]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
Removed of old deprecated code:
authorCaselIT <cfederico87@gmail.com>
Tue, 27 Oct 2020 20:55:48 +0000 (21:55 +0100)
committerCaselIT <cfederico87@gmail.com>
Tue, 27 Oct 2020 20:55:48 +0000 (21:55 +0100)
  * ``--head_only`` option to the ``alembic current`` command
  * legacy argument names in operations, deprecated since version 0.8

Change-Id: Ib6e265e3c2820971d446a1568de16e4a6efb18eb

alembic/command.py
alembic/config.py
alembic/operations/ops.py
docs/build/unreleased/clean_up.rst [new file with mode: 0644]
tests/test_mssql.py
tests/test_op.py
tests/test_oracle.py

index c925b18bcd4ae00f926b1cb524e6bcdbc1fbcfc8..51384949dd0cca604c7b1327c1724159c0325847 100644 (file)
@@ -484,22 +484,17 @@ def branches(config, verbose=False):
             )
 
 
-def current(config, verbose=False, head_only=False):
+def current(config, verbose=False):
     """Display the current revision for a database.
 
     :param config: a :class:`.Config` instance.
 
     :param verbose: output in verbose mode.
 
-    :param head_only: deprecated; use ``verbose`` for additional output.
-
     """
 
     script = ScriptDirectory.from_config(config)
 
-    if head_only:
-        util.warn("--head-only is deprecated", stacklevel=3)
-
     def display_version(rev, context):
         if verbose:
             config.print_stdout(
index f9f94dbc8b578d05baab31aa74fa7bc59958239a..b05b22d77ac3ddfdc1e71d5b59caa2ba3280c0f1 100644 (file)
@@ -399,14 +399,6 @@ class CommandLine(object):
                         "of database to model.",
                     ),
                 ),
-                "head_only": (
-                    "--head-only",
-                    dict(
-                        action="store_true",
-                        help="Deprecated.  Use --verbose for "
-                        "additional output",
-                    ),
-                ),
                 "rev_range": (
                     "-r",
                     "--rev-range",
index 9160bc154fe49257de9f7dcc3787e62456a90061..96c44906a741c19c43a94c57febf352e16be867b 100644 (file)
@@ -130,7 +130,6 @@ class DropConstraintOp(MigrateOperation):
             )
 
     @classmethod
-    @util._with_legacy_names([("type", "type_"), ("name", "constraint_name")])
     def drop_constraint(
         cls, operations, constraint_name, table_name, type_=None, schema=None
     ):
@@ -152,6 +151,7 @@ class DropConstraintOp(MigrateOperation):
            have been changed:
 
            * name -> constraint_name
+           * type -> type_
 
         """
 
@@ -174,6 +174,7 @@ class DropConstraintOp(MigrateOperation):
            have been changed:
 
            * name -> constraint_name
+           * type -> type_
 
         """
         op = cls(
@@ -236,9 +237,6 @@ class CreatePrimaryKeyOp(AddConstraintOp):
         )
 
     @classmethod
-    @util._with_legacy_names(
-        [("name", "constraint_name"), ("cols", "columns")]
-    )
     def create_primary_key(
         cls, operations, constraint_name, table_name, columns, schema=None
     ):
@@ -371,13 +369,6 @@ class CreateUniqueConstraintOp(AddConstraintOp):
         )
 
     @classmethod
-    @util._with_legacy_names(
-        [
-            ("name", "constraint_name"),
-            ("source", "table_name"),
-            ("local_cols", "columns"),
-        ]
-    )
     def create_unique_constraint(
         cls,
         operations,
@@ -439,7 +430,6 @@ class CreateUniqueConstraintOp(AddConstraintOp):
         return operations.invoke(op)
 
     @classmethod
-    @util._with_legacy_names([("name", "constraint_name")])
     def batch_create_unique_constraint(
         cls, operations, constraint_name, columns, **kw
     ):
@@ -549,13 +539,6 @@ class CreateForeignKeyOp(AddConstraintOp):
         )
 
     @classmethod
