"""Trip Attachment

Revision ID: 032b5b7de8bd
Revises: 11c969913a7e
Create Date: 2025-10-14 21:28:53.830779

"""

import sqlalchemy as sa
import sqlmodel.sql.sqltypes
from alembic import op

# revision identifiers, used by Alembic.
revision = "032b5b7de8bd"
down_revision = "11c969913a7e"
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "tripattachment",
        sa.Column("filename", sqlmodel.sql.sqltypes.AutoString(), nullable=False),
        sa.Column("file_size", sa.Integer(), nullable=False),
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("uploaded_at", sa.DateTime(), nullable=False),
        sa.Column("uploaded_by", sqlmodel.sql.sqltypes.AutoString(), nullable=False),
        sa.Column("stored_filename", sqlmodel.sql.sqltypes.AutoString(), nullable=False),
        sa.Column("trip_id", sa.Integer(), nullable=False),
        sa.ForeignKeyConstraint(
            ["trip_id"], ["trip.id"], name=op.f("fk_tripattachment_trip_id_trip"), ondelete="CASCADE"
        ),
        sa.ForeignKeyConstraint(
            ["uploaded_by"],
            ["user.username"],
            name=op.f("fk_tripattachment_uploaded_by_user"),
            ondelete="CASCADE",
        ),
        sa.PrimaryKeyConstraint("id", name=op.f("pk_tripattachment")),
    )
    with op.batch_alter_table("tripattachment", schema=None) as batch_op:
        batch_op.create_index(batch_op.f("ix_tripattachment_trip_id"), ["trip_id"], unique=False)

    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table("tripattachment", schema=None) as batch_op:
        batch_op.drop_index(batch_op.f("ix_tripattachment_trip_id"))

    op.drop_table("tripattachment")
    # ### end Alembic commands ###
