Add migration for Auth
This commit is contained in:
parent
e29917411e
commit
3526940619
37
alembic/versions/20250326_171057_2849591e_create_auth.py
Normal file
37
alembic/versions/20250326_171057_2849591e_create_auth.py
Normal file
@ -0,0 +1,37 @@
|
||||
"""create auths table
|
||||
|
||||
Revision ID: b2c3d4e5f6g7
|
||||
Revises:
|
||||
Create Date: 2023-01-01 12:00:00.000000
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.sql import func
|
||||
import uuid
|
||||
|
||||
# revision identifiers
|
||||
revision = 'b2c3d4e5f6g7'
|
||||
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('user_id', sa.String(), nullable=False),
|
||||
sa.Column('token', sa.String(), nullable=False),
|
||||
sa.Column('is_blacklisted', sa.Boolean(), default=False),
|
||||
sa.Column('expires_at', sa.DateTime(), nullable=False),
|
||||
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_user_id', 'auths', ['user_id'])
|
||||
op.create_index('ix_auths_token', 'auths', ['token'], unique=True)
|
||||
|
||||
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