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

Failed attempt to migrate to 1.15-rc2 windows SQL Server 2008 R2 sp3 #16625

Closed
2 of 6 tasks
snoopydo opened this issue Aug 4, 2021 · 2 comments · Fixed by #16627
Closed
2 of 6 tasks

Failed attempt to migrate to 1.15-rc2 windows SQL Server 2008 R2 sp3 #16625

snoopydo opened this issue Aug 4, 2021 · 2 comments · Fixed by #16627

Comments

@snoopydo
Copy link

snoopydo commented Aug 4, 2021

  • Gitea version (or commit ref): v1.15.0-rc2
  • Git version: 2.32.0.windows.2
  • Operating system: Windows
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
  • Log gist:

Description

from my initial discord post.
Just tried 1.15-rc2 windows go-git version and it fails to start, with sql errors during migration.
We're using SQL 2008 R2 which doesn't support IF EXISTS option.

2021/07/29 11:33:53 ...ations/migrations.go:49:Migrate() [I] [SQL] ALTER TABLE [hook_task] DROP CONSTRAINT IF EXISTS [IDX_tmp_recreatehook_task_typ] []
2021/07/29 11:33:53 ...ations/migrations.go:422:Migrate() [I] [SQL] ROLLBACK [] - 504.6µs
2021/07/29 11:33:53 routers/init.go: 100:GlobalInit() [F] ORM engine initialization failed: migrate: do migrate: Drop table hook_task index constraint `IDX_tmp_recreatehook_task_typ`: mssql: Incorrect syntax near the keyword 'IF'
@snoopydo
Copy link
Author

snoopydo commented Aug 4, 2021

Having a look at /models/migrations/migrations.go#L854, it looks to me that the code is looking up the names of constraints that need to be dropped, making the 'IF EXISTS' clause on lines 861 & 864 redundant?

@zeripath zeripath changed the title Failed attempt to migrate to 1.15-rc2 windows go-git version Failed attempt to migrate to 1.15-rc2 windows SQL Server 2008 R2 sp3 Aug 5, 2021
@zeripath
Copy link
Contributor

zeripath commented Aug 5, 2021

The if exists here is belt and braces - it could be dropped.

The main issue is that we can't test against such very old versions of SQL Server. It's difficult enough to write migrations that SQL server will accept at the best of times.

From the transact SQL documentation:

IF EXISTS
Applies to: SQL Server (SQL Server 2016 (13.x) and later) and Azure SQL Database.

I guess the way to proceed in this case is to adjust this migration to not use IF EXISTS but we need to decide what is the oldest version of SQL server we support.

(For example I don't think we can support versions that don't even have SYS.INDEXES - I think this is sub 2000! Although if users in this case were willing to provide alternative SQL we could use it.)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants