Explain the "why"

All foreign keys use `RESTRICT`,
so cascades can never change the data of finished stages.
This commit is contained in:
Alexander Hess 2026-12-04 13:05:04 +01:00
commit 8a96e78533
Signed by: alexander
GPG key ID: B46EDB4DFC26805D
10 changed files with 22 additions and 0 deletions

View file

@ -76,6 +76,8 @@ class Address(meta.Base):
# Constraints
__table_args__ = (
# All foreign keys `RESTRICT`
# because data of finished stages must never change through cascades
sa.ForeignKeyConstraint(
["primary_id"],
["addresses.id"],

View file

@ -71,6 +71,9 @@ class Path(meta.Base):
# Constraints
__table_args__ = (
# All foreign keys `RESTRICT`
# because data of finished stages must never change through cascades
#
# The two `Address` objects must be in the same `.city`
sa.ForeignKeyConstraint(
["first_address_id", "city_id"],

View file

@ -39,6 +39,9 @@ class AddressPixelAssociation(meta.Base):
# Constraints
__table_args__ = (
# All foreign keys `RESTRICT`
# because data of finished stages must never change through cascades
#
# An `Address` can only be on a `Grid` ...
sa.ForeignKeyConstraint(
["address_id", "city_id"],

View file

@ -82,6 +82,8 @@ class Forecast(meta.Base):
# Constraints
__table_args__ = (
# All foreign keys `RESTRICT`
# because data of finished stages must never change through cascades
sa.ForeignKeyConstraint(
["pixel_id"],
["pixels.id"],

View file

@ -36,6 +36,8 @@ class Grid(meta.Base):
# Constraints
__table_args__ = (
# All foreign keys `RESTRICT`
# because data of finished stages must never change through cascades
sa.ForeignKeyConstraint(
["city_id"],
["cities.id"],

View file

@ -243,6 +243,8 @@ class Order(meta.Base):
# Constraints
__table_args__ = (
# All foreign keys `RESTRICT`
# because data of finished stages must never change through cascades
sa.ForeignKeyConstraint(
["customer_id"],
["customers.id"],

View file

@ -49,6 +49,8 @@ class Pixel(meta.Base):
# Constraints
__table_args__ = (
# All foreign keys `RESTRICT`
# because data of finished stages must never change through cascades
sa.ForeignKeyConstraint(
["grid_id"],
["grids.id"],

View file

@ -118,6 +118,8 @@ class ReplayedOrder(meta.Base):
# Constraints
__table_args__ = (
# All foreign keys `RESTRICT`
# because data of finished stages must never change through cascades
sa.ForeignKeyConstraint(
["simulation_id"],
["replay_simulations.id"],

View file

@ -39,6 +39,8 @@ class ReplaySimulation(meta.Base):
# Constraints
__table_args__ = (
# All foreign keys `RESTRICT`
# because data of finished stages must never change through cascades
sa.ForeignKeyConstraint(
["city_id"],
["cities.id"],

View file

@ -48,6 +48,8 @@ class Restaurant(meta.Base):
# Constraints
__table_args__ = (
# All foreign keys `RESTRICT`
# because data of finished stages must never change through cascades
sa.ForeignKeyConstraint(
["address_id"],
["addresses.id"],