summaryrefslogtreecommitdiff
path: root/alembic/ddl
diff options
context:
space:
mode:
authorAdrien Berchet <adrien.berchet@gmail.com>2022-05-31 08:31:25 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2022-05-31 16:26:37 -0400
commitf73456034f51de5a1a7a9c4d6b23f459049776d0 (patch)
treea17b866e7ed193f5c287bd8adc51894b15ae324e /alembic/ddl
parent188dd8b2f098e804c8e64956e9c6490d41f1d7ce (diff)
downloadalembic-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/ddl')
-rw-r--r--alembic/ddl/impl.py6
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))