]> git.datanom.net - wpp.git/blame - db_migrate.py
rm test access
[wpp.git] / db_migrate.py
CommitLineData
047d4d29
MR
1#!flask/bin/python
2import imp
3from migrate.versioning import api
4from app import db
5from config import SQLALCHEMY_DATABASE_URI
6from config import SQLALCHEMY_MIGRATE_REPO
7v = api.db_version(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
8migration = SQLALCHEMY_MIGRATE_REPO + ('/versions/%03d_migration.py' % (v+1))
9tmp_module = imp.new_module('old_model')
10old_model = api.create_model(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
11exec(old_model, tmp_module.__dict__)
12script = api.make_update_script_for_model(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO, tmp_module.meta, db.metadata)
13open(migration, "wt").write(script)
14api.upgrade(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
15v = api.db_version(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
16print('New migration saved as ' + migration)
17print('Current database version: ' + str(v))
This page took 0.03643 seconds and 5 git commands to generate.