Add a script for generating schema migrations. Should be run from the root quay directory.

This commit is contained in:
Joseph Schorr 2014-09-22 14:36:52 -04:00
parent e5055763f6
commit 70e0aba257
2 changed files with 30 additions and 2 deletions

View file

@ -1,4 +1,7 @@
from __future__ import with_statement
import os
from alembic import context
from sqlalchemy import engine_from_config, pool
from logging.config import fileConfig
@ -12,8 +15,12 @@ from util.morecollections import AttrDict
# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
db_uri = unquote(app.config['DB_URI'])
if 'GENMIGRATE' in os.environ:
db_uri = 'mysql+pymysql://root:password@192.168.59.103/genschema'
config = context.config
config.set_main_option('sqlalchemy.url', unquote(app.config['DB_URI']))
config.set_main_option('sqlalchemy.url', db_uri)
# Interpret the config file for Python logging.
# This line sets up loggers basically.
@ -57,7 +64,7 @@ def run_migrations_online():
"""
if isinstance(db.obj, SqliteDatabase):
if isinstance(db.obj, SqliteDatabase) and not 'GENMIGRATE' in os.environ:
print ('Skipping Sqlite migration!')
return