add user migration

This commit is contained in:
Jakub Miazek 2023-07-22 14:24:14 +02:00
parent a865abcdb3
commit 0032f4418a
3 changed files with 42 additions and 1 deletions

View File

@ -31,7 +31,7 @@ async def run_migrations_online():
and associate a connection with the context. and associate a connection with the context.
""" """
connectable = create_async_engine(settings.asyncpg_url, future=True) connectable = create_async_engine(settings.asyncpg_url.unicode_string(), future=True)
async with connectable.connect() as connection: async with connectable.connect() as connection:
await connection.run_sync(do_run_migrations) await connection.run_sync(do_run_migrations)

View File

@ -0,0 +1,40 @@
"""user auth
Revision ID: 2dcc708f88f8
Revises: 0d1ee3949d21
Create Date: 2023-07-22 12:19:28.780926
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '2dcc708f88f8'
down_revision = '0d1ee3949d21'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('user',
sa.Column('uuid', sa.UUID(), nullable=False),
sa.Column('email', sa.String(), nullable=False),
sa.Column('first_name', sa.String(), nullable=False),
sa.Column('last_name', sa.String(), nullable=False),
sa.Column('password', sa.LargeBinary(), nullable=False),
sa.PrimaryKeyConstraint('uuid'),
sa.UniqueConstraint('uuid')
)
op.create_unique_constraint(None, 'nonsense', ['name'], schema='happy_hog')
op.create_unique_constraint(None, 'stuff', ['name'], schema='happy_hog')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(None, 'stuff', schema='happy_hog', type_='unique')
op.drop_constraint(None, 'nonsense', schema='happy_hog', type_='unique')
op.drop_table('user')
# ### end Alembic commands ###

View File

@ -2,3 +2,4 @@
from app.models.nonsense import * # noqa from app.models.nonsense import * # noqa
from app.models.shakespeare import * # noqa from app.models.shakespeare import * # noqa
from app.models.stuff import * # noqa from app.models.stuff import * # noqa
from app.models.user import * # noqa