Readded fk constraint for conversion_guests
This commit is contained in:
@@ -0,0 +1,32 @@
|
|||||||
|
"""add conversions→conversion_guests fk
|
||||||
|
|
||||||
|
Revision ID: 263bed87114f
|
||||||
|
Revises: 3147e421bc47
|
||||||
|
Create Date: 2025-12-03 12:25:12.820232
|
||||||
|
|
||||||
|
"""
|
||||||
|
from typing import Sequence, Union
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision: str = '263bed87114f'
|
||||||
|
down_revision: Union[str, Sequence[str], None] = '3147e421bc47'
|
||||||
|
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_foreign_key('fk_conversions_guest', 'conversions', 'conversion_guests', ['hotel_id', 'guest_id'], ['hotel_id', 'guest_id'])
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
"""Downgrade schema."""
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.drop_constraint('fk_conversions_guest', 'conversions', type_='foreignkey')
|
||||||
|
# ### end Alembic commands ###
|
||||||
@@ -622,12 +622,15 @@ class Conversion(Base):
|
|||||||
updated_at = Column(DateTime(timezone=True)) # When this record was last updated
|
updated_at = Column(DateTime(timezone=True)) # When this record was last updated
|
||||||
|
|
||||||
# Table constraints
|
# Table constraints
|
||||||
# Note: The relationship to ConversionGuest is handled via SQLAlchemy ORM
|
|
||||||
# by matching (hotel_id, guest_id) pairs, no DB-level FK constraint needed
|
|
||||||
__table_args__ = (
|
__table_args__ = (
|
||||||
UniqueConstraint(
|
UniqueConstraint(
|
||||||
"hotel_id", "pms_reservation_id", name="uq_conversion_hotel_reservation"
|
"hotel_id", "pms_reservation_id", name="uq_conversion_hotel_reservation"
|
||||||
),
|
),
|
||||||
|
ForeignKeyConstraint(
|
||||||
|
["hotel_id", "guest_id"],
|
||||||
|
["conversion_guests.hotel_id", "conversion_guests.guest_id"],
|
||||||
|
name="fk_conversions_guest",
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
# Relationships
|
# Relationships
|
||||||
|
|||||||
Reference in New Issue
Block a user