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

Dropping Indexes in SQL Server uses a different syntax than DROP CONSTRAINT #212

Open
elpete opened this issue Jan 28, 2022 · 4 comments
Open

Comments

@elpete
Copy link
Collaborator

elpete commented Jan 28, 2022

DROP INDEX table_name.index_name;
@jclausen
Copy link
Contributor

This affects any migrations for SQL server which require indices to be dropped on a column before removal. Because of this, I suggest adding a dropIndex method to the dialects, which will pass through to dropConstraint on all except SQL Server. The corresponding addIndex method can be added as well, which will allow more precision during schema creation. I can PR this if you are good with the above approach?

@elpete
Copy link
Collaborator Author

elpete commented Aug 16, 2022

I'm fine with the method name as well, but I think I'd also like dropConstraint to use to correct syntax on SQL Server. We should be able to detect when we are passed a TableIndex and parse accordingly.

@jclausen
Copy link
Contributor

The syntax it currently uses is correct for what SQL server considers to be a constraint ( e.g. Foreign Keys, Unique index ). The problem is that SQL Server does not see a simple non-clustered index on a column as a "constraint". To me it makes more sense to separate those methods, rather than change the method signature, since SQL Server sees a constraint and an index as different.

@elpete
Copy link
Collaborator Author

elpete commented Aug 16, 2022

The reason I'd like both to work is for engine portability. I don't want to have to change my qb code if I switch from MySQL to SQL Server.

@elpete elpete added this to the v9.0.0 milestone Jan 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants