56 lines
1.7 KiB
Python
56 lines
1.7 KiB
Python
"""user table
|
|
|
|
Revision ID: 0f62f2706427
|
|
Revises:
|
|
Create Date: 2023-12-04 12:52:57.863223
|
|
|
|
"""
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = "0f62f2706427"
|
|
down_revision = None
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
|
|
op.create_table(
|
|
"user",
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
sa.Column("email", sa.String(length=80), nullable=True),
|
|
sa.Column("username", sa.String(length=100), nullable=True),
|
|
sa.Column("password_hash", sa.String(length=255), nullable=True),
|
|
sa.Column("token", sa.String(length=32), nullable=True),
|
|
sa.Column("token_expiration", sa.DateTime(), nullable=True),
|
|
sa.Column("refresh_token", sa.String(length=32), nullable=True),
|
|
sa.Column("reset_password_code", sa.String(length=8), nullable=True),
|
|
sa.Column("reset_password_expiration", sa.DateTime(), nullable=True),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
sa.UniqueConstraint("email"),
|
|
)
|
|
with op.batch_alter_table("user", schema=None) as batch_op:
|
|
batch_op.create_index(
|
|
batch_op.f("ix_user_refresh_token"), ["refresh_token"], unique=True
|
|
)
|
|
batch_op.create_index(
|
|
batch_op.f("ix_user_reset_password_code"),
|
|
["reset_password_code"],
|
|
unique=True,
|
|
)
|
|
batch_op.create_index(
|
|
batch_op.f("ix_user_token"), ["token"], unique=True
|
|
)
|
|
|
|
|
|
def downgrade():
|
|
with op.batch_alter_table("user", schema=None) as batch_op:
|
|
batch_op.drop_index(batch_op.f("ix_user_token"))
|
|
batch_op.drop_index(batch_op.f("ix_user_reset_password_code"))
|
|
batch_op.drop_index(batch_op.f("ix_user_refresh_token"))
|
|
op.drop_table("user")
|