Skip to content

Commit 0032f44

Browse files
author
Jakub Miazek
committed
add user migration
1 parent a865abc commit 0032f44

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

alembic/env.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ async def run_migrations_online():
3131
and associate a connection with the context.
3232
3333
"""
34-
connectable = create_async_engine(settings.asyncpg_url, future=True)
34+
connectable = create_async_engine(settings.asyncpg_url.unicode_string(), future=True)
3535

3636
async with connectable.connect() as connection:
3737
await connection.run_sync(do_run_migrations)
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
"""user auth
2+
3+
Revision ID: 2dcc708f88f8
4+
Revises: 0d1ee3949d21
5+
Create Date: 2023-07-22 12:19:28.780926
6+
7+
"""
8+
from alembic import op
9+
import sqlalchemy as sa
10+
11+
12+
# revision identifiers, used by Alembic.
13+
revision = '2dcc708f88f8'
14+
down_revision = '0d1ee3949d21'
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('user',
22+
sa.Column('uuid', sa.UUID(), nullable=False),
23+
sa.Column('email', sa.String(), nullable=False),
24+
sa.Column('first_name', sa.String(), nullable=False),
25+
sa.Column('last_name', sa.String(), nullable=False),
26+
sa.Column('password', sa.LargeBinary(), nullable=False),
27+
sa.PrimaryKeyConstraint('uuid'),
28+
sa.UniqueConstraint('uuid')
29+
)
30+
op.create_unique_constraint(None, 'nonsense', ['name'], schema='happy_hog')
31+
op.create_unique_constraint(None, 'stuff', ['name'], schema='happy_hog')
32+
# ### end Alembic commands ###
33+
34+
35+
def downgrade():
36+
# ### commands auto generated by Alembic - please adjust! ###
37+
op.drop_constraint(None, 'stuff', schema='happy_hog', type_='unique')
38+
op.drop_constraint(None, 'nonsense', schema='happy_hog', type_='unique')
39+
op.drop_table('user')
40+
# ### end Alembic commands ###

app/models/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
from app.models.nonsense import * # noqa
33
from app.models.shakespeare import * # noqa
44
from app.models.stuff import * # noqa
5+
from app.models.user import * # noqa

0 commit comments

Comments
 (0)