Add working Alembic migration setup using Flask-Alembic.
This commit is contained in:
parent
cacf55fe5b
commit
6a9fe69cbf
|
@ -11,12 +11,13 @@ SQLAlchemy==1.1.4
|
||||||
SQLAlchemy-Utils==0.32.9
|
SQLAlchemy-Utils==0.32.9
|
||||||
Flask-SQLAlchemy==2.1
|
Flask-SQLAlchemy==2.1
|
||||||
psycopg2==2.6.2
|
psycopg2==2.6.2
|
||||||
Flask-Migrate==2.0.3
|
Flask-Alembic==2.0.1
|
||||||
|
|
||||||
# Utilities
|
# Utilities
|
||||||
arrow==0.8.0
|
arrow==0.8.0
|
||||||
jsonschema==2.6.0
|
jsonschema==2.6.0
|
||||||
requests==2.12.1
|
requests==2.12.1
|
||||||
|
bpython>=0.15
|
||||||
|
|
||||||
# Documentation
|
# Documentation
|
||||||
Sphinx>=1.4.8
|
Sphinx>=1.4.8
|
||||||
|
|
|
@ -14,6 +14,6 @@ def make_api_app(import_name, **kwargs):
|
||||||
api_app = flask.Flask(import_name, **kwargs)
|
api_app = flask.Flask(import_name, **kwargs)
|
||||||
errors.attach_error_handlers_to_api_app(api_app)
|
errors.attach_error_handlers_to_api_app(api_app)
|
||||||
database.db.init_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)
|
security.jwt.init_app(api_app)
|
||||||
return api_app
|
return api_app
|
||||||
|
|
|
@ -7,12 +7,12 @@ Database code for handling the retrieval and storage of journal entries.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import flask_migrate
|
import flask_alembic
|
||||||
import flask_sqlalchemy
|
import flask_sqlalchemy
|
||||||
|
|
||||||
|
|
||||||
db = flask_sqlalchemy.SQLAlchemy()
|
db = flask_sqlalchemy.SQLAlchemy()
|
||||||
migrations = flask_migrate.Migrate()
|
migrations = flask_alembic.Alembic()
|
||||||
|
|
||||||
EXTERNAL_DB_URI_PARAM = 'ROOKERIES_SQLALCHEMY_DATABASE_URI'
|
EXTERNAL_DB_URI_PARAM = 'ROOKERIES_SQLALCHEMY_DATABASE_URI'
|
||||||
DEFAULT_DB_CONNECTION = 'postgresql+psycopg2://admin:password@db:5432/rookeries'
|
DEFAULT_DB_CONNECTION = 'postgresql+psycopg2://admin:password@db:5432/rookeries'
|
||||||
|
|
|
@ -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"}
|
Loading…
Reference in New Issue