from mig.models import MigrationData from talkatv import db from talkatv.models import MODELS from talkatv.migrations import MIGRATIONS root_log = logging.getLogger() root_log.setLevel(logging.DEBUG) logging.basicConfig() _log = logging.getLogger(__name__) def check_or_create_mig_data(): if not db.engine.dialect.has_table(db.session, 'mig__data'): _log.info('Creating MigrationData table...') MigrationData.__table__.create(db.engine) # Create the first migration, so that mig doesn't init. migration = MigrationData(name=u'__main__', version=0) db.session.add(migration) db.session.commit() if __name__ == '__main__': if db.engine.dialect.has_table(db.session, 'user'): # The DB is already populated, check if migrations are active check_or_create_mig_data() run(db.engine, u'__main__', MODELS, MIGRATIONS)
def main(): run(db.engine, u'__main__', models.MODELS, migrations.MIGRATIONS) run(db.engine, u'www', wwwmodels.MODELS, wwwmigrations.MIGRATIONS)