diff options
author | Adrien Berchet <adrien.berchet@gmail.com> | 2022-05-31 08:31:25 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-05-31 16:26:37 -0400 |
commit | f73456034f51de5a1a7a9c4d6b23f459049776d0 (patch) | |
tree | a17b866e7ed193f5c287bd8adc51894b15ae324e /alembic | |
parent | 188dd8b2f098e804c8e64956e9c6490d41f1d7ce (diff) | |
download | alembic-f73456034f51de5a1a7a9c4d6b23f459049776d0.tar.gz |
Trigger events before and after drop table statements
The ``op.drop_table()`` operation directive will now trigger the
``before_drop()`` and ``after_drop()`` DDL event hooks at the table level,
which is similar to how the ``before_create()`` and ``after_create()``
hooks are triggered by the ``op.create_table()`` directive. Note that as
``op.drop_table()`` accepts only a table name and optional schema name, the
``Table`` object received by the event will not have any information within
it other than the table name and schema name.
Fixes: #1037
Closes: #1036
Pull-request: https://github.com/sqlalchemy/alembic/pull/1036
Pull-request-sha: ea44e7f3398aa5001e86e6a7e30f61f6a86d9674
Change-Id: I20a1702e17ed88054206d964152ce05b81d0f89e
Diffstat (limited to 'alembic')
-rw-r--r-- | alembic/ddl/impl.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/alembic/ddl/impl.py b/alembic/ddl/impl.py index 8c9e0b9..070c124 100644 --- a/alembic/ddl/impl.py +++ b/alembic/ddl/impl.py @@ -371,7 +371,13 @@ class DefaultImpl(metaclass=ImplMeta): self.create_column_comment(column) def drop_table(self, table: "Table") -> None: + table.dispatch.before_drop( + table, self.connection, checkfirst=False, _ddl_runner=self + ) self._exec(schema.DropTable(table)) + table.dispatch.after_drop( + table, self.connection, checkfirst=False, _ddl_runner=self + ) def create_index(self, index: "Index") -> None: self._exec(schema.CreateIndex(index)) |