Add migration for Auth
This commit is contained in:
parent
3ab8efe509
commit
16a4d6ff97
36
alembic/versions/20250327_102146_1d17e58f_create_auth.py
Normal file
36
alembic/versions/20250327_102146_1d17e58f_create_auth.py
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
"""create auths table
|
||||||
|
|
||||||
|
Revision ID: a2b3c4d5e6f7
|
||||||
|
Revises:
|
||||||
|
Create Date: 2024-01-01 12:00:00.000000
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
from sqlalchemy.sql import func
|
||||||
|
import uuid
|
||||||
|
|
||||||
|
# revision identifiers
|
||||||
|
revision = 'a2b3c4d5e6f7'
|
||||||
|
down_revision = None
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
op.create_table(
|
||||||
|
'auths',
|
||||||
|
sa.Column('id', sa.String(), primary_key=True, default=lambda: str(uuid.uuid4())),
|
||||||
|
sa.Column('token', sa.String(), nullable=False),
|
||||||
|
sa.Column('user_id', sa.String(), nullable=False),
|
||||||
|
sa.Column('device_id', sa.String(), nullable=True),
|
||||||
|
sa.Column('created_at', sa.DateTime(), server_default=sa.func.now()),
|
||||||
|
sa.Column('updated_at', sa.DateTime(), server_default=sa.func.now(), onupdate=sa.func.now()),
|
||||||
|
sa.PrimaryKeyConstraint('id')
|
||||||
|
)
|
||||||
|
|
||||||
|
op.create_index('ix_auths_token', 'auths', ['token'])
|
||||||
|
op.create_index('ix_auths_user_id', 'auths', ['user_id'])
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
op.drop_index('ix_auths_token', 'auths')
|
||||||
|
op.drop_index('ix_auths_user_id', 'auths')
|
||||||
|
op.drop_table('auths')
|
Loading…
x
Reference in New Issue
Block a user