Add cascading delete to Gift and Guest relationships
Updated the `ondelete="CASCADE"` behavior for foreign key constraints in Alembic migrations and added cascading rules to related models in SQLAlchemy. These changes ensure proper cleanup of dependent records when a parent record is deleted.
This commit is contained in:
@@ -317,8 +317,8 @@ def upgrade() -> None:
|
||||
sa.Column('gift_id', sa.UUID(), nullable=False),
|
||||
sa.Column('reserved_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('notes', sa.String(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['gift_id'], ['gift_items.id'], ),
|
||||
sa.ForeignKeyConstraint(['guest_id'], ['guests.id'], ),
|
||||
sa.ForeignKeyConstraint(['gift_id'], ['gift_items.id'], ondelete="CASCADE"),
|
||||
sa.ForeignKeyConstraint(['guest_id'], ['guests.id'], ondelete="CASCADE"),
|
||||
sa.PrimaryKeyConstraint('guest_id', 'gift_id')
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
Reference in New Issue
Block a user