mirror of
https://gitlab.com/MoonTestUse1/AdministrationItDepartmens.git
synced 2025-08-14 00:25:46 +02:00
32 lines
998 B
Python
32 lines
998 B
Python
"""create tokens table
|
|
|
|
Revision ID: create_tokens_table
|
|
Revises:
|
|
Create Date: 2024-01-03 22:00:00.000000
|
|
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = 'create_tokens_table'
|
|
down_revision = None
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
def upgrade():
|
|
op.create_table(
|
|
'tokens',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('token', sa.String(), nullable=False),
|
|
sa.Column('user_id', sa.Integer(), nullable=False),
|
|
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()')),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index(op.f('ix_tokens_token'), 'tokens', ['token'], unique=True)
|
|
op.create_index(op.f('ix_tokens_user_id'), 'tokens', ['user_id'], unique=False)
|
|
|
|
def downgrade():
|
|
op.drop_index(op.f('ix_tokens_user_id'), table_name='tokens')
|
|
op.drop_index(op.f('ix_tokens_token'), table_name='tokens')
|
|
op.drop_table('tokens') |