def migrate(migrationDirectory, dsn, fromVersion=None, toVersion=None, selectedMigrations=None, init=False): migrator = getMigrator(migrationDirectory) migrator.connect(dsn) if init: models.init() migrator.migrate(fromVersion, toVersion, selectedMigrations) return migrator
def listMigrations(migrationDirectory, dsn, init=False): migrator = getMigrator(migrationDirectory) migrator.connect(dsn) if init: models.init() dbVersion = migrator.getVersion() print "Applied(*) VersionNumber MigrationName" for i, migration in enumerate(migrator.migrations): migrationVersion = i+1 if migrationVersion <= dbVersion: print "%-10s %-13s %s"%("Y", migrationVersion, migration) else: print "%-10s %-13s %s"%("N ", migrationVersion, migration)
def initializeDatabase(dsn): models.connect(dsn) models.init()
def test(self): models.connect(dbUrl) models.init()
def setUp(self): self.indexFilepath = os.path.join(core.ROOT, "testmigrations", "index.yaml") self.migrator = core.DatabaseMigrator(self.indexFilepath) self.migrator.connect(dbUrl) models.init()