def run_backwards(app, migrations, ignore=[], fake=False, db_dry_run=False, silent=False): """ Runs the specified migrations backwards, in order, skipping those migrations in 'ignore'. """ for migration in migrations: if migration not in ignore: app_name = get_app_name(app) if not silent: print " < %s: %s" % (app_name, migration) klass = get_migration(app, migration) if fake: if not silent: print " (faked)" else: if db_dry_run: db.dry_run = True db.start_transaction() try: klass().backwards() db.execute_deferred_sql() except: db.rollback_transaction() raise else: db.commit_transaction() if not db_dry_run: # Record us as having not done this record = MigrationHistory.for_migration(app_name, migration) record.delete()
def run_forwards(app, migrations, fake=False, db_dry_run=False, silent=False): """ Runs the specified migrations forwards, in order. """ for migration in migrations: app_name = get_app_name(app) if not silent: print " > %s: %s" % (app_name, migration) klass = get_migration(app, migration) if fake: if not silent: print " (faked)" else: if db_dry_run: db.dry_run = True db.start_transaction() try: klass().forwards() db.execute_deferred_sql() except: db.rollback_transaction() raise else: db.commit_transaction() if not db_dry_run: # Record us as having done this record = MigrationHistory.for_migration(app_name, migration) record.applied = datetime.datetime.utcnow() record.save()
def record(app_name, migration): # Record us as having not done this record = MigrationHistory.for_migration(app_name, migration) record.delete()
def record(app_name, migration): # Record us as having done this record = MigrationHistory.for_migration(app_name, migration) record.applied = datetime.datetime.utcnow() record.save()