def test_upgrate(self): migrations.migrate(0) self.assertEquals(0, migrations.current_schema()) migrations.migrate(1) self.assertEquals(1, migrations.current_schema()) migrations.migrate(schema.version) self.assertEquals(schema.version, migrations.current_schema())
def run(self): if len(self.args) > 0: self.parser.error("Invalid argument") # First we check to see if it is current cur = migrations.current_schema() if cur is None: print "Creating database..." migrations.create() elif cur < schema.version: print "Database schema out of date. Please run migrate." elif cur == schema.version: print "Database schema up-to-date." else: print "Database schema is newer than expected. " "Expected <= %d, got %d." % (schema.version, cur)
def run(self): if len(self.args) > 0: self.parser.error("Invalid argument") # First we check to see if it is current cur = migrations.current_schema() if cur is None: print "Creating database..." migrations.create() elif cur < schema.version: print "Database schema out of date. Please run migrate." elif cur == schema.version: print "Database schema up-to-date." else: print "Database schema is newer than expected. "\ "Expected <= %d, got %d." % (schema.version, cur)
def run(self): if len(self.args) > 1: self.parser.error("Invalid argument") elif len(self.args) == 1: target = int(self.args[0]) else: target = schema.version current = migrations.current_schema() if current is None: print "No database schema. Please run create." exit(1) if current == target: print "Database schema up to date" exit(0) print "Migrating database schema from v%d to v%d..." % (current, target) migrations.migrate(target)
def test_downgrade(self): self.assertEquals(schema.version, migrations.current_schema()) migrations.migrate(0) self.assertEquals(0, migrations.current_schema())