-    @util._with_legacy_names(
-        [
-            ("name", "constraint_name"),
-            ("source", "source_table"),
-            ("referent", "referent_table"),
-        ]
-    )
     def create_foreign_key(
         cls,
         operations,
@@ -643,9 +626,6 @@ class CreateForeignKeyOp(AddConstraintOp):
         return operations.invoke(op)
 
     @classmethod
-    @util._with_legacy_names(
-        [("name", "constraint_name"), ("referent", "referent_table")]
-    )
     def batch_create_foreign_key(
         cls,
         operations,
@@ -756,9 +736,6 @@ class CreateCheckConstraintOp(AddConstraintOp):
         )
 
     @classmethod
-    @util._with_legacy_names(
-        [("name", "constraint_name"), ("source", "table_name")]
-    )
     def create_check_constraint(
         cls,
         operations,
@@ -821,7 +798,6 @@ class CreateCheckConstraintOp(AddConstraintOp):
         return operations.invoke(op)
 
     @classmethod
-    @util._with_legacy_names([("name", "constraint_name")])
     def batch_create_check_constraint(
         cls, operations, constraint_name, condition, **kw
     ):
@@ -906,7 +882,6 @@ class CreateIndexOp(MigrateOperation):
         )
 
     @classmethod
-    @util._with_legacy_names([("name", "index_name")])
     def create_index(
         cls,
         operations,
@@ -1050,9 +1025,6 @@ class DropIndexOp(MigrateOperation):
         )
 
     @classmethod
-    @util._with_legacy_names(
-        [("name", "index_name"), ("tablename", "table_name")]
-    )
     def drop_index(
         cls, operations, index_name, table_name=None, schema=None, **kw
     ):
@@ -1087,13 +1059,13 @@ class DropIndexOp(MigrateOperation):
            have been changed:
 
            * name -> index_name
+           * tablename -> table_name
 
         """
         op = cls(index_name, table_name=table_name, schema=schema, **kw)
         return operations.invoke(op)
 
     @classmethod
-    @util._with_legacy_names([("name", "index_name")])
     def batch_drop_index(cls, operations, index_name, **kw):
         """Issue a "drop index" instruction using the
         current batch migration context.
@@ -1157,7 +1129,6 @@ class CreateTableOp(MigrateOperation):
         )
 
     @classmethod
-    @util._with_legacy_names([("name", "table_name")])
     def create_table(cls, operations, table_name, *columns, **kw):
         r"""Issue a "create table" instruction using the current migration
         context.
@@ -1287,7 +1258,6 @@ class DropTableOp(MigrateOperation):
         )
 
     @classmethod
-    @util._with_legacy_names([("name", "table_name")])
     def drop_table(cls, operations, table_name, schema=None, **kw):
         r"""Issue a "drop table" instruction using the current
         migration context.
@@ -1643,7 +1613,6 @@ class AlterColumnOp(AlterTableOp):
         )
 
     @classmethod
