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

Support sqlite alter table drop column when applying new schema #3231

Open
alarbada opened this issue Nov 25, 2024 · 1 comment
Open

Support sqlite alter table drop column when applying new schema #3231

alarbada opened this issue Nov 25, 2024 · 1 comment
Assignees

Comments

@alarbada
Copy link

Sqlite supports dropping columns for a while now.

I was surprised to see that atlas still migrates the old way, removing and creating the table again.

@alarbada alarbada changed the title Support sqlite alter table drop column Support sqlite alter table drop column when applying new schema Nov 25, 2024
@a8m a8m self-assigned this Nov 25, 2024
@a8m
Copy link
Member

a8m commented Nov 25, 2024

Thanks for bringing this up, @alarbada. DROP COLUMN is allowed only with a few limitations:

The DROP COLUMN command only works if the column is not referenced by any other parts of the schema and is not a PRIMARY KEY and does not have a UNIQUE constraint. Possible reasons why the DROP COLUMN command can fail include:

The column is a PRIMARY KEY or part of one.
The column has a UNIQUE constraint.
The column is indexed.
The column is named in the WHERE clause of a partial index.
The column is named in a table or column CHECK constraint not associated with the column being dropped.
The column is used in a foreign key constraint.
The column is used in the expression of a generated column.
The column appears in a trigger or view.

However, this can still be improved. I've assigned it to myself, and we will add it to the upcoming milestones.

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

No branches or pull requests

2 participants