def drop_constraint(
constraint_name: str,
table_name: str,
- *,
type_: Optional[str] = None,
+ *,
schema: Optional[str] = None,
) -> None:
r"""Drop a constraint of the given name, typically via DROP CONSTRAINT.
def drop_index(
index_name: str,
- *,
table_name: Optional[str] = None,
+ *,
schema: Optional[str] = None,
**kw: Any,
) -> None:
self,
constraint_name: str,
table_name: str,
- *,
type_: Optional[str] = None,
+ *,
schema: Optional[str] = None,
) -> None:
r"""Drop a constraint of the given name, typically via DROP CONSTRAINT.
def drop_index(
self,
index_name: str,
- *,
table_name: Optional[str] = None,
+ *,
schema: Optional[str] = None,
**kw: Any,
) -> None:
...
def drop_constraint(
- self, constraint_name: str, *, type_: Optional[str] = None
+ self, constraint_name: str, type_: Optional[str] = None
) -> None:
"""Issue a "drop constraint" instruction using the
current batch migration context.
self,
constraint_name: Optional[sqla_compat._ConstraintNameDefined],
table_name: str,
- *,
type_: Optional[str] = None,
+ *,
schema: Optional[str] = None,
_reverse: Optional[AddConstraintOp] = None,
) -> None:
operations: Operations,
constraint_name: str,
table_name: str,
- *,
type_: Optional[str] = None,
+ *,
schema: Optional[str] = None,
) -> None:
r"""Drop a constraint of the given name, typically via DROP CONSTRAINT.
cls,
operations: BatchOperations,
constraint_name: str,
- *,
type_: Optional[str] = None,
) -> None:
"""Issue a "drop constraint" instruction using the
def __init__(
self,
index_name: Union[quoted_name, str, conv],
- *,
table_name: Optional[str] = None,
+ *,
schema: Optional[str] = None,
_reverse: Optional[CreateIndexOp] = None,
**kw: Any,
cls,
operations: Operations,
index_name: str,
- *,
table_name: Optional[str] = None,
+ *,
schema: Optional[str] = None,
**kw: Any,
) -> None:
the check constraint also::
with self.op.batch_alter_table("some_table") as batch_op:
- batch_op.drop_constraint("ck1", "check")
+ batch_op.drop_constraint("ck1", type_="check")
batch_op.drop_column('q')
.. versionchanged:: 1.7 Named CHECK constraints participate in batch mode
.. versionchanged:: 1.7 Alembic now supports Python 3.6 and newer; support
for Python 2.7 has been dropped.
+.. _versioning_scheme:
+
+Versioning Scheme
+-----------------
+
+Alembic's versioning scheme is based on that of
+`SQLAlchemy's versioning scheme <https://www.sqlalchemy.org/download.html#versions>`_.
+In particular, it should be noted that while Alembic uses a three-number
+versioning scheme, it **does not use SemVer**. In SQLAlchemy and Alembic's
+scheme, **the middle digit is considered to be a "Significant Minor Release",
+which may include removal of previously deprecated APIs with some risk of
+non-backwards compatibility in a very small number of cases**.
+
+This means that version "1.8.0", "1.9.0", "1.10.0", "1.11.0", etc. are
+**Significant Minor Releases**, which will include new API features and may
+remove or modify existing ones.
+
+Therefore, when `pinning <https://pip.pypa.io/en/stable/topics/repeatable-installs/>`_
+Alembic releases, pin to the "major" and "minor" digits to avoid API changes.
+
+A true "Major" release such as a change to "2.0" would include complete
+redesigns/re-architectures of foundational features; currently no such series
+of changes are planned, although changes such as replacing the entire
+"autogenerate" scheme with a new approach would qualify for that level of
+change.
+
+
+
Community
=========
--- /dev/null
+.. change::
+ :tags: bug, autogenerate, regression
+ :tickets: 1243 1245
+
+ As Alembic 1.11.0 is considered a major release (Alembic does not use
+ semver, nor does its parent project SQLAlchemy; this has been
+ :ref:`clarified <versioning_scheme>` in the documentation), change
+ :ticket:`1130` modified calling signatures for most operations to consider
+ all optional keyword parameters to be keyword-only arguments, to match what
+ was always documented and generated by autogenerate. However, two of these
+ changes were identified as possibly problematic without a more formal
+ deprecation warning being emitted which were the ``table_name`` parameter
+ to :meth:`.Operations.drop_index`, which was generated positionally by
+ autogenerate prior to version 0.6.3 released in 2014, and ``type_`` in
+ :meth:`.Operations.drop_constraint` and
+ :meth:`.BatchOperations.drop_constraint`, which was documented positionally
+ in one example in the batch documentation. These two signatures have been
+ restored to allow those particular parameters to be passed positionally. A
+ future change will include formal deprecation paths (with warnings) for
+ these arguments where they will again become keyword-only in a future
+ "Significant Minor" release.
ck_consts = inspect(self.conn).get_check_constraints("ck_table")
eq_(ck_consts, [])
+ @config.requirements.check_constraint_reflection
+ def test_drop_ck_constraint_legacy_type(self):
+ self._ck_constraint_fixture()
+
+ with self.op.batch_alter_table(
+ "ck_table", recreate="always"
+ ) as batch_op:
+ # matches the docs that were written for this originally
+ batch_op.drop_constraint("ck", "check")
+
+ ck_consts = inspect(self.conn).get_check_constraints("ck_table")
+ eq_(ck_consts, [])
+
@config.requirements.unnamed_constraints
def test_drop_foreign_key(self):
bar = Table(
op.drop_index("my_idx", table_name="my_table")
context.assert_contains("DROP INDEX my_idx ON my_table")
+ def test_drop_index_w_tablename_legacy(self):
+ """#1243"""
+ context = op_fixture("mssql")
+ op.drop_index("my_idx", "my_table")
+ context.assert_contains("DROP INDEX my_idx ON my_table")
+
def test_drop_column_w_default(self):
context = op_fixture("mssql")
op.drop_column("t1", "c1", mssql_drop_default=True)
op.drop_constraint("f1", "t1", type_="foreignkey")
context.assert_("ALTER TABLE t1 DROP FOREIGN KEY f1")
+ def test_drop_fk_legacy(self):
+ """#1245"""
+ context = op_fixture("mysql")
+ op.drop_constraint("f1", "t1", "foreignkey")
+ context.assert_("ALTER TABLE t1 DROP FOREIGN KEY f1")
+
def test_drop_fk_quoted(self):
context = op_fixture("mysql")
op.drop_constraint("MyFk", "MyTable", type_="foreignkey")
op.drop_constraint("foo_bar_bat", "t1")
context.assert_("ALTER TABLE t1 DROP CONSTRAINT foo_bar_bat")
+ def test_drop_constraint_type(self):
+ context = op_fixture()
+ op.drop_constraint("foo_bar_bat", "t1", type_="foreignkey")
+ context.assert_("ALTER TABLE t1 DROP CONSTRAINT foo_bar_bat")
+
+ def test_drop_constraint_legacy_type(self):
+ """#1245"""
+ context = op_fixture()
+ op.drop_constraint("foo_bar_bat", "t1", "foreignkey")
+ context.assert_("ALTER TABLE t1 DROP CONSTRAINT foo_bar_bat")
+
def test_drop_constraint_schema(self):
context = op_fixture()
op.drop_constraint("foo_bar_bat", "t1", schema="foo")
op.drop_index("ik_test")
context.assert_("DROP INDEX ik_test")
+ def test_drop_index_w_tablename(self):
+ context = op_fixture()
+ op.drop_index("ik_test", table_name="the_table")
+ context.assert_("DROP INDEX ik_test")
+
+ def test_drop_index_w_tablename_legacy(self):
+ """#1243"""
+ context = op_fixture()
+ op.drop_index("ik_test", "the_table")
+ context.assert_("DROP INDEX ik_test")
+
def test_drop_index_schema(self):
context = op_fixture()
op.drop_index("ik_test", schema="foo")