-
-
Notifications
You must be signed in to change notification settings - Fork 253
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
IF (NOT) EXISTS for ALTER TABLE sub-commands like constraints etc #524
Comments
I think these would be good contributions, although I would still consider this to be #151, and additionally because the DDL for these constructs comes from SQLAlchemy it would be cleaner to be on the SQLAlhcemy side added to the CreateIndex, DropIndex etc constructs. The good news is that CASCADE, while not really supported by any major DB except Postgresql, is in the SQL standard, so it can go right in as is. "IF (NOT) EXISTS" seems like it's not part of the standard but it seems to be in every database these days. anyway the issue you want to be mainly working on is in SQLAlchemy over at: sqlalchemy/sqlalchemy#2843 . CASCADE can be part of it too for those constructs where it applies. you will note how often in that bug, people offer to work on the issue, then disappear, or I ask people to provide a PR, then they disappear, etc. I've gotten PRs for some very complex features in this area like support for schema comments and such so I know it's doable. |
to clarify, the change has to be both in SQLAlchemy and Alembic - SQLAlchemy's CreateIndex/DropIndex/CreateTable/DropTable/AddConstraint/DropConstraint all get CASCADE and IF (NOT) EXISTS as is available on databases, then Alembic's op directives gain those flags and pass them through. I dont think Alembic's autogenerate feature needs anything at all here as these directives don't apply to a automatically managed schema. |
Hello, forgive me if an issue already exists for this, I have seen a related one here but that is several years old and status is unclear.
There doesn't seem to be an option to add IF (NOT) EXISTS or CASCADE flags to queries generated by e.g.
op.create_unique_constraint
orop.drop_index
. Here are some raw queries I've added and directly executed lately:or
I would like to be able to create these with alembic, for example:
(The syntax could be different to better fit the style of existing commands, if needed.)
I haven't contributed yet but I might be able to work on this issue if it is deemed a worthwhile change to the project.
The text was updated successfully, but these errors were encountered: