Give every year of a repeating period its own row

A repeating period was a single row that the planner expanded into one
window per year at read time, so no year had anywhere to differ from the
others. Editing one year rewrote them all, and removing a year in the
middle had to split the wish in two. Neither survives contact with the
thing this app is for: Easter moves, and the cheapest week is not the
same week every year.

Each year is now its own row, linked by a series id. Editing one year
touches one row; editing the series re-projects the rest from it.
Removing a year is one delete. The weekday snap is worked out once, when
the rows are made, and stored, so a row now says what it means rather
than being re-derived on every read. Recurrence stops being a stored
field and becomes what it always was in practice — an instruction at
create and update time; whether a period repeats is whether it belongs
to a series.

Migration 004 rebuilds the table and expands the existing rows, keeping
each original row as its first year so the days already planned against
it still point somewhere. A Feb 29 anchor recurring into a common year
used to raise out of the allocator; it clamps now.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ei7gCZzdd751uZtPzb1Pep
This commit is contained in:
2026-09-19 15:53:25 +02:00
parent c6593062e3
commit 6d92b87bf3
43 changed files with 2735 additions and 638 deletions
+3 -2
View File
@@ -96,8 +96,6 @@ CREATE TABLE IF NOT EXISTS leave_wish (
CHECK (window_end_day >= 1 AND window_end_day <= 31),
target_weeks INTEGER NOT NULL,
target_days INTEGER,
recurrence TEXT NOT NULL DEFAULT 'once'
CHECK (recurrence IN ('yearly','once')),
first_year INTEGER NOT NULL DEFAULT 2026,
last_year INTEGER,
priority INTEGER NOT NULL DEFAULT 1 CHECK (priority >= 1),
@@ -106,6 +104,7 @@ CREATE TABLE IF NOT EXISTS leave_wish (
parent_personal_data_uuid TEXT,
window_mode TEXT NOT NULL DEFAULT 'fixed'
CHECK (window_mode IN ('fixed','flexible')),
series_id TEXT,
wants_dubbeldag INTEGER NOT NULL DEFAULT 0,
created_at TIMESTAMP NOT NULL,
updated_at TIMESTAMP NOT NULL,
@@ -214,6 +213,8 @@ CREATE INDEX IF NOT EXISTS idx_leave_wish_child
ON leave_wish (child_id);
CREATE INDEX IF NOT EXISTS idx_leave_wish_parent
ON leave_wish (parent_personal_data_uuid);
CREATE INDEX IF NOT EXISTS idx_leave_wish_series
ON leave_wish (series_id);
CREATE INDEX IF NOT EXISTS idx_child_workspace_birth
ON child (workspace_id, birth_date);
CREATE INDEX IF NOT EXISTS idx_personal_data_workspace_deleted