"""Initial schema

Revision ID: 17063f7d3880
Revises:
Create Date: 2025-11-17 22:11:12.491355

"""

from typing import Sequence, Union

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision: str = "17063f7d3880"
down_revision: Union[str, Sequence[str], None] = None
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    """Upgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "contexts",
        sa.Column("name", sa.String(), nullable=False),
        sa.Column("access_token", sa.String(), nullable=False),
        sa.Column("user_id", sa.String(), nullable=False),
        sa.Column("workspace_id", sa.String(), nullable=False),
        sa.PrimaryKeyConstraint("name"),
    )
    op.create_table(
        "current_context",
        sa.Column("timestamp", sa.DateTime(), nullable=False),
        sa.Column("context_name", sa.String(), nullable=False),
        sa.ForeignKeyConstraint(
            ["context_name"], ["contexts.name"], ondelete="CASCADE"
        ),
        sa.PrimaryKeyConstraint("timestamp"),
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    """Downgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table("current_context")
    op.drop_table("contexts")
    # ### end Alembic commands ###
