mirror of
https://github.com/grillazz/fastapi-sqlalchemy-asyncpg.git
synced 2025-08-26 16:40:40 +03:00
add user migration
This commit is contained in:
parent
a865abcdb3
commit
0032f4418a
@ -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)
|
||||||
|
40
alembic/versions/20230722_1219_2dcc708f88f8_user_auth.py
Normal file
40
alembic/versions/20230722_1219_2dcc708f88f8_user_auth.py
Normal 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 ###
|
@ -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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user