"""initial

Revision ID: f40ddf6f808c
Revises:
Create Date: 2025-04-19 15:36:15.928419

"""

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "f40ddf6f808c"
down_revision = None
branch_labels = None
depends_on = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "text",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.PrimaryKeyConstraint("id", name=op.f("pk_text")),
        schema="public",
    )
    op.create_table(
        "step",
        sa.Column("type", sa.String(), nullable=False),
        sa.Column("prev_id", sa.Integer(), nullable=True),
        sa.Column("title_id", sa.Integer(), nullable=False),
        sa.Column("description_id", sa.Integer(), nullable=True),
        sa.Column("id", sa.Integer(), nullable=False),
        sa.ForeignKeyConstraint(
            ["description_id"],
            ["public.text.id"],
            name=op.f("fk_step_description_id_text"),
        ),
        sa.ForeignKeyConstraint(
            ["prev_id"], ["public.step.id"], name=op.f("fk_step_prev_id_step")
        ),
        sa.ForeignKeyConstraint(
            ["title_id"], ["public.text.id"], name=op.f("fk_step_title_id_text")
        ),
        sa.PrimaryKeyConstraint("id", name=op.f("pk_step")),
        schema="public",
    )
    op.create_table(
        "translation",
        sa.Column("text_id", sa.Integer(), nullable=False),
        sa.Column("contents", sa.String(), nullable=False),
        sa.Column("language", sa.Enum("CZ", "EN", name="language"), nullable=False),
        sa.Column("id", sa.Integer(), nullable=False),
        sa.ForeignKeyConstraint(
            ["text_id"], ["public.text.id"], name=op.f("fk_translation_text_id_text")
        ),
        sa.PrimaryKeyConstraint("id", name=op.f("pk_translation")),
        schema="public",
    )
    op.create_table(
        "link_step",
        sa.Column("link", sa.String(), nullable=False),
        sa.Column("id", sa.Integer(), nullable=False),
        sa.ForeignKeyConstraint(
            ["id"],
            ["public.step.id"],
            name=op.f("fk_link_step_id_step"),
            ondelete="CASCADE",
        ),
        sa.PrimaryKeyConstraint("id", name=op.f("pk_link_step")),
        schema="public",
    )
    op.create_table(
        "text_step",
        sa.Column("text_id", sa.Integer(), nullable=False),
        sa.Column("id", sa.Integer(), nullable=False),
        sa.ForeignKeyConstraint(
            ["id"],
            ["public.step.id"],
            name=op.f("fk_text_step_id_step"),
            ondelete="CASCADE",
        ),
        sa.ForeignKeyConstraint(
            ["text_id"], ["public.text.id"], name=op.f("fk_text_step_text_id_text")
        ),
        sa.PrimaryKeyConstraint("id", name=op.f("pk_text_step")),
        schema="public",
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table("text_step", schema="public")
    op.drop_table("link_step", schema="public")
    op.drop_table("translation", schema="public")
    op.drop_table("step", schema="public")
    op.drop_table("text", schema="public")
    # ### end Alembic commands ###
