foxnouns/alembic/versions/1710345710_add_tokens.py

40 lines
981 B
Python
Raw Permalink Normal View History

2024-03-13 17:03:18 +01:00
"""Add tokens
Revision ID: 0b63f7c8ab96
Revises: b39613fd7327
Create Date: 2024-03-13 17:01:50.434602
"""
2024-03-23 01:39:08 +01:00
2024-03-13 17:03:18 +01:00
from typing import Sequence, Union
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
2024-03-23 01:39:08 +01:00
from alembic import op
2024-03-13 17:03:18 +01:00
# 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")