Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to migrate from version 1.7.4 to version 1.8.0 #6707

Closed
1 of 6 tasks
alexmejiaec opened this issue Apr 22, 2019 · 21 comments
Closed
1 of 6 tasks

Unable to migrate from version 1.7.4 to version 1.8.0 #6707

alexmejiaec opened this issue Apr 22, 2019 · 21 comments
Labels
issue/critical This issue should be fixed ASAP. If it is a PR, the PR should be merged ASAP type/bug
Milestone

Comments

@alexmejiaec
Copy link

  • Gitea version (or commit ref): 1.8.0
  • Git version: 2.16.2.windows.1
  • Operating system: WIndows server 2012
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • [x ] Not relevant
  • Log gist:

Description

Hi guys, I'm facing a issue when upgrading from version 1.74 to 1.8.0 :

2019/04/22 10:25:23 [I] Migration: add theme to users
2019/04/22 10:25:30 [I] Migration: rename repo is_bare to repo is_empty
2019/04/22 10:25:30 [I] Backing off for 3 seconds
2019/04/22 10:25:33 [I] ORM engine initialization attempt #2/10...
2019/04/22 10:25:33 [I] Migration: rename repo is_bare to repo is_empty
2019/04/22 10:25:34 [I] Backing off for 3 seconds
2019/04/22 10:25:37 [I] ORM engine initialization attempt #3/10...
2019/04/22 10:25:37 [I] Migration: rename repo is_bare to repo is_empty
2019/04/22 10:25:37 [I] Backing off for 3 seconds
2019/04/22 10:25:40 [I] ORM engine initialization attempt #4/10...
2019/04/22 10:25:40 [I] Migration: rename repo is_bare to repo is_empty
2019/04/22 10:25:40 [I] Backing off for 3 seconds
2019/04/22 10:25:44 [I] ORM engine initialization attempt #5/10...
2019/04/22 10:25:44 [I] Migration: rename repo is_bare to repo is_empty
2019/04/22 10:25:44 [I] Backing off for 3 seconds
2019/04/22 10:25:47 [I] ORM engine initialization attempt #6/10...
2019/04/22 10:25:47 [I] Migration: rename repo is_bare to repo is_empty
2019/04/22 10:25:47 [I] Backing off for 3 seconds
2019/04/22 10:25:50 [I] ORM engine initialization attempt #7/10...
2019/04/22 10:25:50 [I] Migration: rename repo is_bare to repo is_empty
2019/04/22 10:25:51 [I] Backing off for 3 seconds
2019/04/22 10:25:54 [I] ORM engine initialization attempt #8/10...
2019/04/22 10:25:54 [I] Migration: rename repo is_bare to repo is_empty
2019/04/22 10:25:54 [I] Backing off for 3 seconds
2019/04/22 10:25:57 [I] ORM engine initialization attempt #9/10...
2019/04/22 10:25:57 [I] Migration: rename repo is_bare to repo is_empty
2019/04/22 10:25:57 [I] Backing off for 3 seconds
2019/04/22 10:26:00 [I] ORM engine initialization attempt #10/10...
2019/04/22 10:26:00 [I] Migration: rename repo is_bare to repo is_empty
2019/04/22 10:26:01 [...itea/routers/init.go:82 GlobalInit()] [E] ORM engine initialization failed: migrate: do migrate: Drop column failed: mssql: Error de ALTER TABLE DROP COLUMN is_bare debido a que uno o más objetos tienen acceso a columna.
2019/04/22 10:26:22 [I] Log Mode: File(Info)
2019/04/22 10:26:22 [I] XORM Log Mode: File(Info)
2019/04/22 10:26:22 [I] Cache Service Enabled
2019/04/22 10:26:22 [I] Session Service Enabled
2019/04/22 10:26:22 [I] Mail Service Enabled
2019/04/22 10:26:22 [I] Notify Mail Service Enabled
2019/04/22 10:26:22 [I] Beginning ORM engine initialization.
2019/04/22 10:26:22 [I] ORM engine initialization attempt #1/10...
2019/04/22 10:26:22 [I] Migration: rename repo is_bare to repo is_empty
2019/04/22 10:26:29 [I] Backing off for 3 seconds
2019/04/22 10:26:32 [I] ORM engine initialization attempt #2/10...
2019/04/22 10:26:32 [I] Migration: rename repo is_bare to repo is_empty
2019/04/22 10:26:33 [I] Backing off for 3 seconds
2019/04/22 10:26:36 [I] ORM engine initialization attempt #3/10...
2019/04/22 10:26:36 [I] Migration: rename repo is_bare to repo is_empty
2019/04/22 10:26:36 [I] Backing off for 3 seconds
2019/04/22 10:26:39 [I] ORM engine initialization attempt #4/10...
2019/04/22 10:26:39 [I] Migration: rename repo is_bare to repo is_empty
2019/04/22 10:26:39 [I] Backing off for 3 seconds
2019/04/22 10:26:42 [I] ORM engine initialization attempt #5/10...
2019/04/22 10:26:43 [I] Migration: rename repo is_bare to repo is_empty
2019/04/22 10:26:43 [I] Backing off for 3 seconds
2019/04/22 10:26:46 [I] ORM engine initialization attempt #6/10...
2019/04/22 10:26:46 [I] Migration: rename repo is_bare to repo is_empty
2019/04/22 10:26:46 [I] Backing off for 3 seconds
2019/04/22 10:26:49 [I] ORM engine initialization attempt #7/10...
2019/04/22 10:26:49 [I] Migration: rename repo is_bare to repo is_empty
2019/04/22 10:26:50 [I] Backing off for 3 seconds
2019/04/22 10:26:53 [I] ORM engine initialization attempt #8/10...
2019/04/22 10:26:53 [I] Migration: rename repo is_bare to repo is_empty
2019/04/22 10:26:54 [I] Backing off for 3 seconds
2019/04/22 10:26:57 [I] ORM engine initialization attempt #9/10...
2019/04/22 10:26:57 [I] Migration: rename repo is_bare to repo is_empty
2019/04/22 10:26:57 [I] Backing off for 3 seconds
2019/04/22 10:27:00 [I] ORM engine initialization attempt #10/10...
2019/04/22 10:27:00 [I] Migration: rename repo is_bare to repo is_empty
2019/04/22 10:27:01 [...itea/routers/init.go:82 GlobalInit()] [E] ORM engine initialization failed: migrate: do migrate: Drop column failed: mssql: Error de ALTER TABLE DROP COLUMN is_bare debido a que uno o más objetos tienen acceso a columna.

