Add working Alembic migration setup using Flask-Alembic.

This commit is contained in:
Dorian 2017-03-11 13:32:37 -05:00
parent cacf55fe5b
commit 6a9fe69cbf
4 changed files with 30 additions and 4 deletions

View File

@ -11,12 +11,13 @@ SQLAlchemy==1.1.4
SQLAlchemy-Utils==0.32.9
Flask-SQLAlchemy==2.1
psycopg2==2.6.2
Flask-Migrate==2.0.3
Flask-Alembic==2.0.1
# Utilities
arrow==0.8.0
jsonschema==2.6.0
requests==2.12.1
bpython>=0.15
# Documentation
Sphinx>=1.4.8

View File

@ -14,6 +14,6 @@ def make_api_app(import_name, **kwargs):
api_app = flask.Flask(import_name, **kwargs)
errors.attach_error_handlers_to_api_app(api_app)
database.db.init_app(api_app)
database.migrations.init_app(api_app, database.db)
database.migrations.init_app(api_app)
security.jwt.init_app(api_app)
return api_app

View File

@ -7,12 +7,12 @@ Database code for handling the retrieval and storage of journal entries.
import os
import flask_migrate
import flask_alembic
import flask_sqlalchemy
db = flask_sqlalchemy.SQLAlchemy()
migrations = flask_migrate.Migrate()
migrations = flask_alembic.Alembic()
EXTERNAL_DB_URI_PARAM = 'ROOKERIES_SQLALCHEMY_DATABASE_URI'
DEFAULT_DB_CONNECTION = 'postgresql+psycopg2://admin:password@db:5432/rookeries'

View File

@ -0,0 +1,25 @@
"""${message}
Revision ID: ${up_revision}
Revises: ${down_revision | comma,n}
Create Date: ${create_date}
"""
from alembic import op
import sqlalchemy as sa
import sqlalchemy_utils
${imports if imports else ""}
# revision identifiers, used by Alembic.
revision = ${repr(up_revision)}
down_revision = ${repr(down_revision)}
branch_labels = ${repr(branch_labels)}
depends_on = ${repr(depends_on)}
def upgrade():
${upgrades if upgrades else "pass"}
def downgrade():
${downgrades if downgrades else "pass"}