fix: remove ON CONFLICT clause after constraint removal
Migration 011 removed UNIQUE constraint (profile_id, date) to allow multiple rest days per date, but INSERT still used ON CONFLICT. Error: psycopg2.errors.InvalidColumnReference: there is no unique or exclusion constraint matching the ON CONFLICT specification Solution: Remove ON CONFLICT clause, use plain INSERT. Multiple entries per date now allowed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
6916e5b808
commit
f2e2aff17f
|
|
@ -93,15 +93,11 @@ def create_rest_day(
|
||||||
with get_db() as conn:
|
with get_db() as conn:
|
||||||
cur = get_cursor(conn)
|
cur = get_cursor(conn)
|
||||||
|
|
||||||
# Upsert by (profile_id, date)
|
# Insert (multiple entries per date allowed)
|
||||||
cur.execute(
|
cur.execute(
|
||||||
"""
|
"""
|
||||||
INSERT INTO rest_days (profile_id, date, rest_config, note, created_at)
|
INSERT INTO rest_days (profile_id, date, rest_config, note, created_at)
|
||||||
VALUES (%s, %s, %s, %s, CURRENT_TIMESTAMP)
|
VALUES (%s, %s, %s, %s, CURRENT_TIMESTAMP)
|
||||||
ON CONFLICT (profile_id, date)
|
|
||||||
DO UPDATE SET
|
|
||||||
rest_config = EXCLUDED.rest_config,
|
|
||||||
note = EXCLUDED.note
|
|
||||||
RETURNING id, profile_id, date, rest_config, note, created_at
|
RETURNING id, profile_id, date, rest_config, note, created_at
|
||||||
""",
|
""",
|
||||||
(pid, data.date, Json(config_dict), data.note)
|
(pid, data.date, Json(config_dict), data.note)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user