Do you have any solution or workaround for this?

@lafriks
Copy link
Member

lafriks commented Apr 22, 2019

Could be bug in mssql migration

@lunny
Copy link
Member

lunny commented Apr 23, 2019

@alexmejiaec could you try to upgrade to v1.7.6 and then upgrade to v1.8.0?

@lafriks
Copy link
Member

lafriks commented Apr 23, 2019

@lunny I don't think that will help

@alexmejiaec
Copy link
Author

alexmejiaec commented Apr 23, 2019

@lunny Did the try: 1.7.4 -> 1.7.6 -> 1.8.0 , not working

2019/04/23 08:47:58 [I] Log Mode: File(Info)
2019/04/23 08:47:58 [I] XORM Log Mode: File(Info)
2019/04/23 08:47:58 [I] Cache Service Enabled
2019/04/23 08:47:58 [I] Session Service Enabled
2019/04/23 08:47:58 [I] Mail Service Enabled
2019/04/23 08:47:58 [I] Notify Mail Service Enabled
2019/04/23 08:47:58 [I] Beginning ORM engine initialization.
2019/04/23 08:47:58 [I] ORM engine initialization attempt #1/10...
2019/04/23 08:48:01 [I] Migration: add theme to users
2019/04/23 08:48:08 [I] Migration: rename repo is_bare to repo is_empty
2019/04/23 08:48:08 [I] Backing off for 3 seconds
2019/04/23 08:48:11 [I] ORM engine initialization attempt #2/10...
2019/04/23 08:48:11 [I] Migration: rename repo is_bare to repo is_empty
2019/04/23 08:48:18 [I] Backing off for 3 seconds
2019/04/23 08:48:21 [I] ORM engine initialization attempt #3/10...
2019/04/23 08:48:21 [I] Migration: rename repo is_bare to repo is_empty
2019/04/23 08:48:22 [I] Backing off for 3 seconds
2019/04/23 08:48:25 [I] ORM engine initialization attempt #4/10...
2019/04/23 08:48:25 [I] Migration: rename repo is_bare to repo is_empty
2019/04/23 08:48:25 [I] Backing off for 3 seconds
2019/04/23 08:48:28 [I] ORM engine initialization attempt #5/10...
2019/04/23 08:48:28 [I] Migration: rename repo is_bare to repo is_empty
2019/04/23 08:48:28 [I] Backing off for 3 seconds
2019/04/23 08:48:31 [I] ORM engine initialization attempt #6/10...
2019/04/23 08:48:31 [I] Migration: rename repo is_bare to repo is_empty
2019/04/23 08:48:32 [I] Backing off for 3 seconds
2019/04/23 08:48:35 [I] ORM engine initialization attempt #7/10...
2019/04/23 08:48:35 [I] Migration: rename repo is_bare to repo is_empty
2019/04/23 08:48:35 [I] Backing off for 3 seconds
2019/04/23 08:48:38 [I] ORM engine initialization attempt #8/10...
2019/04/23 08:48:38 [I] Migration: rename repo is_bare to repo is_empty
2019/04/23 08:48:38 [I] Backing off for 3 seconds
2019/04/23 08:48:41 [I] ORM engine initialization attempt #9/10...
2019/04/23 08:48:45 [I] Migration: rename repo is_bare to repo is_empty
2019/04/23 08:48:45 [I] Backing off for 3 seconds
2019/04/23 08:48:48 [I] ORM engine initialization attempt #10/10...
2019/04/23 08:48:48 [I] Migration: rename repo is_bare to repo is_empty
2019/04/23 08:48:48 [...itea/routers/init.go:82 GlobalInit()] [E] ORM engine initialization failed: migrate: do migrate: Drop column failed: mssql: Error de ALTER TABLE DROP COLUMN is_bare debido a que uno o más objetos tienen acceso a columna.
2019/04/23 08:49:18 [I] Log Mode: File(Info)