-    @util._with_legacy_names([("name", "new_column_name")])
     def alter_column(
         cls,
         operations,
@@ -1754,6 +1723,11 @@ class AlterColumnOp(AlterTableOp):
 
          .. versionadded:: 0.8.8
 
+        .. versionchanged:: 0.8.0 The following positional argument names
+           have been changed:
+
+           * name -> new_column_name
+
         """
 
         alt = cls(
diff --git a/docs/build/unreleased/clean_up.rst b/docs/build/unreleased/clean_up.rst
new file mode 100644 (file)
index 0000000..b91fb8d
--- /dev/null
@@ -0,0 +1,7 @@
+.. change::
+    :tags: changed, commands
+
+    Removed of old deprecated code:
+
+      * ``--head_only`` option to the ``alembic current`` command
+      * legacy argument names in operations, deprecated since version 0.8
index 56aafc4a34eab351bcae631f1d0e0b180ecad120..36b90cb1c8710c1e13ebee73d98d97697f3bba87 100644 (file)
@@ -329,7 +329,7 @@ class OpTest(TestBase):
 
     def test_alter_column_rename_mssql_schema(self):
         context = op_fixture("mssql")
-        op.alter_column("t", "c", name="x", schema="y")
+        op.alter_column("t", "c", new_column_name="x", schema="y")
         context.assert_("EXEC sp_rename 'y.t.c', x, 'COLUMN'")
 
     def test_create_index_mssql_include(self):
index 1406dbdcdc8cca9324572428c74daa1028cd1e29..acd329ef05a2e5a216eb52014991534d482c5128 100644 (file)
@@ -697,62 +697,6 @@ class OpTest(TestBase):
             "ALTER TABLE t1 ADD CONSTRAINT uk_test UNIQUE (foo, bar)"
         )
 
-    def test_add_foreign_key_legacy_kwarg(self):
-        context = op_fixture()
-
-        op.create_foreign_key(
-            name="some_fk",
-            source="some_table",
-            referent="referred_table",
-            local_cols=["a", "b"],
-            remote_cols=["c", "d"],
-            ondelete="CASCADE",
-        )
-        context.assert_(
-            "ALTER TABLE some_table ADD CONSTRAINT some_fk "
-            "FOREIGN KEY(a, b) REFERENCES referred_table (c, d) "
-            "ON DELETE CASCADE"
-        )
-
-    def test_add_unique_constraint_legacy_kwarg(self):
-        context = op_fixture()
-        op.create_unique_constraint(
-            name="uk_test", source="t1", local_cols=["foo", "bar"]
-        )
-        context.assert_(
-            "ALTER TABLE t1 ADD CONSTRAINT uk_test UNIQUE (foo, bar)"
-        )
-
-    def test_drop_constraint_legacy_kwarg(self):
-        context = op_fixture()
-        op.drop_constraint(
-            name="pk_name", table_name="sometable", type_="primary"
-        )
-        context.assert_("ALTER TABLE sometable DROP CONSTRAINT pk_name")
-
-    def test_create_pk_legacy_kwarg(self):
-        context = op_fixture()
-        op.create_primary_key(
-            name=None,
-            table_name="sometable",
-            cols=["router_id", "l3_agent_id"],
-        )
-        context.assert_(
-            "ALTER TABLE sometable ADD PRIMARY KEY (router_id, l3_agent_id)"
-        )
-
-    def test_legacy_kwarg_catches_arg_missing(self):
-        op_fixture()
-
-        assert_raises_message(
-            TypeError,
-            "missing required positional argument: columns",
-            op.create_primary_key,
-            name=None,
-            table_name="sometable",
-            wrong_cols=["router_id", "l3_agent_id"],
-        )
-
     def test_add_unique_constraint_schema(self):
         context = op_fixture()
         op.create_unique_constraint(
@@ -934,25 +878,17 @@ class OpTest(TestBase):
         )
 
     def test_naming_changes(self):
-        context = op_fixture()
-        op.alter_column("t", "c", name="x")
-        context.assert_("ALTER TABLE t RENAME c TO x")
-
         context = op_fixture()
         op.alter_column("t", "c", new_column_name="x")
         context.assert_("ALTER TABLE t RENAME c TO x")
 
-        context = op_fixture("mysql")
-        op.drop_constraint("f1", "t1", type="foreignkey")
-        context.assert_("ALTER TABLE t1 DROP FOREIGN KEY f1")
-
         context = op_fixture("mysql")
         op.drop_constraint("f1", "t1", type_="foreignkey")
         context.assert_("ALTER TABLE t1 DROP FOREIGN KEY f1")
 
     def test_naming_changes_drop_idx(self):
         context = op_fixture("mssql")
-        op.drop_index("ik_test", tablename="t1")
+        op.drop_index("ik_test", table_name="t1")
         context.assert_("DROP INDEX ik_test ON t1")
 
     @config.requirements.comments
index 784574500563f5b34ed72c94e39cf46e43fc2943..f7061903a264680f9b39d3a390c04ca8597fdfc7 100644 (file)
@@ -92,7 +92,7 @@ class OpTest(TestBase):
 
     def test_alter_column_rename_oracle(self):
         context = op_fixture("oracle")
-        op.alter_column("t", "c", name="x")
+        op.alter_column("t", "c", new_column_name="x")
         context.assert_("ALTER TABLE t RENAME COLUMN c TO x")
 
     def test_alter_column_new_type(self):
@@ -196,7 +196,7 @@ class OpTest(TestBase):
         op.alter_column(
             "t",
             "c",
-            name="c2",
+            new_column_name="c2",
             nullable=True,
             type_=Integer,
             server_default="5",