From 8f671afb5894f1c44fa8dbf237e5b86e4bd9e4dc Mon Sep 17 00:00:00 2001 From: itskovacs Date: Sun, 2 Nov 2025 00:16:04 +0100 Subject: [PATCH] update models: TripItem attachments --- .../c6bf10b10d0a_tripitem_attachments.py | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 backend/trip/alembic/versions/c6bf10b10d0a_tripitem_attachments.py diff --git a/backend/trip/alembic/versions/c6bf10b10d0a_tripitem_attachments.py b/backend/trip/alembic/versions/c6bf10b10d0a_tripitem_attachments.py new file mode 100644 index 0000000..ed3015a --- /dev/null +++ b/backend/trip/alembic/versions/c6bf10b10d0a_tripitem_attachments.py @@ -0,0 +1,52 @@ +"""TripItem attachments + +Revision ID: c6bf10b10d0a +Revises: e75fca7d8759 +Create Date: 2025-11-01 23:12:29.691502 + +""" + +import sqlalchemy as sa +import sqlmodel.sql.sqltypes +from alembic import op + +# revision identifiers, used by Alembic. +revision = "c6bf10b10d0a" +down_revision = "e75fca7d8759" +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table( + "tripitemattachmentlink", + sa.Column("item_id", sa.Integer(), nullable=False), + sa.Column("attachment_id", sa.Integer(), nullable=False), + sa.ForeignKeyConstraint( + ["attachment_id"], + ["tripattachment.id"], + name=op.f("fk_tripitemattachmentlink_attachment_id_tripattachment"), + ondelete="CASCADE", + ), + sa.ForeignKeyConstraint( + ["item_id"], + ["tripitem.id"], + name=op.f("fk_tripitemattachmentlink_item_id_tripitem"), + ondelete="CASCADE", + ), + sa.PrimaryKeyConstraint("item_id", "attachment_id", name=op.f("pk_tripitemattachmentlink")), + ) + with op.batch_alter_table("tripitemattachmentlink", schema=None) as batch_op: + batch_op.create_index(batch_op.f("ix_tripitemattachmentlink_item_id"), ["item_id"], unique=False) + + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table("tripitemattachmentlink", schema=None) as batch_op: + batch_op.drop_index(batch_op.f("ix_tripitemattachmentlink_item_id")) + + op.drop_table("tripitemattachmentlink") + # ### end Alembic commands ###