Currently running on 1.7.6

@alexmejiaec
Copy link
Author

My current configuration , if it helps

APP_NAME = GIT NTS
RUN_USER = COMPUTERNAME$
RUN_MODE = prod

[security]
INTERNAL_TOKEN = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
INSTALL_LOCK = true
SECRET_KEY = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

[database]
DB_TYPE = mssql
HOST = 127.0.0.1\SQLEXPRESS:1433
NAME = gitea
USER = gitea
PASSWD = XXXXXXXXXXXXXXXXXXXX
SSL_MODE = disable
PATH = data/gitea.db

[repository]
ROOT = C:/Repositorios

[server]
SSH_DOMAIN = localhost
DOMAIN = localhost
HTTP_PORT = 3000
ROOT_URL = http://servidorfuentes:3000/
DISABLE_SSH = false
SSH_PORT = 22
LFS_START_SERVER = true
LFS_CONTENT_PATH = c:/gitea/data/lfs
LFS_JWT_SECRET = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
OFFLINE_MODE = false

[mailer]
ENABLED = true
SUBJECT = %(APP_NAME)s
HOST = smtp.gmail.com:587
FROM = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
USER = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
PASSWD = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

[service]
REGISTER_EMAIL_CONFIRM = false
ENABLE_NOTIFY_MAIL = true
DISABLE_REGISTRATION = true
ALLOW_ONLY_EXTERNAL_REGISTRATION = false
ENABLE_CAPTCHA = false
REQUIRE_SIGNIN_VIEW = false
DEFAULT_KEEP_EMAIL_PRIVATE = false
DEFAULT_ALLOW_CREATE_ORGANIZATION = true
DEFAULT_ENABLE_TIMETRACKING = true
NO_REPLY_ADDRESS = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

