def migrations_to_run(self):
"""
Get a list of migrations to run still, if any.
-
+
Note that this will fail if there's no migration record for
this class!
"""
assert self.database_current_migration is not None
db_current_migration = self.database_current_migration
-
+
return [
(migration_number, migration_func)
for migration_number, migration_func in self.sorted_migrations
in mediagoblin.db.models
"""
for Model, rows in self.foundations.items():
- self.printer(u' + Laying foundations for %s table\n' %
+ self.printer(u' + Laying foundations for %s table\n' %
(Model.__name__))
for parameters in rows:
new_row = Model(**parameters)
migration_number, migration_func.func_name))
return u'migrated'
-
+
def name_for_printing(self):
if self.name == u'__main__':
return u"main mediagoblin tables"
assert migration_number > 0, "Migration number must be > 0!"
assert migration_number not in migration_registry, \
"Duplicate migration numbers detected! That's not allowed!"
+ assert migration_number <= 44, ('Alembic should be used for '
+ 'new migrations')
self.migration_number = migration_number
self.migration_registry = migration_registry
-tion, for example, dropping a boolean column in sqlite is impossible w/o
this method
- :param old_table A ref to the old table, gotten through
+ :param old_table A ref to the old table, gotten through
inspect_table
:param replacement_table A ref to the new table, gotten through
# If it's SQLite just return all the objects
if db.bind.url.drivername == "sqlite":
return [obj for obj in db.execute(query)]
-
+
# Postgres return the query as it knows how to deal with it.
return db.execute(query)