log.info("Detected added column '%s.%s'", name, cname)
for cname in set(conn_col_names).difference(metadata_col_names):
- rem_col = sa_schema.Column(
- cname,
- conn_table.c[cname].type,
- nullable=conn_table.c[cname].nullable,
- server_default=conn_table.c[cname].server_default
- )
- if _run_filters(rem_col, cname,
+ if _run_filters(conn_table.c[cname], cname,
"column", True, None, object_filters):
diffs.append(
- ("remove_column", schema, tname, rem_col)
+ ("remove_column", schema, tname, conn_table.c[cname])
)
log.info("Detected removed column '%s.%s'", name, cname)
.. changelog::
:version: 0.6.5
+ .. change::
+ :tags: bug, autogenerate
+ :tickets: 200
+
+ Fixed bug where the ``include_object()`` filter would not receive
+ the original :class:`.Column` object when evaluating a database-only
+ column to be dropped; the object would not include the parent
+ :class:`.Table` nor other aspects of the column that are important
+ for generating the "downgrade" case where the column is recreated.
+
.. change::
:tags: bug, environment
:tickets: 195
assert obj.metadata is not self.m2
else:
assert obj.metadata is self.m2
- return name in ("address", "order")
+ return name in ("address", "order", "user")
elif type_ == "column":
if reflected:
assert obj.table.metadata is not self.m2
else:
return True
-
context = MigrationContext.configure(
connection=self.bind.connect(),
opts={
)
template_args = {}
autogenerate._produce_migration_diffs(context, template_args, set())
+
template_args['upgrades'] = template_args['upgrades'].replace("u'", "'")
template_args['downgrades'] = template_args['downgrades'].\
replace("u'", "'")
+ assert "op.create_table('item'" not in template_args['upgrades']
+ assert "op.create_table('item'" not in template_args['downgrades']
- assert "alter_column('user'" not in template_args['upgrades']
- assert "alter_column('user'" not in template_args['downgrades']
+ assert "alter_column('user'" in template_args['upgrades']
+ assert "alter_column('user'" in template_args['downgrades']
assert "'street'" not in template_args['upgrades']
assert "'street'" not in template_args['downgrades']
assert "alter_column('order'" in template_args['upgrades']
server_default=None,
existing_nullable=True,
schema='%(schema)s')
- op.add_column('user', sa.Column('pw', sa.VARCHAR(length=50), nullable=True), schema='%(schema)s')
+ op.add_column('user', sa.Column('pw', sa.VARCHAR(length=50), autoincrement=False, nullable=True), schema='%(schema)s')
op.alter_column('order', 'amount',
existing_type=sa.Numeric(precision=10, scale=2),
type_=sa.NUMERIC(precision=8, scale=2),