mirror of
https://github.com/joaovitoriasilva/endurain.git
synced 2026-01-06 22:43:54 -05:00
Add CASCADE ondelete to relevant foreign keys
Updated foreign key constraints in migration and model files to include ondelete="CASCADE" for idp_id, user_id, and token_family_id. This ensures related records are properly deleted when parent records are removed, improving data integrity and cleanup.
This commit is contained in:
@@ -94,10 +94,12 @@ def upgrade() -> None:
|
||||
sa.ForeignKeyConstraint(
|
||||
["idp_id"],
|
||||
["identity_providers.id"],
|
||||
ondelete="CASCADE",
|
||||
),
|
||||
sa.ForeignKeyConstraint(
|
||||
["user_id"],
|
||||
["users.id"],
|
||||
ondelete="CASCADE",
|
||||
),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
)
|
||||
@@ -240,6 +242,7 @@ def upgrade() -> None:
|
||||
sa.ForeignKeyConstraint(
|
||||
["token_family_id"],
|
||||
["users_sessions.token_family_id"],
|
||||
ondelete="CASCADE",
|
||||
),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
sa.UniqueConstraint("hashed_token"),
|
||||
|
||||
@@ -42,7 +42,7 @@ class OAuthState(Base):
|
||||
|
||||
idp_id = Column(
|
||||
Integer,
|
||||
ForeignKey("identity_providers.id"),
|
||||
ForeignKey("identity_providers.id", ondelete="CASCADE"),
|
||||
nullable=False,
|
||||
index=True,
|
||||
comment="Identity provider ID",
|
||||
@@ -50,7 +50,7 @@ class OAuthState(Base):
|
||||
|
||||
user_id = Column(
|
||||
Integer,
|
||||
ForeignKey("users.id"),
|
||||
ForeignKey("users.id", ondelete="CASCADE"),
|
||||
nullable=True,
|
||||
index=True,
|
||||
comment="User ID (for link mode)",
|
||||
|
||||
@@ -28,7 +28,7 @@ class RotatedRefreshToken(Base):
|
||||
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||
token_family_id = Column(
|
||||
String(36),
|
||||
ForeignKey("users_sessions.token_family_id"),
|
||||
ForeignKey("users_sessions.token_family_id", ondelete="CASCADE"),
|
||||
nullable=False,
|
||||
index=True,
|
||||
comment="UUID of the token family",
|
||||
|
||||
Reference in New Issue
Block a user