[picture]
DISABLE_GRAVATAR = false
ENABLE_FEDERATED_AVATAR = true

[openid]
ENABLE_OPENID_SIGNIN = false
ENABLE_OPENID_SIGNUP = false

[session]
PROVIDER = file

[log]
MODE = file
LEVEL = Info
ROOT_PATH = c:/gitea/log

[ui]
DEFAULT_THEME = arc-green

[oauth2]
JWT_SECRET = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

@zeripath
Copy link
Contributor

The error with is_bare implies that migration 78 hasn't run properly. But that should have happened ages ago.

Try setting the version in the version table to 78 to skip the migration. Drop the is_bare column by hand.

@alexmejiaec
Copy link
Author

Yup that worked, thanks

BTW, the error is given because there's a constraint for is_bare that wasn't being dropped, thus not allowing renaming the column

@zeripath
Copy link
Contributor

damn that's annoying.

Fancy creating a PR for it? the file is models/migrations/v78.go

Otherwise if you tell me the SQL I can add it to the file and try to create a PR.

@alexmejiaec
Copy link
Author

alexmejiaec commented Apr 23, 2019

Actually I think there's a bit of a problem for that

It looks like the constrait was created without a name, like :

Alter table add is_bare bit null default(0)

So I had in my db a contraint with a SQL server generated name: DF__repositor__is_ba__1FCDBCEB

The SQL required to drop that constraint was :
ALTER TABLE [dbo].[repository] DROP CONSTRAINT [DF__repositor__is_ba__1FCDBCEB]

But as the name of the constraint is system named I don't think you can add this in a migration

I don't know if is related, but I also had to create is_empty column , as I checked the migration before and noticed that the info from is_bare was transfered to is_empty

@zeripath
Copy link
Contributor

Ah that's why the migration didn't work for you. OK we're screwed in those cases and we will just have to cope with the issue reports I guess.

OK, so you need to double check that repositories that are empty are marked with is_empty because unfortunately you'll get 500s if you try to access them.

@Cellebyte
Copy link

Is their currently a solution instead of manually do it.

@zeripath
Copy link
Contributor

@Cellebyte Do you have the same issue as @alexmejiaec - is your constraint also autonamed?

@zeripath
Copy link
Contributor

@Cellebyte
Copy link

Cellebyte commented Apr 26, 2019

So i have the same Error Message as above in English.

2019/04/24 07:50:00 [...itea/routers/init.go:82 GlobalInit()] [E] ORM engine initialization failed: migrate: do migrate: Drop column failed: mssql: ALTER TABLE DROP COLUMN is_bare failed because one or more objects access this column

I do not know how to fix that.

@alexmejiaec
Copy link
Author

@Cellebyte Try drop the column is_bare in repository table and check what error gives

@Cellebyte
Copy link

Cellebyte commented Apr 27, 2019

@Cellebyte Try drop the column is_bare in repository table and check what error gives

failed because one or more objects access this column.

Or is the error message more specific on the DBMS than in ORM.
I will try it when I am back at work on Monday.

@lafriks lafriks added the issue/critical This issue should be fixed ASAP. If it is a PR, the PR should be merged ASAP label Apr 27, 2019
@PaulBol
Copy link

PaulBol commented Apr 30, 2019

This script can be used to drop the constraint without knowing the exact name

DECLARE @ConstraintName VARCHAR(256)
DECLARE @SQL NVARCHAR(256)
SELECT @ConstraintName = obj.name FROM sys.columns col LEFT OUTER JOIN sys.objects obj ON obj.object_id = col.default_object_id AND obj.type = 'D' WHERE col.object_id = OBJECT_ID('repository') AND obj.name IS NOT NULL AND col.name = 'is_bare'
SET @SQL = N'ALTER TABLE [repository] DROP CONSTRAINT [' + @ConstraintName + N']'
EXEC sp_executesql @SQL

@achikhv
Copy link

achikhv commented May 1, 2019

Getting similar error when upgrading from 1.7.6 to 1.8.0. But the last line is different
Is there any solution or workaround?

