Skip to content

Commit ae67ae6

Browse files
committed
Collapsed the database migrations
So we can test with both SQLite and Postgres
1 parent 2f51d3b commit ae67ae6

File tree

4 files changed

+44
-108
lines changed

4 files changed

+44
-108
lines changed

migrations/env.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,11 @@
2424

2525
import logging
2626
from logging.config import fileConfig
27+
from alembic import context
2728

2829
from flask import current_app
2930

30-
from alembic import context
31-
32-
# this is the Alembic Config object, which provides
33-
# access to the values within the .ini file in use.
3431
config = context.config
35-
36-
# Interpret the config file for Python logging.
37-
# This line sets up loggers basically.
3832
fileConfig(config.config_file_name)
3933
logger = logging.getLogger('alembic.env')
4034

@@ -99,6 +93,7 @@ def process_revision_directives(context, revision, directives):
9993
connection=connection,
10094
target_metadata=target_metadata,
10195
process_revision_directives=process_revision_directives,
96+
render_as_batch=True,
10297
**current_app.extensions['migrate'].configure_args
10398
)
10499

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
"""initial
2+
3+
Revision ID: 1bea80b612cc
4+
Revises:
5+
Create Date: 2021-12-25 13:31:36.003378
6+
7+
"""
8+
from alembic import op
9+
import sqlalchemy as sa
10+
11+
12+
# revision identifiers, used by Alembic.
13+
revision = '1bea80b612cc'
14+
down_revision = None
15+
branch_labels = None
16+
depends_on = None
17+
18+
19+
def upgrade():
20+
# ### commands auto generated by Alembic - please adjust! ###
21+
op.create_table('owners',
22+
sa.Column('id', sa.BigInteger().with_variant(sa.Integer(), 'sqlite'), nullable=False),
23+
sa.Column('client_id', sa.String(length=255), nullable=False),
24+
sa.Column('name', sa.String(length=255), nullable=False),
25+
sa.PrimaryKeyConstraint('id'),
26+
sa.UniqueConstraint('client_id')
27+
)
28+
op.create_table('resources',
29+
sa.Column('id', sa.BigInteger().with_variant(sa.Integer(), 'sqlite'), nullable=False),
30+
sa.Column('owner_id', sa.Integer(), nullable=False),
31+
sa.Column('name', sa.String(length=255), nullable=False),
32+
sa.ForeignKeyConstraint(['owner_id'], ['owners.id'], ),
33+
sa.PrimaryKeyConstraint('id')
34+
)
35+
# ### end Alembic commands ###
36+
37+
38+
def downgrade():
39+
# ### commands auto generated by Alembic - please adjust! ###
40+
op.drop_table('resources')
41+
op.drop_table('owners')
42+
# ### end Alembic commands ###

migrations/versions/4594cf7d8bfb_initial_resource.py

Lines changed: 0 additions & 55 deletions
This file was deleted.

migrations/versions/d11062fbec93_owners_and_resources.py

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)