)
-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(
"of database to model.",
),
),
- "head_only": (
- "--head-only",
- dict(
- action="store_true",
- help="Deprecated. Use --verbose for "
- "additional output",
- ),
- ),
"rev_range": (
"-r",
"--rev-range",
)
@classmethod
- @util._with_legacy_names([("type", "type_"), ("name", "constraint_name")])
def drop_constraint(
cls, operations, constraint_name, table_name, type_=None, schema=None
):
have been changed:
* name -> constraint_name
+ * type -> type_
"""
have been changed:
* name -> constraint_name
+ * type -> type_
"""
op = cls(
)
@classmethod
- @util._with_legacy_names(
- [("name", "constraint_name"), ("cols", "columns")]
- )
def create_primary_key(
cls, operations, constraint_name, table_name, columns, schema=None
):
)
@classmethod
- @util._with_legacy_names(
- [
- ("name", "constraint_name"),
- ("source", "table_name"),
- ("local_cols", "columns"),
- ]
- )
def create_unique_constraint(
cls,
operations,
return operations.invoke(op)
@classmethod
- @util._with_legacy_names([("name", "constraint_name")])
def batch_create_unique_constraint(
cls, operations, constraint_name, columns, **kw
):
)
@classmethod
- @util._with_legacy_names(
- [
- ("name", "constraint_name"),
- ("source", "source_table"),
- ("referent", "referent_table"),
- ]
- )
def create_foreign_key(
cls,
operations,
return operations.invoke(op)
@classmethod
- @util._with_legacy_names(
- [("name", "constraint_name"), ("referent", "referent_table")]
- )
def batch_create_foreign_key(
cls,
operations,
)
@classmethod
- @util._with_legacy_names(
- [("name", "constraint_name"), ("source", "table_name")]
- )
def create_check_constraint(
cls,
operations,
return operations.invoke(op)
@classmethod
- @util._with_legacy_names([("name", "constraint_name")])
def batch_create_check_constraint(
cls, operations, constraint_name, condition, **kw
):
)
@classmethod
- @util._with_legacy_names([("name", "index_name")])
def create_index(
cls,
operations,
)
@classmethod
- @util._with_legacy_names(
- [("name", "index_name"), ("tablename", "table_name")]
- )
def drop_index(
cls, operations, index_name, table_name=None, schema=None, **kw
):
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.
)
@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.
)
@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.
)
@classmethod
- @util._with_legacy_names([("name", "new_column_name")])
def alter_column(
cls,
operations,
.. versionadded:: 0.8.8
+ .. versionchanged:: 0.8.0 The following positional argument names
+ have been changed:
+
+ * name -> new_column_name
+
"""
alt = cls(
--- /dev/null
+.. 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
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):
"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(
)
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
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):
op.alter_column(
"t",
"c",
- name="c2",
+ new_column_name="c2",
nullable=True,
type_=Integer,
server_default="5",