SQL Server 2014

2019/05/02 00:04:23 [I] Beginning ORM engine initialization.
2019/05/02 00:04:23 [I] ORM engine initialization attempt #1/10...
2019/05/02 00:04:23 [I] Migration: add theme to users
2019/05/02 00:04:23 [I] Migration: rename repo is_bare to repo is_empty
2019/05/02 00:04:23 [I] Backing off for 3 seconds
2019/05/02 00:04:26 [I] ORM engine initialization attempt #2/10...
2019/05/02 00:04:26 [I] Migration: rename repo is_bare to repo is_empty
2019/05/02 00:04:26 [I] Backing off for 3 seconds
2019/05/02 00:04:29 [I] ORM engine initialization attempt #3/10...
2019/05/02 00:04:29 [I] Migration: rename repo is_bare to repo is_empty
2019/05/02 00:04:29 [I] Backing off for 3 seconds
2019/05/02 00:04:32 [I] ORM engine initialization attempt #4/10...
2019/05/02 00:04:32 [I] Migration: rename repo is_bare to repo is_empty
2019/05/02 00:04:32 [I] Backing off for 3 seconds
2019/05/02 00:04:35 [I] ORM engine initialization attempt #5/10...
2019/05/02 00:04:35 [I] Migration: rename repo is_bare to repo is_empty
2019/05/02 00:04:35 [I] Backing off for 3 seconds
2019/05/02 00:04:38 [I] ORM engine initialization attempt #6/10...
2019/05/02 00:04:38 [I] Migration: rename repo is_bare to repo is_empty
2019/05/02 00:04:38 [I] Backing off for 3 seconds
2019/05/02 00:04:41 [I] ORM engine initialization attempt #7/10...
2019/05/02 00:04:41 [I] Migration: rename repo is_bare to repo is_empty
2019/05/02 00:04:41 [I] Backing off for 3 seconds
2019/05/02 00:04:44 [I] ORM engine initialization attempt #8/10...
2019/05/02 00:04:44 [I] Migration: rename repo is_bare to repo is_empty
2019/05/02 00:04:44 [I] Backing off for 3 seconds
2019/05/02 00:04:47 [I] ORM engine initialization attempt #9/10...
2019/05/02 00:04:47 [I] Migration: rename repo is_bare to repo is_empty
2019/05/02 00:04:47 [I] Backing off for 3 seconds
2019/05/02 00:04:50 [I] ORM engine initialization attempt #10/10...
2019/05/02 00:04:50 [I] Migration: rename repo is_bare to repo is_empty
2019/05/02 00:04:50 [...itea/routers/init.go:82 GlobalInit()] [E] ORM engine initialization failed: migrate: do migrate: Drop index failed: mssql: Incorrect syntax near the keyword 'IF'.

@PaulBol
Copy link

PaulBol commented May 2, 2019

Incorrect syntax near the keyword 'IF' should be caused by the same script.

DROP INDEX IF EXISTS IDX_repository_is_bare ON repository

IF EXISTS is only supported by SQL Server 2016+, see https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-index-transact-sql?view=sql-server-2017

The suggested workaround should work with SQL Server 2014, too.

@zeripath
Copy link
Contributor

zeripath commented May 2, 2019

I think #6823 will fix this. It'll need to be backported to 1.8

@lafriks lafriks added this to the 1.8.1 milestone May 4, 2019
zeripath added a commit to zeripath/gitea that referenced this issue May 5, 2019
zeripath added a commit to zeripath/gitea that referenced this issue May 5, 2019
zeripath added a commit to zeripath/gitea that referenced this issue May 5, 2019
zeripath added a commit to zeripath/gitea that referenced this issue May 5, 2019
zeripath added a commit to zeripath/gitea that referenced this issue May 5, 2019
lunny pushed a commit that referenced this issue May 6, 2019
@Cellebyte
Copy link

Migration is now working thanks for the fix.

@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
issue/critical This issue should be fixed ASAP. If it is a PR, the PR should be merged ASAP type/bug
Projects
None yet
Development

No branches or pull requests

7 participants