def update_database_from_model(): """Introspection the model and add missing columns in the database this function can be ran in setup_model after setup_all(create_tables=True) """ import settings migrate_engine = settings.ENGINE() migrate_connection = migrate_engine.connect() from camelot.model import metadata from migrate.versioning.schemadiff import SchemaDiff from migrate.changeset import create_column schema_diff = SchemaDiff(metadata, migrate_connection) for table_with_diff in schema_diff.tablesWithDiff: missingInDatabase, _missingInModel, _diffDecl = schema_diff.colDiffs[table_with_diff.name] for col in missingInDatabase: create_column(col, table_with_diff)
def update_database_from_model(): """Introspection the model and add missing columns in the database this function can be ran in setup_model after setup_all(create_tables=True) """ import settings migrate_engine = settings.ENGINE() migrate_connection = migrate_engine.connect() from camelot.model import metadata from migrate.versioning.schemadiff import SchemaDiff from migrate.changeset import create_column schema_diff = SchemaDiff(metadata, migrate_connection) for table_with_diff in schema_diff.tablesWithDiff: missingInDatabase, _missingInModel, _diffDecl = schema_diff.colDiffs[ table_with_diff.name] for col in missingInDatabase: create_column(col, table_with_diff)
def update_database_from_model(): """Introspection the model and add missing columns in the database. this function can be ran in setup_model after:: metadata.create_all() """ migrate_engine = settings.ENGINE() migrate_connection = migrate_engine.connect() from sqlalchemy.schema import MetaData from migrate.versioning import schemadiff from migrate.changeset import create_column schema_diff = schemadiff.SchemaDiff(metadata, MetaData(migrate_connection, reflect=True)) for table_name, difference in schema_diff.tables_different.items(): for column in difference.columns_missing_from_B: LOGGER.warn( 'column %s missing in table %s'%(column, table_name) ) table = metadata.tables[table_name] create_column(column, table)
def update_database_from_model(): """Introspection the model and add missing columns in the database. this function can be ran in setup_model after:: metadata.create_all() """ migrate_engine = settings.ENGINE() migrate_connection = migrate_engine.connect() from sqlalchemy.schema import MetaData from migrate.versioning import schemadiff from migrate.changeset import create_column schema_diff = schemadiff.SchemaDiff( metadata, MetaData(migrate_connection, reflect=True)) for table_name, difference in schema_diff.tables_different.items(): for column in difference.columns_missing_from_B: LOGGER.warn('column %s missing in table %s' % (column, table_name)) table = metadata.tables[table_name] create_column(column, table)
def upgrade(): create_column(myth_role, hosts) create_column(myth_remote, hosts) create_column(myth_theme, hosts)
def upgrade(): create_column(myth_systemrole, hosts) create_column(mythremote, hosts) create_column(myththeme, hosts)
def upgrade(): create_column(col, GroupsTable)
def upgrade(): create_column(col, PeopleTable)
def upgrade(migrate_engine): metadata = DeclarativeBase.metadata metadata.bind = migrate_engine create_column(Status.__table__.c.group_id, table=Status.__table__)
def upgrade(migrate_engine): metadata = DeclarativeBase.metadata metadata.bind = migrate_engine create_column(User.__table__.c.username, table=User.__table__)
def upgrade(): # Upgrade operations go here. Don't create your own engine; use the engine # named 'migrate_engine' imported from migrate. create_column(description, shows_table)