Skip to content

MSSQL error DROP INDEX IF EXISTS: Incorrect syntax near the keyword ‘IF’ #30872

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

Closed
wxiaoguang opened this issue May 6, 2024 · 2 comments · Fixed by #30894
Closed

MSSQL error DROP INDEX IF EXISTS: Incorrect syntax near the keyword ‘IF’ #30872

wxiaoguang opened this issue May 6, 2024 · 2 comments · Fixed by #30894
Labels
issue/critical This issue should be fixed ASAP. If it is a PR, the PR should be merged ASAP skip-changelog This PR is irrelevant for the (next) changelog, for example bug fixes for unreleased features. type/bug
Milestone

Comments

@wxiaoguang
Copy link
Contributor

wxiaoguang commented May 6, 2024

https://forum.gitea.com/t/add-support-for-sha256-git-repositories-failed/9062

2024/04/30 17:15:03 routers/init.go:72:mustInitCtx() [F] ... failed: migrate: migration[286]: Add support for SHA256 git repositories failed: DROP INDEX IF EXISTS [IDX_commit_status_context_hash] ON [commit_status] mssql: Incorrect syntax near the keyword ‘IF’.

@lunny

@wxiaoguang wxiaoguang added type/bug issue/critical This issue should be fixed ASAP. If it is a PR, the PR should be merged ASAP labels May 6, 2024
@techknowlogick techknowlogick added this to the 1.22.0 milestone May 6, 2024
@silverwind
Copy link
Member

Which MSSQL version? The forum link seems 404.

https://learn.microsoft.com/en-us/sql/t-sql/statements/drop-index-transact-sql?view=sql-server-ver16 indicates 2016 and above supports IF EXISTS clause.

@lunny
Copy link
Member

lunny commented May 8, 2024

lunny added a commit that referenced this issue May 11, 2024
…ired SQL server 2016 (#30894)

Fix #30872

We will assume the database is consistent before executing the
migration. So the indexes should exist. Removing `IF EXIST` then is safe
enough.

---------

Co-authored-by: silverwind <[email protected]>
GiteaBot pushed a commit to GiteaBot/gitea that referenced this issue May 11, 2024
…ired SQL server 2016 (go-gitea#30894)

Fix go-gitea#30872

We will assume the database is consistent before executing the
migration. So the indexes should exist. Removing `IF EXIST` then is safe
enough.

---------

Co-authored-by: silverwind <[email protected]>
@lunny lunny added the skip-changelog This PR is irrelevant for the (next) changelog, for example bug fixes for unreleased features. label May 11, 2024
lunny added a commit that referenced this issue May 12, 2024
…ired SQL server 2016 (#30894) (#30946)

Backport #30894 by @lunny

Fix #30872

We will assume the database is consistent before executing the
migration. So the indexes should exist. Removing `IF EXIST` then is safe
enough.

Co-authored-by: Lunny Xiao <[email protected]>
Co-authored-by: silverwind <[email protected]>
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Aug 9, 2024
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 skip-changelog This PR is irrelevant for the (next) changelog, for example bug fixes for unreleased features. type/bug
Projects
None yet
4 participants