1
0
mirror of https://gitlab.com/MoonTestUse1/AdministrationItDepartmens.git synced 2025-08-14 00:25:46 +02:00
Files
AdministrationItDepartmens/backend/app/migrations/versions/update_tokens_table.py
MoonTestUse1 87fc83a6d2 починка
2025-01-04 03:25:54 +06:00

38 lines
1.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""update tokens table
Revision ID: update_tokens_table
Revises:
Create Date: 2024-01-03 21:30:00.000000
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'update_tokens_table'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
# Удаляем старую таблицу tokens если она существует
op.drop_table('tokens', if_exists=True)
# Создаем новую таблицу tokens с правильной структурой
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_id'), 'tokens', ['id'], unique=False)
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_index(op.f('ix_tokens_id'), table_name='tokens')
op.drop_table('tokens')