Fix migration issues:

- MySQL 5.5 doesn't support the now() call as a default
  - Postgres migration isn't auto-committed, so we have to check if the table exists first
This commit is contained in:
Joseph Schorr 2014-11-03 15:25:55 -05:00
parent 225c2be355
commit 9aa72c5cc2
3 changed files with 21 additions and 6 deletions

View file

@ -5,7 +5,7 @@ import os
from alembic import context
from sqlalchemy import engine_from_config, pool
from logging.config import fileConfig
from urllib import unquote
from urllib import unquote, quote
from peewee import SqliteDatabase
from data.database import all_models, db
@ -24,6 +24,11 @@ if 'GENMIGRATE' in os.environ:
else:
db_uri = 'postgresql://postgres@%s/genschema' % (docker_host_ip)
if 'DB_URI' in os.environ:
db_uri = os.environ['DB_URI']
app.config['DB_URI'] = db_uri
config = context.config
config.set_main_option('sqlalchemy.url', db_uri)
@ -69,7 +74,7 @@ def run_migrations_online():
"""
if isinstance(db.obj, SqliteDatabase) and not 'GENMIGRATE' in os.environ:
if isinstance(db.obj, SqliteDatabase) and not 'GENMIGRATE' in os.environ and not 'DB_URI' in os.environ:
print ('Skipping Sqlite migration!')
return