From: CaselIT Date: Tue, 27 Oct 2020 20:55:48 +0000 (+0100) Subject: Removed of old deprecated code: X-Git-Tag: rel_1_5_0~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ac3c03bfc1dfee16cf0e7d2b02fcd9ba42e3fc32;p=thirdparty%2Fsqlalchemy%2Falembic.git Removed of old deprecated code: * ``--head_only`` option to the ``alembic current`` command * legacy argument names in operations, deprecated since version 0.8 Change-Id: Ib6e265e3c2820971d446a1568de16e4a6efb18eb --- diff --git a/alembic/command.py b/alembic/command.py index c925b18b..51384949 100644 --- a/alembic/command.py +++ b/alembic/command.py @@ -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( diff --git a/alembic/config.py b/alembic/config.py index f9f94dbc..b05b22d7 100644 --- a/alembic/config.py +++ b/alembic/config.py @@ -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", diff --git a/alembic/operations/ops.py b/alembic/operations/ops.py index 9160bc15..96c44906 100644 --- a/alembic/operations/ops.py +++ b/alembic/operations/ops.py @@ -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 index 00000000..b91fb8de --- /dev/null +++ b/docs/build/unreleased/clean_up.rst @@ -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 diff --git a/tests/test_mssql.py b/tests/test_mssql.py index 56aafc4a..36b90cb1 100644 --- a/tests/test_mssql.py +++ b/tests/test_mssql.py @@ -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): diff --git a/tests/test_op.py b/tests/test_op.py index 1406dbdc..acd329ef 100644 --- a/tests/test_op.py +++ b/tests/test_op.py @@ -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 diff --git a/tests/test_oracle.py b/tests/test_oracle.py index 78457450..f7061903 100644 --- a/tests/test_oracle.py +++ b/tests/test_oracle.py @@ -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",