]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commit
Add support of IF [NOT] EXISTS for ADD/DROP COLUMN in Postgresql
authorLouis-Amaury Chaib <louisamaury.chaib@partoo.fr>
Mon, 19 May 2025 13:11:00 +0000 (09:11 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 19 May 2025 16:03:15 +0000 (12:03 -0400)
commitcfc9de8c6c45c68f90205c3e9d414d5e451b7d74
tree1f7c3b26e5310a82dcdcf62fa91cf08afe7c9769
parent76791bbb42b4b2829dc79df5ea5234ac7dc226b0
Add support of IF [NOT] EXISTS for ADD/DROP COLUMN in Postgresql

Added :paramref:`.Operations.add_column.if_not_exists` and
:paramref:`.Operations.drop_column.if_exists` to render ``IF [NOT] EXISTS``
for ``ADD COLUMN`` and ``DROP COLUMN`` operations, a feature available on
some database backends such as PostgreSQL, MariaDB, as well as third party
backends.  The parameters also support autogenerate rendering allowing them
to be turned on via a custom :class:`.Rewriter`. Pull request courtesy of
Louis-Amaury Chaib (@lachaib).

Fixes: #1626
Closes: #1627
Pull-request: https://github.com/sqlalchemy/alembic/pull/1627
Pull-request-sha: c503b049f453a12e7fdb87464606cddd58ad306c

Change-Id: I4d55f65f072b9f03698b2f45f066872b5c3e8c58
17 files changed:
alembic/autogenerate/render.py
alembic/ddl/base.py
alembic/ddl/impl.py
alembic/ddl/mssql.py
alembic/ddl/mysql.py
alembic/ddl/postgresql.py
alembic/op.pyi
alembic/operations/base.py
alembic/operations/ops.py
alembic/operations/toimpl.py
docs/build/cookbook.rst
docs/build/unreleased/1626.rst [new file with mode: 0644]
tests/test_autogen_render.py
tests/test_batch.py
tests/test_mysql.py
tests/test_op.py
tests/test_postgresql.py