<s> import imp <EOL> from migrate . versioning import api <EOL> from app import db <EOL> from config import SQLALCHEMY_DATABASE_URI <EOL> from config import SQLALCHEMY_MIGRATE_REPO <EOL> v = api . db_version ( SQLALCHEMY_DATABASE_URI , SQLALCHEMY_MIGRATE_REPO ) <EOL> migration = SQLALCHEMY_MIGRATE_REPO + ( '<STR_LIT>' % ( v + <NUM_LIT:1> ) ) <EOL> tmp_module = imp . new_module ( '<STR_LIT>' ) <EOL> old_model = api . create_model ( SQLALCHEMY_DATABASE_URI , SQLALCHEMY_MIGRATE_REPO ) <EOL> exec old_model in tmp_module . __dict__ <EOL> script = api . make_update_script_for_model ( SQLALCHEMY_DATABASE_URI , <EOL> SQLALCHEMY_MIGRATE_REPO , <EOL> tmp_module . meta , db . metadata ) <EOL> open ( migration , "<STR_LIT>" ) . write ( script ) <EOL> api . upgrade ( SQLALCHEMY_DATABASE_URI , SQLALCHEMY_MIGRATE_REPO ) <EOL> v = api . db_version ( SQLALCHEMY_DATABASE_URI , SQLALCHEMY_MIGRATE_REPO ) <EOL> print ( '<STR_LIT>' + migration ) <EOL> print ( '<STR_LIT>' + str ( v ) ) </s>
