def upgrade(migrate_engine): meta = MetaData() meta.bind = migrate_engine dialect = migrate_engine.url.get_dialect().name block_device_mapping = Table('block_device_mapping', meta, autoload=True) instances = Table('instances', meta, autoload=True) uuid_column = Column('instance_uuid', String(36)) uuid_column.create(block_device_mapping) try: block_device_mapping.update().values(instance_uuid=select( [instances.c.uuid], instances.c.id == block_device_mapping.c.instance_id)).execute() except Exception: uuid_column.drop() raise fkeys = list(block_device_mapping.c.instance_id.foreign_keys) if fkeys: try: fkey_name = fkeys[0].constraint.name ForeignKeyConstraint(columns=[block_device_mapping.c.instance_id], refcolumns=[instances.c.id], name=fkey_name).drop() except Exception: LOG.error(_("foreign key constraint couldn't be removed")) raise block_device_mapping.c.instance_id.drop()
def upgrade(migrate_engine): meta.bind = migrate_engine instance_actions = _get_table('instance_actions') instances = _get_table('instances') uuid_column = Column('instance_uuid', String(36), ForeignKey('instances.uuid')) uuid_column = Column('instance_uuid', String(36)) uuid_column.create(instance_actions) try: instance_actions.update().values( instance_uuid=select( [instances.c.uuid], instances.c.id == instance_actions.c.instance_id) ).execute() except Exception: uuid_column.drop() raise try: fkey_name = list(instance_actions.c.instance_id.foreign_keys)[0].constraint.name ForeignKeyConstraint(columns=[instance_actions.c.instance_id], refcolumns=[instances.c.id], name=fkey_name).drop() except Exception: logging.error(_("foreign key constraint couldn't be removed")) raise instance_actions.c.instance_id.drop()
def upgrade(migrate_engine): meta.bind = migrate_engine instance_actions = _get_table('instance_actions') instances = _get_table('instances') uuid_column = Column('instance_uuid', String(36), ForeignKey('instances.uuid')) uuid_column = Column('instance_uuid', String(36)) uuid_column.create(instance_actions) try: instance_actions.update().values( instance_uuid=select( [instances.c.uuid], instances.c.id == instance_actions.c.instance_id) ).execute() except Exception: uuid_column.drop() raise if migrate_engine.name == "mysql": try: migrate_engine.execute("ALTER TABLE instance_actions " \ "DROP FOREIGN KEY instance_actions_ibfk_1;") except Exception: # Don't care, just fail silently. pass instance_actions.c.instance_id.drop()
def upgrade(migrate_engine): meta.bind = migrate_engine dialect = migrate_engine.url.get_dialect().name instance_actions = _get_table("instance_actions") instances = _get_table("instances") uuid_column = Column("instance_uuid", String(36), ForeignKey("instances.uuid")) uuid_column = Column("instance_uuid", String(36)) uuid_column.create(instance_actions) try: instance_actions.update().values( instance_uuid=select([instances.c.uuid], instances.c.id == instance_actions.c.instance_id) ).execute() except Exception: uuid_column.drop() raise if not dialect.startswith("sqlite"): fkeys = list(instance_actions.c.instance_id.foreign_keys) if fkeys: try: fkey_name = fkeys[0].constraint.name ForeignKeyConstraint( columns=[instance_actions.c.instance_id], refcolumns=[instances.c.id], name=fkey_name ).drop() except: logging.error(_("foreign key constraint couldn't be removed")) raise instance_actions.c.instance_id.drop()
def upgrade(migrate_engine): meta = MetaData() meta.bind = migrate_engine volumes = Table('volumes', meta, autoload=True) attach_datetime = Column('attachtime_datetime', DateTime(timezone=False)) attach_datetime.create(volumes) old_attachtime = volumes.c.attach_time try: volumes_list = list(volumes.select().execute()) for v in volumes_list: attach_time = select([volumes.c.attach_time], volumes.c.id == v['id']) volumes.update().\ where(volumes.c.id == v['id']).\ values(attach_datetime=attach_time).execute() except Exception: attach_datetime.drop() raise old_attachtime.alter(name='attach_time_old') attach_datetime.alter(name='attach_time') old_attachtime.drop()
def upgrade(migrate_engine): meta = MetaData() meta.bind = migrate_engine dialect = migrate_engine.url.get_dialect().name instance_actions = Table('instance_actions', meta, autoload=True) instances = Table('instances', meta, autoload=True) uuid_column = Column('instance_uuid', String(36)) uuid_column.create(instance_actions) try: instance_actions.update().values( instance_uuid=select( [instances.c.uuid], instances.c.id == instance_actions.c.instance_id) ).execute() except Exception: uuid_column.drop() raise if not dialect.startswith('sqlite'): fkeys = list(instance_actions.c.instance_id.foreign_keys) if fkeys: try: fkey_name = fkeys[0].constraint.name ForeignKeyConstraint(columns=[instance_actions.c.instance_id], refcolumns=[instances.c.id], name=fkey_name).drop() except Exception: LOG.error(_("foreign key constraint couldn't be removed")) raise instance_actions.c.instance_id.drop()
def upgrade(migrate_engine): meta = MetaData() meta.bind = migrate_engine instance_metadata = Table("instance_metadata", meta, autoload=True) instances = Table("instances", meta, autoload=True) uuid_column = Column("instance_uuid", String(36)) uuid_column.create(instance_metadata) try: instance_metadata.update().values( instance_uuid=select([instances.c.uuid], instances.c.id == instance_metadata.c.instance_id) ).execute() except Exception: uuid_column.drop() raise fkeys = list(instance_metadata.c.instance_id.foreign_keys) if fkeys: try: fkey_name = fkeys[0].constraint.name ForeignKeyConstraint( columns=[instance_metadata.c.instance_id], refcolumns=[instances.c.id], name=fkey_name ).drop() except Exception: LOG.error(_("foreign key constraint couldn't be removed")) raise instance_metadata.c.instance_id.drop()
def upgrade(migrate_engine): meta = MetaData() meta.bind = migrate_engine dialect = migrate_engine.url.get_dialect().name block_device_mapping = Table('block_device_mapping', meta, autoload=True) instances = Table('instances', meta, autoload=True) uuid_column = Column('instance_uuid', String(36)) uuid_column.create(block_device_mapping) try: block_device_mapping.update().values( instance_uuid=select( [instances.c.uuid], instances.c.id == block_device_mapping.c.instance_id) ).execute() except Exception: uuid_column.drop() raise fkeys = list(block_device_mapping.c.instance_id.foreign_keys) if fkeys: try: fkey_name = fkeys[0].constraint.name ForeignKeyConstraint( columns=[block_device_mapping.c.instance_id], refcolumns=[instances.c.id], name=fkey_name).drop() except Exception: LOG.error(_("foreign key constraint couldn't be removed")) raise block_device_mapping.c.instance_id.drop()
def upgrade(migrate_engine): meta = MetaData() meta.bind = migrate_engine virtual_interfaces = Table('virtual_interfaces', meta, autoload=True) instances = Table('instances', meta, autoload=True) uuid_column = Column('instance_uuid', String(36)) uuid_column.create(virtual_interfaces) try: virtual_interfaces.update().values( instance_uuid=select([instances.c.uuid], instances.c.id == virtual_interfaces.c.instance_id)).execute() except Exception: uuid_column.drop() raise fkeys = list(virtual_interfaces.c.instance_id.foreign_keys) if fkeys: try: fkey_name = fkeys[0].constraint.name ForeignKeyConstraint(columns=[virtual_interfaces.c.instance_id], refcolumns=[instances.c.id], name=fkey_name).drop() except Exception: LOG.error(_("foreign key constraint couldn't be removed")) raise virtual_interfaces.c.instance_id.drop() try: ForeignKeyConstraint(columns=[virtual_interfaces.c.instance_uuid], refcolumns=[instances.c.uuid]).create() except Exception: LOG.error(_("foreign key constraint couldn't be created")) raise
def downgrade(migrate_engine): meta = MetaData() meta.bind = migrate_engine instances = Table('instances', meta, autoload=True) volumes = Table('volumes', meta, autoload=True) instance_id_column = Column('instance_id', Integer) instance_id_column.create(volumes) try: volumes.update().values( instance_id=select( [instances.c.id], instances.c.uuid == volumes.c.instance_uuid) ).execute() except Exception: instance_id_column.drop() fkeys = list(volumes.c.instance_id.foreign_keys) if fkeys: try: fk_name = fkeys[0].constraint.name ForeignKeyConstraint( columns=[volumes.c.instance_id], refcolumns=[instances.c.id], name=fk_name).create() except Exception: LOG.error(_("foreign key could not be created")) raise volumes.c.instance_uuid.drop()
def downgrade(migrate_engine): meta = MetaData() meta.bind = migrate_engine volumes = Table('volumes', meta, autoload=True) attach_string = Column('attachtime_string', String(255)) attach_string.create(volumes) old_attachtime = volumes.c.attach_time try: volumes_list = list(volumes.select().execute()) for v in volumes_list: attach_time = select([volumes.c.attach_time], volumes.c.id == v['id']).execute().fetchone()[0] volumes.update().\ where(volumes.c.id == v['id']).\ values(attachtime_string=attach_time).execute() except Exception: attach_string.drop() raise old_attachtime.alter(name='attach_time_old') attach_string.alter(name='attach_time') old_attachtime.drop()
def upgrade(migrate_engine): meta = MetaData() meta.bind = migrate_engine sgia = Table('security_group_instance_association', meta, autoload=True) instances = Table('instances', meta, autoload=True) uuid_column = Column('instance_uuid', String(36)) uuid_column.create(sgia) try: sgia.update().values( instance_uuid=select([instances.c.uuid], instances.c.id == sgia.c.instance_id)).execute() except Exception: uuid_column.drop() raise fkeys = list(sgia.c.instance_id.foreign_keys) if fkeys: try: fkey_name = fkeys[0].constraint.name ForeignKeyConstraint(columns=[sgia.c.instance_id], refcolumns=[instances.c.id], name=fkey_name).drop() except Exception: LOG.error(_("foreign key constraint couldn't be removed")) raise sgia.c.instance_id.drop()
def downgrade(migrate_engine): meta.bind = migrate_engine domains_table = Table('domains', meta, autoload=True) # Drop the multi-column unique index constraint = UniqueConstraint('name', 'deleted', name='unique_domain_name', table=domains_table) constraint.drop() # Revert to single column unique # NOTE(kiall): It appears this does nothing. Miration 17 has been added. # leaving this here for reference. domains_table.c.name.alter(unique=True) # Drop the deleted columns deleted_column = Column('deleted', CHAR(32), nullable=True, default=None) deleted_column.drop(domains_table) deleted_at_column = Column('deleted_at', DateTime, nullable=True, default=None) deleted_at_column.drop(domains_table)
def downgrade(migrate_engine): meta = MetaData() meta.bind = migrate_engine fixed_ips = Table('fixed_ips', meta, autoload=True) instances = Table('instances', meta, autoload=True) id_column = Column('instance_id', Integer, ForeignKey('instances.id')) id_column.create(fixed_ips) fkeys = list(fixed_ips.c.instance_uuid.foreign_keys) if fkeys: try: fkey_name = fkeys[0].constraint.name ForeignKeyConstraint(columns=[fixed_ips.c.instance_uuid], refcolumns=[instances.c.uuid], name=fkey_name).drop() except Exception: LOG.error(_("foreign key constraint couldn't be removed")) raise try: fixed_ips.update().values( instance_id=select([instances.c.id], instances.c.uuid == fixed_ips.c.instance_uuid)).execute() except Exception: id_column.drop() raise fixed_ips.c.instance_uuid.drop() try: ForeignKeyConstraint(columns=[fixed_ips.c.instance_id], refcolumns=[instances.c.id]).create() except Exception: LOG.error(_("foreign key constraint couldn't be created")) raise
def downgrade(migrate_engine): meta.bind = migrate_engine domains_table = Table('domains', meta, autoload=True) parent_domain_id = Column('parent_domain_id', UUID, ForeignKey('domains.id'), default=None, nullable=True) parent_domain_id.drop(domains_table)
def downgrade(migrate_engine): meta.bind = migrate_engine records_table = Table('records', meta, autoload=True) records_table.c.managed.alter(name='managed_resource') managed_plugin_name = Column('managed_resource_name', Unicode(50)) managed_plugin_name.drop(records_table) managed_plugin_type = Column('managed_resource_type', Unicode(50)) managed_plugin_type.drop(records_table)
def downgrade(migrate_engine): meta.bind = migrate_engine instance_actions = _get_table('instance_actions') instances = _get_table('instances') id_column = Column('instance_id', Integer, ForeignKey('instances.id')) id_column.create(instance_actions) try: instance_actions.update().values( instance_id=select([instances.c.id], instances.c.uuid == instance_actions.c.instance_uuid)).execute() except Exception: id_column.drop() raise instance_actions.c.instance_uuid.drop()
def downgrade(migrate_engine): meta.bind = migrate_engine instance_actions = _get_table("instance_actions") instances = _get_table("instances") id_column = Column("instance_id", Integer, ForeignKey("instances.id")) id_column.create(instance_actions) try: instance_actions.update().values( instance_id=select([instances.c.id], instances.c.uuid == instance_actions.c.instance_uuid) ).execute() except Exception: id_column.drop() raise instance_actions.c.instance_uuid.drop()
def downgrade(migrate_engine): meta = MetaData() meta.bind = migrate_engine consoles = Table('consoles', meta, autoload=True) instances = Table('instances', meta, autoload=True) id_column = Column('instance_id', Integer, ForeignKey('instances.id')) id_column.create(consoles) try: consoles.update().values( instance_id=select([instances.c.id], instances.c.uuid == consoles.c.instance_uuid)).execute() except Exception: id_column.drop() raise consoles.c.instance_uuid.drop()
def downgrade(migrate_engine): meta = MetaData() meta.bind = migrate_engine block_device_mapping = Table('block_device_mapping', meta, autoload=True) instances = Table('instances', meta, autoload=True) id_column = Column('instance_id', Integer, ForeignKey('instances.id')) id_column.create(block_device_mapping) try: block_device_mapping.update().values(instance_id=select( [instances.c.id], instances.c.uuid == block_device_mapping.c.instance_uuid)).execute() except Exception: id_column.drop() raise block_device_mapping.c.instance_uuid.drop()
def downgrade(migrate_engine): meta = MetaData() meta.bind = migrate_engine instance_metadata = Table("instance_metadata", meta, autoload=True) instances = Table("instances", meta, autoload=True) id_column = Column("instance_id", Integer, ForeignKey("instances.id")) id_column.create(instance_metadata) try: instance_metadata.update().values( instance_id=select([instances.c.id], instances.c.uuid == instance_metadata.c.instance_uuid) ).execute() except Exception: id_column.drop() raise instance_metadata.c.instance_uuid.drop()
def downgrade(migrate_engine): meta = MetaData() meta.bind = migrate_engine sgia = Table('security_group_instance_association', meta, autoload=True) instances = Table('instances', meta, autoload=True) id_column = Column('instance_id', Integer, ForeignKey('instances.id')) id_column.create(sgia) try: sgia.update().values( instance_id=select([instances.c.id], instances.c.uuid == sgia.c.instance_uuid)).execute() except Exception: id_column.drop() raise sgia.c.instance_uuid.drop()
def _update_col(column, table, data_type, columns): """ Update the column based on the database operation. :param column: Base column. :type column: BaseColumn :returns: SQLAlchemy column object. :rtype: Column :param columns: Existing column names in the database for the given table. :type columns: list """ alchemy_column = Column(column.name, data_type, **_base_col_attrs(column)) idx_name = None if column.index: idx_name = u'idx_{0}_{1}'.format(column.entity.name, column.name) unique_name = None if column.unique: unique_name = u'unq_{0}_{1}'.format(column.entity.name, column.name) if column.action == DbItem.CREATE: #Ensure the column does not exist otherwise an exception will be thrown if not column.name in columns: alchemy_column.create(table=table, index_name=idx_name, unique_name=unique_name) elif column.action == DbItem.ALTER: #Ensure the column exists before altering if column.name in columns: col_attrs = _base_col_attrs(column) col_attrs['table'] = table alchemy_column.alter(**col_attrs) elif column.action == DbItem.DROP: #Ensure the column exists before dropping if column.name in columns: _clear_ref_in_entity_relations(column) alchemy_column.drop(table=table) #Ensure column is added to the table if alchemy_column.table is None: alchemy_column._set_parent(table) return alchemy_column
def downgrade(migrate_engine): meta = MetaData() meta.bind = migrate_engine block_device_mapping = Table('block_device_mapping', meta, autoload=True) instances = Table('instances', meta, autoload=True) id_column = Column('instance_id', Integer, ForeignKey('instances.id')) id_column.create(block_device_mapping) try: block_device_mapping.update().values( instance_id=select( [instances.c.id], instances.c.uuid == block_device_mapping.c.instance_uuid) ).execute() except Exception: id_column.drop() raise block_device_mapping.c.instance_uuid.drop()
def downgrade(migrate_engine): meta = MetaData() meta.bind = migrate_engine sgia = Table('security_group_instance_association', meta, autoload=True) instances = Table('instances', meta, autoload=True) id_column = Column('instance_id', Integer, ForeignKey('instances.id')) id_column.create(sgia) try: sgia.update().values( instance_id=select( [instances.c.id], instances.c.uuid == sgia.c.instance_uuid) ).execute() except Exception: id_column.drop() raise sgia.c.instance_uuid.drop()
def downgrade(migrate_engine): meta = MetaData() meta.bind = migrate_engine instance_types = Table('instance_types', meta, autoload=True) integer_column = Column('flavorid_int', Integer()) integer_column.create(instance_types) try: # NOTE(bcwaldon): This catches a bug with python-migrate # failing to add the unique constraint try: migrate.UniqueConstraint(integer_column).create() except migrate.changeset.NotSupportedError: LOG.info("Failed to add unique constraint on flavorid") pass string_column = instance_types.c.flavorid instance_types_rows = list(instance_types.select().execute()) for instance_type in instance_types_rows: flavorid_str = instance_type.flavorid try: flavorid_int = int(instance_type.flavorid) except ValueError: msg = _('Could not cast flavorid to integer: %s. ' 'Set flavorid to an integer-like string to downgrade.') LOG.error(msg % instance_type.flavorid) raise instance_types.update()\ .where(string_column == flavorid_str)\ .values(flavorid_int=flavorid_int)\ .execute() except Exception: integer_column.drop() raise string_column.alter(name='flavorid_str') integer_column.alter(name='flavorid') string_column.drop()
def downgrade(migrate_engine): meta = MetaData() meta.bind = migrate_engine consoles = Table('consoles', meta, autoload=True) instances = Table('instances', meta, autoload=True) id_column = Column('instance_id', Integer, ForeignKey('instances.id')) id_column.create(consoles) try: consoles.update().values( instance_id=select( [instances.c.id], instances.c.uuid == consoles.c.instance_uuid) ).execute() except Exception: id_column.drop() raise consoles.c.instance_uuid.drop()
def upgrade(migrate_engine): meta.bind = migrate_engine instance_actions = _get_table('instance_actions') instances = _get_table('instances') uuid_column = Column('instance_uuid', String(36), ForeignKey('instances.uuid')) uuid_column = Column('instance_uuid', String(36)) uuid_column.create(instance_actions) try: instance_actions.update().values( instance_uuid=select( [instances.c.uuid], instances.c.id == instance_actions.c.instance_id) ).execute() except Exception: uuid_column.drop() raise instance_actions.c.instance_id.drop()
def downgrade(migrate_engine): meta.bind = migrate_engine domains_table = Table("domains", meta, autoload=True) # Drop the multi-column unique index constraint = UniqueConstraint("name", "deleted", name="unique_domain_name", table=domains_table) constraint.drop() # Revert to single column unique # NOTE(kiall): It appears this does nothing. Miration 17 has been added. # leaving this here for reference. domains_table.c.name.alter(unique=True) # Drop the deleted columns deleted_column = Column("deleted", CHAR(32), nullable=True, default=None) deleted_column.drop(domains_table) deleted_at_column = Column("deleted_at", DateTime, nullable=True, default=None) deleted_at_column.drop(domains_table)
def upgrade(migrate_engine): meta = MetaData() meta.bind = migrate_engine instance_types = Table('instance_types', meta, autoload=True) string_column = Column('flavorid_str', String(255)) string_column.create(instance_types) try: # NOTE(bcwaldon): This catches a bug with python-migrate # failing to add the unique constraint try: migrate.UniqueConstraint(string_column).create() except migrate.changeset.NotSupportedError: LOG.error("Failed to add unique constraint on flavorid") pass # NOTE(bcwaldon): this is a hack to preserve uniqueness constraint # on existing 'name' column try: migrate.UniqueConstraint(instance_types.c.name).create() except Exception: pass integer_column = instance_types.c.flavorid instance_type_rows = list(instance_types.select().execute()) for instance_type in instance_type_rows: flavorid_int = instance_type.flavorid instance_types.update()\ .where(integer_column == flavorid_int)\ .values(flavorid_str=str(flavorid_int))\ .execute() except Exception: string_column.drop() raise integer_column.alter(name='flavorid_int') string_column.alter(name='flavorid') integer_column.drop()
def upgrade(migrate_engine): meta = MetaData() meta.bind = migrate_engine virtual_interfaces = Table('virtual_interfaces', meta, autoload=True) instances = Table('instances', meta, autoload=True) uuid_column = Column('instance_uuid', String(36)) uuid_column.create(virtual_interfaces) try: virtual_interfaces.update().values( instance_uuid=select( [instances.c.uuid], instances.c.id == virtual_interfaces.c.instance_id) ).execute() except Exception: uuid_column.drop() raise fkeys = list(virtual_interfaces.c.instance_id.foreign_keys) if fkeys: try: fkey_name = fkeys[0].constraint.name ForeignKeyConstraint( columns=[virtual_interfaces.c.instance_id], refcolumns=[instances.c.id], name=fkey_name).drop() except Exception: LOG.error(_("foreign key constraint couldn't be removed")) raise virtual_interfaces.c.instance_id.drop() try: ForeignKeyConstraint( columns=[virtual_interfaces.c.instance_uuid], refcolumns=[instances.c.uuid]).create() except Exception: LOG.error(_("foreign key constraint couldn't be created")) raise
def downgrade(migrate_engine): meta = MetaData() meta.bind = migrate_engine fixed_ips = Table('fixed_ips', meta, autoload=True) instances = Table('instances', meta, autoload=True) id_column = Column('instance_id', Integer, ForeignKey('instances.id')) id_column.create(fixed_ips) fkeys = list(fixed_ips.c.instance_uuid.foreign_keys) if fkeys: try: fkey_name = fkeys[0].constraint.name ForeignKeyConstraint( columns=[fixed_ips.c.instance_uuid], refcolumns=[instances.c.uuid], name=fkey_name).drop() except Exception: LOG.error(_("foreign key constraint couldn't be removed")) raise try: fixed_ips.update().values( instance_id=select( [instances.c.id], instances.c.uuid == fixed_ips.c.instance_uuid) ).execute() except Exception: id_column.drop() raise fixed_ips.c.instance_uuid.drop() try: ForeignKeyConstraint( columns=[fixed_ips.c.instance_id], refcolumns=[instances.c.id]).create() except Exception: LOG.error(_("foreign key constraint couldn't be created")) raise
def downgrade(migrate_engine): meta.bind = migrate_engine tsigkeys_table = Table('tsigkeys', meta, autoload=True) domains_table = Table('domains', meta, autoload=True) records_table = Table('records', meta, autoload=True) tsigkeys_moniker_id = Column('moniker_id', UUID()) tsigkeys_moniker_id.drop(tsigkeys_table) domains_moniker_id = Column('moniker_id', UUID()) domains_moniker_id.drop(domains_table) records_moniker_id = Column('moniker_id', UUID()) records_moniker_id.drop(records_table)
def downgrade(migrate_engine): meta.bind = migrate_engine records_table = Table('records', meta, autoload=True) managed_resource_id = Column('managed_resource_id', UUID(), default=None, nullable=True) managed_resource_id.drop(records_table) managed_resource_type = Column('managed_resource_type', Unicode(50), default=None, nullable=True) managed_resource_type.drop(records_table) managed_resource = Column('managed_resource', Boolean(), default=False) managed_resource.drop(records_table)
def downgrade(migrate_engine): meta.bind = migrate_engine records_table = Table('records', meta, autoload=True) record_managed_tenant_id = Column( 'managed_tenant_id', Unicode(36), default=None, nullable=True) record_managed_tenant_id.drop(records_table) record_managed_resource_region = Column( 'managed_resource_region', Unicode(100), default=None, nullable=True) record_managed_resource_region.drop(records_table) record_extra = Column( 'managed_extra', Unicode(100), default=None, nullable=True) record_extra.drop(records_table)
def downgrade(migrate_engine): meta.bind = migrate_engine records_table = Table('records', meta, autoload=True) record_managed_tenant_id = Column('managed_tenant_id', Unicode(36), default=None, nullable=True) record_managed_tenant_id.drop(records_table) record_managed_resource_region = Column('managed_resource_region', Unicode(100), default=None, nullable=True) record_managed_resource_region.drop(records_table) record_extra = Column('managed_extra', Unicode(100), default=None, nullable=True) record_extra.drop(records_table)
def downgrade(migrate_engine): # Operations to reverse the above upgrade go here. meta = MetaData(bind=migrate_engine) training_results = Table('training_results', meta, autoload=True) column = Column('validation_error', Float(precision=32), default=0) column.drop(training_results)
if Job_table is not None: try: i = Index( 'ix_job_state', Job_table.c.state ) i.drop() except Exception, e: log.debug( "Dropping index from job.state column failed: %s" % ( str( e ) ) ) # Drop 1 column from the stored_workflow table - changeset 2328 try: StoredWorkflow_table = Table( "stored_workflow", metadata, autoload=True ) except NoSuchTableError: StoredWorkflow_table = None log.debug( "Failed loading table stored_workflow" ) if StoredWorkflow_table is not None: try: col = StoredWorkflow_table.c.importable col.drop() except Exception, e: log.debug( "Dropping column 'importable' from stored_workflow table failed: %s" % ( str( e ) ) ) # Drop 1 column from the metadata_file table try: MetadataFile_table = Table( "metadata_file", metadata, autoload=True ) except NoSuchTableError: MetadataFile_table = None log.debug( "Failed loading table metadata_file" ) if MetadataFile_table is not None: try: col = MetadataFile_table.c.lda_id col.drop() except Exception, e: log.debug( "Dropping column 'lda_id' from metadata_file table failed: %s" % ( str( e ) ) ) # Drop 1 column from the history_dataset_association table
def downgrade(migrate_engine): meta.bind = migrate_engine user = Table("user", meta, autoload=True) col = Column("favorited", DateTime) col.drop(user)
def downgrade(migrate_engine): # Operations to reverse the above upgrade go here. meta = MetaData(bind=migrate_engine) training_results = Table('training_results', meta, autoload=True) column = Column('extra_info', JSON) column.drop(training_results)