[x]):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?
Could be bug in mssql migration
@alexmejiaec could you try to upgrade to v1.7.6 and then upgrade to v1.8.0?
@lunny I don't think that will help
@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
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
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.
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
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.
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
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.
Is their currently a solution instead of manually do it.
@Cellebyte Do you have the same issue as @alexmejiaec - is your constraint also autonamed?
OK so the following SO comments discuss how to drop these constraints:
https://stackoverflow.com/questions/670946/dropping-unnamed-constraints
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.
@Cellebyte Try drop the column is_bare in repository table and check what error gives
@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.
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
                    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'.
                    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.
I think #6823 will fix this. It'll need to be backported to 1.8
Migration is now working thanks for the fix.
Most helpful comment
This script can be used to drop the constraint without knowing the exact name