mirror of
https://github.com/Xevion/linkpulse.git
synced 2025-12-06 15:15:34 -06:00
correctly add names to table constraints, fix inverted constraint for session_last_used_created
This commit is contained in:
@@ -48,7 +48,7 @@ def migrate(migrator: Migrator, database: pw.Database, *, fake=False):
|
|||||||
migrator.add_constraint(
|
migrator.add_constraint(
|
||||||
"session",
|
"session",
|
||||||
"session_last_used_created_at",
|
"session_last_used_created_at",
|
||||||
pw.Check("last_used IS NULL OR last_used <= created_at"),
|
pw.Check("last_used IS NULL OR last_used >= created_at"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -70,9 +70,12 @@ class Session(BaseModel):
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
constraints = [
|
constraints = [
|
||||||
Check("LENGTH(token) = 32"),
|
Check("LENGTH(token) = 32", name="session_token_length"),
|
||||||
Check("expiry > created_at"),
|
Check("expiry > created_at", name="session_expiry_created_at"),
|
||||||
Check("last_used IS NULL OR last_used <= created_at"),
|
Check(
|
||||||
|
"last_used IS NULL OR last_used >= created_at",
|
||||||
|
name="session_last_used_created_at",
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|||||||
Reference in New Issue
Block a user