Alexander Hess
a16c260543
- use Alembic to migrate the PostgreSQL database + create initial migration script to set up the database, as an alternative to db.Base.metadata.create_all() + integrate Alembic into the test suite; the db_engine fixture now has two modes: * create the latest version of tables all at once * invoke `alembic upgrade head` => the "e2e" tests are all run twice, once in each mode; this ensures that the migration scripts re-create the same database schema as db.Base.metadata.create_all() would * in both modes, a temporary PostgreSQL schema is used to create the tables in => could now run "e2e" tests against production database and still have isolation - make the configuration module public (to be used by Alembic) - adjust linting rules for Alembic
31 lines
689 B
Mako
31 lines
689 B
Mako
"""${message}.
|
|
|
|
Revision: # ${up_revision} at ${create_date}
|
|
Revises: # ${down_revision | comma,n}
|
|
"""
|
|
|
|
import os
|
|
|
|
import sqlalchemy as sa
|
|
from alembic import op
|
|
${imports if imports else ""}
|
|
|
|
from urban_meal_delivery import configuration
|
|
|
|
revision = ${repr(up_revision)}
|
|
down_revision = ${repr(down_revision)}
|
|
branch_labels = ${repr(branch_labels)}
|
|
depends_on = ${repr(depends_on)}
|
|
|
|
|
|
config = configuration.make_config('testing' if os.getenv('TESTING') else 'production')
|
|
|
|
|
|
def upgrade():
|
|
"""Upgrade to revision ${up_revision}."""
|
|
${upgrades if upgrades else "pass"}
|
|
|
|
|
|
def downgrade():
|
|
"""Downgrade to revision ${down_revision}."""
|
|
${downgrades if downgrades else "pass"}
|
|
|