42 lines
1.4 KiB
Python
42 lines
1.4 KiB
Python
|
|
"""add email verification tokens table
|
||
|
|
|
||
|
|
Revision ID: 0011
|
||
|
|
Revises: 0010
|
||
|
|
Create Date: 2026-04-10
|
||
|
|
|
||
|
|
"""
|
||
|
|
from typing import Sequence, Union
|
||
|
|
|
||
|
|
import sqlalchemy as sa
|
||
|
|
from alembic import op
|
||
|
|
from sqlalchemy.dialects import postgresql
|
||
|
|
|
||
|
|
revision: str = "0011"
|
||
|
|
down_revision: Union[str, None] = "0010"
|
||
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
||
|
|
depends_on: Union[str, Sequence[str], None] = None
|
||
|
|
|
||
|
|
|
||
|
|
def upgrade() -> None:
|
||
|
|
op.create_table(
|
||
|
|
"email_verification_tokens",
|
||
|
|
sa.Column("id", postgresql.UUID(as_uuid=True), primary_key=True),
|
||
|
|
sa.Column(
|
||
|
|
"user_id",
|
||
|
|
postgresql.UUID(as_uuid=True),
|
||
|
|
sa.ForeignKey("users.id", ondelete="CASCADE"),
|
||
|
|
nullable=False,
|
||
|
|
),
|
||
|
|
sa.Column("token", sa.Text(), nullable=False, unique=True),
|
||
|
|
sa.Column("expires_at", sa.DateTime(timezone=True), nullable=False),
|
||
|
|
sa.Column("used_at", sa.DateTime(timezone=True), nullable=True),
|
||
|
|
)
|
||
|
|
op.create_index("ix_email_verification_tokens_token", "email_verification_tokens", ["token"])
|
||
|
|
op.create_index("ix_email_verification_tokens_user_id", "email_verification_tokens", ["user_id"])
|
||
|
|
|
||
|
|
|
||
|
|
def downgrade() -> None:
|
||
|
|
op.drop_index("ix_email_verification_tokens_user_id", table_name="email_verification_tokens")
|
||
|
|
op.drop_index("ix_email_verification_tokens_token", table_name="email_verification_tokens")
|
||
|
|
op.drop_table("email_verification_tokens")
|