foxnouns/alembic/versions/1709998348_init.py

65 lines
2 KiB
Python

"""Init
Revision ID: b39613fd7327
Revises:
Create Date: 2024-03-09 16:32:28.590145
"""
from typing import Sequence, Union
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision: str = "b39613fd7327"
down_revision: Union[str, None] = None
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
op.create_table(
"fediverse_apps",
sa.Column("id", sa.BigInteger(), nullable=False),
sa.Column("instance", sa.Text(), nullable=False),
sa.Column("client_id", sa.Text(), nullable=False),
sa.Column("client_secret", sa.Text(), nullable=False),
sa.Column("instance_type", sa.Integer(), nullable=False),
sa.PrimaryKeyConstraint("id"),
sa.UniqueConstraint("instance"),
)
op.create_table(
"users",
sa.Column("id", sa.BigInteger(), nullable=False),
sa.Column("username", sa.Text(), nullable=False),
sa.Column("display_name", sa.Text(), nullable=True),
sa.Column("bio", sa.Text(), nullable=True),
sa.PrimaryKeyConstraint("id"),
sa.UniqueConstraint("username"),
)
op.create_table(
"auth_methods",
sa.Column("id", sa.BigInteger(), nullable=False),
sa.Column("auth_type", sa.Integer(), nullable=False),
sa.Column("remote_id", sa.Text(), nullable=False),
sa.Column("remote_username", sa.Text(), nullable=True),
sa.Column("user_id", sa.BigInteger(), nullable=False),
sa.Column("fediverse_app_id", sa.BigInteger(), nullable=True),
sa.ForeignKeyConstraint(
["fediverse_app_id"],
["fediverse_apps.id"],
),
sa.ForeignKeyConstraint(
["user_id"],
["users.id"],
),
sa.PrimaryKeyConstraint("id"),
)
def downgrade() -> None:
op.drop_table("auth_methods")
op.drop_table("users")
op.drop_table("fediverse_apps")