alembic 1.11.0__py3-none-any.whl → 1.11.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- alembic/__init__.py +1 -1
- alembic/autogenerate/api.py +0 -2
- alembic/autogenerate/compare.py +24 -35
- alembic/autogenerate/render.py +24 -38
- alembic/command.py +0 -1
- alembic/config.py +20 -7
- alembic/context.pyi +2 -2
- alembic/ddl/base.py +3 -3
- alembic/ddl/impl.py +14 -9
- alembic/ddl/mssql.py +8 -9
- alembic/ddl/mysql.py +0 -1
- alembic/ddl/oracle.py +1 -1
- alembic/ddl/postgresql.py +35 -12
- alembic/ddl/sqlite.py +3 -5
- alembic/op.pyi +32 -20
- alembic/operations/base.py +34 -22
- alembic/operations/batch.py +10 -8
- alembic/operations/ops.py +60 -36
- alembic/operations/toimpl.py +18 -4
- alembic/runtime/environment.py +2 -3
- alembic/runtime/migration.py +3 -7
- alembic/script/base.py +3 -7
- alembic/script/revision.py +0 -4
- alembic/script/write_hooks.py +8 -7
- alembic/templates/async/script.py.mako +6 -4
- alembic/templates/generic/script.py.mako +6 -4
- alembic/templates/multidb/script.py.mako +6 -4
- alembic/testing/assertions.py +0 -3
- alembic/testing/env.py +0 -3
- alembic/testing/fixtures.py +0 -2
- alembic/testing/suite/_autogen_fixtures.py +0 -1
- alembic/util/langhelpers.py +0 -1
- alembic/util/pyfiles.py +0 -1
- alembic/util/sqla_compat.py +4 -5
- {alembic-1.11.0.dist-info → alembic-1.11.2.dist-info}/METADATA +1 -1
- {alembic-1.11.0.dist-info → alembic-1.11.2.dist-info}/RECORD +40 -40
- {alembic-1.11.0.dist-info → alembic-1.11.2.dist-info}/WHEEL +1 -1
- {alembic-1.11.0.dist-info → alembic-1.11.2.dist-info}/LICENSE +0 -0
- {alembic-1.11.0.dist-info → alembic-1.11.2.dist-info}/entry_points.txt +0 -0
- {alembic-1.11.0.dist-info → alembic-1.11.2.dist-info}/top_level.txt +0 -0
alembic/ddl/mssql.py
CHANGED
@@ -98,7 +98,6 @@ class MSSQLImpl(DefaultImpl):
|
|
98
98
|
existing_nullable: Optional[bool] = None,
|
99
99
|
**kw: Any,
|
100
100
|
) -> None:
|
101
|
-
|
102
101
|
if nullable is not None:
|
103
102
|
if type_ is not None:
|
104
103
|
# the NULL/NOT NULL alter will handle
|
@@ -171,7 +170,7 @@ class MSSQLImpl(DefaultImpl):
|
|
171
170
|
table_name, column_name, schema=schema, name=name
|
172
171
|
)
|
173
172
|
|
174
|
-
def create_index(self, index: Index) -> None:
|
173
|
+
def create_index(self, index: Index, **kw: Any) -> None:
|
175
174
|
# this likely defaults to None if not present, so get()
|
176
175
|
# should normally not return the default value. being
|
177
176
|
# defensive in any case
|
@@ -180,7 +179,7 @@ class MSSQLImpl(DefaultImpl):
|
|
180
179
|
for col in mssql_include:
|
181
180
|
if col not in index.table.c:
|
182
181
|
index.table.append_column(Column(col, sqltypes.NullType))
|
183
|
-
self._exec(CreateIndex(index))
|
182
|
+
self._exec(CreateIndex(index, **kw))
|
184
183
|
|
185
184
|
def bulk_insert( # type:ignore[override]
|
186
185
|
self, table: Union[TableClause, Table], rows: List[dict], **kw: Any
|
@@ -201,7 +200,7 @@ class MSSQLImpl(DefaultImpl):
|
|
201
200
|
def drop_column(
|
202
201
|
self,
|
203
202
|
table_name: str,
|
204
|
-
column: Column,
|
203
|
+
column: Column[Any],
|
205
204
|
schema: Optional[str] = None,
|
206
205
|
**kw,
|
207
206
|
) -> None:
|
@@ -231,9 +230,7 @@ class MSSQLImpl(DefaultImpl):
|
|
231
230
|
rendered_metadata_default,
|
232
231
|
rendered_inspector_default,
|
233
232
|
):
|
234
|
-
|
235
233
|
if rendered_metadata_default is not None:
|
236
|
-
|
237
234
|
rendered_metadata_default = re.sub(
|
238
235
|
r"[\(\) \"\']", "", rendered_metadata_default
|
239
236
|
)
|
@@ -273,7 +270,7 @@ class _ExecDropConstraint(Executable, ClauseElement):
|
|
273
270
|
def __init__(
|
274
271
|
self,
|
275
272
|
tname: str,
|
276
|
-
colname: Union[Column, str],
|
273
|
+
colname: Union[Column[Any], str],
|
277
274
|
type_: str,
|
278
275
|
schema: Optional[str],
|
279
276
|
) -> None:
|
@@ -287,7 +284,7 @@ class _ExecDropFKConstraint(Executable, ClauseElement):
|
|
287
284
|
inherit_cache = False
|
288
285
|
|
289
286
|
def __init__(
|
290
|
-
self, tname: str, colname: Column, schema: Optional[str]
|
287
|
+
self, tname: str, colname: Column[Any], schema: Optional[str]
|
291
288
|
) -> None:
|
292
289
|
self.tname = tname
|
293
290
|
self.colname = colname
|
@@ -347,7 +344,9 @@ def visit_add_column(element: AddColumn, compiler: MSDDLCompiler, **kw) -> str:
|
|
347
344
|
)
|
348
345
|
|
349
346
|
|
350
|
-
def mssql_add_column(
|
347
|
+
def mssql_add_column(
|
348
|
+
compiler: MSDDLCompiler, column: Column[Any], **kw
|
349
|
+
) -> str:
|
351
350
|
return "ADD %s" % compiler.get_column_specification(column, **kw)
|
352
351
|
|
353
352
|
|
alembic/ddl/mysql.py
CHANGED
alembic/ddl/oracle.py
CHANGED
@@ -176,7 +176,7 @@ def alter_column(compiler: OracleDDLCompiler, name: str) -> str:
|
|
176
176
|
return "MODIFY %s" % format_column_name(compiler, name)
|
177
177
|
|
178
178
|
|
179
|
-
def add_column(compiler: OracleDDLCompiler, column: Column, **kw) -> str:
|
179
|
+
def add_column(compiler: OracleDDLCompiler, column: Column[Any], **kw) -> str:
|
180
180
|
return "ADD %s" % compiler.get_column_specification(column, **kw)
|
181
181
|
|
182
182
|
|
alembic/ddl/postgresql.py
CHANGED
@@ -12,7 +12,6 @@ from typing import TYPE_CHECKING
|
|
12
12
|
from typing import Union
|
13
13
|
|
14
14
|
from sqlalchemy import Column
|
15
|
-
from sqlalchemy import Index
|
16
15
|
from sqlalchemy import literal_column
|
17
16
|
from sqlalchemy import Numeric
|
18
17
|
from sqlalchemy import text
|
@@ -50,6 +49,8 @@ from ..util import sqla_compat
|
|
50
49
|
if TYPE_CHECKING:
|
51
50
|
from typing import Literal
|
52
51
|
|
52
|
+
from sqlalchemy import Index
|
53
|
+
from sqlalchemy import UniqueConstraint
|
53
54
|
from sqlalchemy.dialects.postgresql.array import ARRAY
|
54
55
|
from sqlalchemy.dialects.postgresql.base import PGDDLCompiler
|
55
56
|
from sqlalchemy.dialects.postgresql.hstore import HSTORE
|
@@ -79,18 +80,19 @@ class PostgresqlImpl(DefaultImpl):
|
|
79
80
|
)
|
80
81
|
identity_attrs_ignore = ("on_null", "order")
|
81
82
|
|
82
|
-
def create_index(self, index):
|
83
|
+
def create_index(self, index: Index, **kw: Any) -> None:
|
83
84
|
# this likely defaults to None if not present, so get()
|
84
85
|
# should normally not return the default value. being
|
85
86
|
# defensive in any case
|
86
87
|
postgresql_include = index.kwargs.get("postgresql_include", None) or ()
|
87
88
|
for col in postgresql_include:
|
88
|
-
if col not in index.table.c:
|
89
|
-
index.table.append_column(
|
90
|
-
|
89
|
+
if col not in index.table.c: # type: ignore[union-attr]
|
90
|
+
index.table.append_column( # type: ignore[union-attr]
|
91
|
+
Column(col, sqltypes.NullType)
|
92
|
+
)
|
93
|
+
self._exec(CreateIndex(index, **kw))
|
91
94
|
|
92
95
|
def prep_table_for_batch(self, batch_impl, table):
|
93
|
-
|
94
96
|
for constraint in table.constraints:
|
95
97
|
if (
|
96
98
|
constraint.name is not None
|
@@ -157,7 +159,6 @@ class PostgresqlImpl(DefaultImpl):
|
|
157
159
|
existing_autoincrement: Optional[bool] = None,
|
158
160
|
**kw: Any,
|
159
161
|
) -> None:
|
160
|
-
|
161
162
|
using = kw.pop("postgresql_using", None)
|
162
163
|
|
163
164
|
if using is not None and type_ is None:
|
@@ -239,7 +240,6 @@ class PostgresqlImpl(DefaultImpl):
|
|
239
240
|
metadata_unique_constraints,
|
240
241
|
metadata_indexes,
|
241
242
|
):
|
242
|
-
|
243
243
|
doubled_constraints = {
|
244
244
|
index
|
245
245
|
for index in conn_indexes
|
@@ -308,6 +308,21 @@ class PostgresqlImpl(DefaultImpl):
|
|
308
308
|
break
|
309
309
|
return to_remove
|
310
310
|
|
311
|
+
def _dialect_sig(
|
312
|
+
self, item: Union[Index, UniqueConstraint]
|
313
|
+
) -> Tuple[Any, ...]:
|
314
|
+
if (
|
315
|
+
item.dialect_kwargs.get("postgresql_nulls_not_distinct")
|
316
|
+
is not None
|
317
|
+
):
|
318
|
+
return (
|
319
|
+
(
|
320
|
+
"nulls_not_distinct",
|
321
|
+
item.dialect_kwargs["postgresql_nulls_not_distinct"],
|
322
|
+
),
|
323
|
+
)
|
324
|
+
return ()
|
325
|
+
|
311
326
|
def create_index_sig(self, index: Index) -> Tuple[Any, ...]:
|
312
327
|
return tuple(
|
313
328
|
self._cleanup_index_expr(
|
@@ -319,7 +334,14 @@ class PostgresqlImpl(DefaultImpl):
|
|
319
334
|
),
|
320
335
|
)
|
321
336
|
for e in index.expressions
|
322
|
-
)
|
337
|
+
) + self._dialect_sig(index)
|
338
|
+
|
339
|
+
def create_unique_constraint_sig(
|
340
|
+
self, const: UniqueConstraint
|
341
|
+
) -> Tuple[Any, ...]:
|
342
|
+
return tuple(
|
343
|
+
sorted([col.name for col in const.columns])
|
344
|
+
) + self._dialect_sig(const)
|
323
345
|
|
324
346
|
def _compile_element(self, element: ClauseElement) -> str:
|
325
347
|
return element.compile(
|
@@ -486,7 +508,7 @@ class CreateExcludeConstraintOp(ops.AddConstraintOp):
|
|
486
508
|
table_name: Union[str, quoted_name],
|
487
509
|
elements: Union[
|
488
510
|
Sequence[Tuple[str, str]],
|
489
|
-
Sequence[Tuple[ColumnClause, str]],
|
511
|
+
Sequence[Tuple[ColumnClause[Any], str]],
|
490
512
|
],
|
491
513
|
where: Optional[Union[BinaryExpression, str]] = None,
|
492
514
|
schema: Optional[str] = None,
|
@@ -638,7 +660,6 @@ def _render_inline_exclude_constraint(
|
|
638
660
|
|
639
661
|
|
640
662
|
def _postgresql_autogenerate_prefix(autogen_context: AutogenContext) -> str:
|
641
|
-
|
642
663
|
imports = autogen_context.imports
|
643
664
|
if imports is not None:
|
644
665
|
imports.add("from sqlalchemy.dialects import postgresql")
|
@@ -706,7 +727,9 @@ def _exclude_constraint(
|
|
706
727
|
|
707
728
|
|
708
729
|
def _render_potential_column(
|
709
|
-
value: Union[
|
730
|
+
value: Union[
|
731
|
+
ColumnClause[Any], Column[Any], TextClause, FunctionElement[Any]
|
732
|
+
],
|
710
733
|
autogen_context: AutogenContext,
|
711
734
|
) -> str:
|
712
735
|
if isinstance(value, ColumnClause):
|
alembic/ddl/sqlite.py
CHANGED
@@ -95,12 +95,11 @@ class SQLiteImpl(DefaultImpl):
|
|
95
95
|
|
96
96
|
def compare_server_default(
|
97
97
|
self,
|
98
|
-
inspector_column: Column,
|
99
|
-
metadata_column: Column,
|
98
|
+
inspector_column: Column[Any],
|
99
|
+
metadata_column: Column[Any],
|
100
100
|
rendered_metadata_default: Optional[str],
|
101
101
|
rendered_inspector_default: Optional[str],
|
102
102
|
) -> bool:
|
103
|
-
|
104
103
|
if rendered_metadata_default is not None:
|
105
104
|
rendered_metadata_default = re.sub(
|
106
105
|
r"^\((.+)\)$", r"\1", rendered_metadata_default
|
@@ -173,7 +172,7 @@ class SQLiteImpl(DefaultImpl):
|
|
173
172
|
|
174
173
|
def cast_for_batch_migrate(
|
175
174
|
self,
|
176
|
-
existing: Column,
|
175
|
+
existing: Column[Any],
|
177
176
|
existing_transfer: Dict[str, Union[TypeEngine, Cast]],
|
178
177
|
new_type: TypeEngine,
|
179
178
|
) -> None:
|
@@ -193,7 +192,6 @@ class SQLiteImpl(DefaultImpl):
|
|
193
192
|
metadata_unique_constraints,
|
194
193
|
metadata_indexes,
|
195
194
|
):
|
196
|
-
|
197
195
|
self._skip_functional_indexes(metadata_indexes, conn_indexes)
|
198
196
|
|
199
197
|
|
alembic/op.pyi
CHANGED
@@ -45,7 +45,7 @@ _T = TypeVar("_T")
|
|
45
45
|
### end imports ###
|
46
46
|
|
47
47
|
def add_column(
|
48
|
-
table_name: str, column: Column, *, schema: Optional[str] = None
|
48
|
+
table_name: str, column: Column[Any], *, schema: Optional[str] = None
|
49
49
|
) -> None:
|
50
50
|
"""Issue an "add column" instruction using the current
|
51
51
|
migration context.
|
@@ -646,6 +646,7 @@ def create_index(
|
|
646
646
|
*,
|
647
647
|
schema: Optional[str] = None,
|
648
648
|
unique: bool = False,
|
649
|
+
if_not_exists: Optional[bool] = None,
|
649
650
|
**kw: Any,
|
650
651
|
) -> None:
|
651
652
|
r"""Issue a "create index" instruction using the current
|
@@ -675,20 +676,24 @@ def create_index(
|
|
675
676
|
:class:`~sqlalchemy.sql.elements.quoted_name`.
|
676
677
|
:param unique: If True, create a unique index.
|
677
678
|
|
678
|
-
:param quote:
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
679
|
+
:param quote: Force quoting of this column's name on or off,
|
680
|
+
corresponding to ``True`` or ``False``. When left at its default
|
681
|
+
of ``None``, the column identifier will be quoted according to
|
682
|
+
whether the name is case sensitive (identifiers with at least one
|
683
|
+
upper case character are treated as case sensitive), or if it's a
|
684
|
+
reserved word. This flag is only needed to force quoting of a
|
685
|
+
reserved word which is not known by the SQLAlchemy dialect.
|
686
|
+
|
687
|
+
:param if_not_exists: If True, adds IF NOT EXISTS operator when
|
688
|
+
creating the new index.
|
689
|
+
|
690
|
+
.. versionadded:: 1.12.0
|
686
691
|
|
687
692
|
:param \**kw: Additional keyword arguments not mentioned above are
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
693
|
+
dialect specific, and passed in the form
|
694
|
+
``<dialectname>_<argname>``.
|
695
|
+
See the documentation regarding an individual dialect at
|
696
|
+
:ref:`dialect_toplevel` for detail on documented arguments.
|
692
697
|
|
693
698
|
"""
|
694
699
|
|
@@ -933,8 +938,8 @@ def drop_column(
|
|
933
938
|
def drop_constraint(
|
934
939
|
constraint_name: str,
|
935
940
|
table_name: str,
|
936
|
-
*,
|
937
941
|
type_: Optional[str] = None,
|
942
|
+
*,
|
938
943
|
schema: Optional[str] = None,
|
939
944
|
) -> None:
|
940
945
|
r"""Drop a constraint of the given name, typically via DROP CONSTRAINT.
|
@@ -952,9 +957,10 @@ def drop_constraint(
|
|
952
957
|
|
953
958
|
def drop_index(
|
954
959
|
index_name: str,
|
955
|
-
*,
|
956
960
|
table_name: Optional[str] = None,
|
961
|
+
*,
|
957
962
|
schema: Optional[str] = None,
|
963
|
+
if_exists: Optional[bool] = None,
|
958
964
|
**kw: Any,
|
959
965
|
) -> None:
|
960
966
|
r"""Issue a "drop index" instruction using the current
|
@@ -971,11 +977,17 @@ def drop_index(
|
|
971
977
|
quoting of the schema outside of the default behavior, use
|
972
978
|
the SQLAlchemy construct
|
973
979
|
:class:`~sqlalchemy.sql.elements.quoted_name`.
|
980
|
+
|
981
|
+
:param if_exists: If True, adds IF EXISTS operator when
|
982
|
+
dropping the index.
|
983
|
+
|
984
|
+
.. versionadded:: 1.12.0
|
985
|
+
|
974
986
|
:param \**kw: Additional keyword arguments not mentioned above are
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
987
|
+
dialect specific, and passed in the form
|
988
|
+
``<dialectname>_<argname>``.
|
989
|
+
See the documentation regarding an individual dialect at
|
990
|
+
:ref:`dialect_toplevel` for detail on documented arguments.
|
979
991
|
|
980
992
|
"""
|
981
993
|
|
@@ -1228,7 +1240,7 @@ def invoke(operation: MigrateOperation) -> Any:
|
|
1228
1240
|
|
1229
1241
|
def register_operation(
|
1230
1242
|
name: str, sourcename: Optional[str] = None
|
1231
|
-
) -> Callable[
|
1243
|
+
) -> Callable[[_T], _T]:
|
1232
1244
|
"""Register a new operation for this class.
|
1233
1245
|
|
1234
1246
|
This method is normally used to add new operations
|
alembic/operations/base.py
CHANGED
@@ -86,7 +86,7 @@ class AbstractOperations(util.ModuleClsProxy):
|
|
86
86
|
@classmethod
|
87
87
|
def register_operation(
|
88
88
|
cls, name: str, sourcename: Optional[str] = None
|
89
|
-
) -> Callable[
|
89
|
+
) -> Callable[[_T], _T]:
|
90
90
|
"""Register a new operation for this class.
|
91
91
|
|
92
92
|
This method is normally used to add new operations
|
@@ -569,7 +569,7 @@ class Operations(AbstractOperations):
|
|
569
569
|
def add_column(
|
570
570
|
self,
|
571
571
|
table_name: str,
|
572
|
-
column: Column,
|
572
|
+
column: Column[Any],
|
573
573
|
*,
|
574
574
|
schema: Optional[str] = None,
|
575
575
|
) -> None:
|
@@ -1035,6 +1035,7 @@ class Operations(AbstractOperations):
|
|
1035
1035
|
*,
|
1036
1036
|
schema: Optional[str] = None,
|
1037
1037
|
unique: bool = False,
|
1038
|
+
if_not_exists: Optional[bool] = None,
|
1038
1039
|
**kw: Any,
|
1039
1040
|
) -> None:
|
1040
1041
|
r"""Issue a "create index" instruction using the current
|
@@ -1064,20 +1065,24 @@ class Operations(AbstractOperations):
|
|
1064
1065
|
:class:`~sqlalchemy.sql.elements.quoted_name`.
|
1065
1066
|
:param unique: If True, create a unique index.
|
1066
1067
|
|
1067
|
-
:param quote:
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1068
|
+
:param quote: Force quoting of this column's name on or off,
|
1069
|
+
corresponding to ``True`` or ``False``. When left at its default
|
1070
|
+
of ``None``, the column identifier will be quoted according to
|
1071
|
+
whether the name is case sensitive (identifiers with at least one
|
1072
|
+
upper case character are treated as case sensitive), or if it's a
|
1073
|
+
reserved word. This flag is only needed to force quoting of a
|
1074
|
+
reserved word which is not known by the SQLAlchemy dialect.
|
1075
|
+
|
1076
|
+
:param if_not_exists: If True, adds IF NOT EXISTS operator when
|
1077
|
+
creating the new index.
|
1078
|
+
|
1079
|
+
.. versionadded:: 1.12.0
|
1075
1080
|
|
1076
1081
|
:param \**kw: Additional keyword arguments not mentioned above are
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1080
|
-
|
1082
|
+
dialect specific, and passed in the form
|
1083
|
+
``<dialectname>_<argname>``.
|
1084
|
+
See the documentation regarding an individual dialect at
|
1085
|
+
:ref:`dialect_toplevel` for detail on documented arguments.
|
1081
1086
|
|
1082
1087
|
""" # noqa: E501
|
1083
1088
|
...
|
@@ -1335,8 +1340,8 @@ class Operations(AbstractOperations):
|
|
1335
1340
|
self,
|
1336
1341
|
constraint_name: str,
|
1337
1342
|
table_name: str,
|
1338
|
-
*,
|
1339
1343
|
type_: Optional[str] = None,
|
1344
|
+
*,
|
1340
1345
|
schema: Optional[str] = None,
|
1341
1346
|
) -> None:
|
1342
1347
|
r"""Drop a constraint of the given name, typically via DROP CONSTRAINT.
|
@@ -1356,9 +1361,10 @@ class Operations(AbstractOperations):
|
|
1356
1361
|
def drop_index(
|
1357
1362
|
self,
|
1358
1363
|
index_name: str,
|
1359
|
-
*,
|
1360
1364
|
table_name: Optional[str] = None,
|
1365
|
+
*,
|
1361
1366
|
schema: Optional[str] = None,
|
1367
|
+
if_exists: Optional[bool] = None,
|
1362
1368
|
**kw: Any,
|
1363
1369
|
) -> None:
|
1364
1370
|
r"""Issue a "drop index" instruction using the current
|
@@ -1375,11 +1381,17 @@ class Operations(AbstractOperations):
|
|
1375
1381
|
quoting of the schema outside of the default behavior, use
|
1376
1382
|
the SQLAlchemy construct
|
1377
1383
|
:class:`~sqlalchemy.sql.elements.quoted_name`.
|
1384
|
+
|
1385
|
+
:param if_exists: If True, adds IF EXISTS operator when
|
1386
|
+
dropping the index.
|
1387
|
+
|
1388
|
+
.. versionadded:: 1.12.0
|
1389
|
+
|
1378
1390
|
:param \**kw: Additional keyword arguments not mentioned above are
|
1379
|
-
|
1380
|
-
|
1381
|
-
|
1382
|
-
|
1391
|
+
dialect specific, and passed in the form
|
1392
|
+
``<dialectname>_<argname>``.
|
1393
|
+
See the documentation regarding an individual dialect at
|
1394
|
+
:ref:`dialect_toplevel` for detail on documented arguments.
|
1383
1395
|
|
1384
1396
|
""" # noqa: E501
|
1385
1397
|
...
|
@@ -1574,7 +1586,7 @@ class BatchOperations(AbstractOperations):
|
|
1574
1586
|
|
1575
1587
|
def add_column(
|
1576
1588
|
self,
|
1577
|
-
column: Column,
|
1589
|
+
column: Column[Any],
|
1578
1590
|
*,
|
1579
1591
|
insert_before: Optional[str] = None,
|
1580
1592
|
insert_after: Optional[str] = None,
|
@@ -1787,7 +1799,7 @@ class BatchOperations(AbstractOperations):
|
|
1787
1799
|
...
|
1788
1800
|
|
1789
1801
|
def drop_constraint(
|
1790
|
-
self, constraint_name: str,
|
1802
|
+
self, constraint_name: str, type_: Optional[str] = None
|
1791
1803
|
) -> None:
|
1792
1804
|
"""Issue a "drop constraint" instruction using the
|
1793
1805
|
current batch migration context.
|
alembic/operations/batch.py
CHANGED
@@ -185,11 +185,11 @@ class BatchOperationsImpl:
|
|
185
185
|
def rename_table(self, *arg, **kw):
|
186
186
|
self.batch.append(("rename_table", arg, kw))
|
187
187
|
|
188
|
-
def create_index(self, idx: Index) -> None:
|
189
|
-
self.batch.append(("create_index", (idx,),
|
188
|
+
def create_index(self, idx: Index, **kw: Any) -> None:
|
189
|
+
self.batch.append(("create_index", (idx,), kw))
|
190
190
|
|
191
|
-
def drop_index(self, idx: Index) -> None:
|
192
|
-
self.batch.append(("drop_index", (idx,),
|
191
|
+
def drop_index(self, idx: Index, **kw: Any) -> None:
|
192
|
+
self.batch.append(("drop_index", (idx,), kw))
|
193
193
|
|
194
194
|
def create_table_comment(self, table):
|
195
195
|
self.batch.append(("create_table_comment", (table,), {}))
|
@@ -243,7 +243,7 @@ class ApplyBatchImpl:
|
|
243
243
|
|
244
244
|
def _grab_table_elements(self) -> None:
|
245
245
|
schema = self.table.schema
|
246
|
-
self.columns: Dict[str, Column] = OrderedDict()
|
246
|
+
self.columns: Dict[str, Column[Any]] = OrderedDict()
|
247
247
|
for c in self.table.c:
|
248
248
|
c_copy = _copy(c, schema=schema)
|
249
249
|
c_copy.unique = c_copy.index = False
|
@@ -337,7 +337,6 @@ class ApplyBatchImpl:
|
|
337
337
|
for const in (
|
338
338
|
list(self.named_constraints.values()) + self.unnamed_constraints
|
339
339
|
):
|
340
|
-
|
341
340
|
const_columns = {c.key for c in _columns_for_constraint(const)}
|
342
341
|
|
343
342
|
if not const_columns.issubset(self.column_transfers):
|
@@ -607,7 +606,7 @@ class ApplyBatchImpl:
|
|
607
606
|
def add_column(
|
608
607
|
self,
|
609
608
|
table_name: str,
|
610
|
-
column: Column,
|
609
|
+
column: Column[Any],
|
611
610
|
insert_before: Optional[str] = None,
|
612
611
|
insert_after: Optional[str] = None,
|
613
612
|
**kw,
|
@@ -621,7 +620,10 @@ class ApplyBatchImpl:
|
|
621
620
|
self.column_transfers[column.name] = {}
|
622
621
|
|
623
622
|
def drop_column(
|
624
|
-
self,
|
623
|
+
self,
|
624
|
+
table_name: str,
|
625
|
+
column: Union[ColumnClause[Any], Column[Any]],
|
626
|
+
**kw,
|
625
627
|
) -> None:
|
626
628
|
if column.name in self.table.primary_key.columns:
|
627
629
|
_remove_column_from_collection(
|