foxnouns/alembic/versions/1710345710_add_tokens.py

39 lines
981 B
Python

"""Add tokens
Revision ID: 0b63f7c8ab96
Revises: b39613fd7327
Create Date: 2024-03-13 17:01:50.434602
"""
from typing import Sequence, Union
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
from alembic import op
# revision identifiers, used by Alembic.
revision: str = "0b63f7c8ab96"
down_revision: Union[str, None] = "b39613fd7327"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
op.create_table(
"tokens",
sa.Column("id", sa.BigInteger(), nullable=False),
sa.Column("expires_at", sa.DateTime(), nullable=False),
sa.Column("scopes", postgresql.ARRAY(sa.Text()), nullable=False),
sa.Column("user_id", sa.BigInteger(), nullable=False),
sa.ForeignKeyConstraint(
["user_id"],
["users.id"],
),
sa.PrimaryKeyConstraint("id"),
)
def downgrade() -> None:
op.drop_table("tokens")