Link planned days to their wish, fix the age-4 cap, drop the planning goal
Three changes that together unblock treating a calendar period as one editable object. Migration 008 adds `planned_leave_day.wish_id` (nullable, ON DELETE SET NULL) so a persisted day knows which `leave_wish` produced it, `is_pinned` to mark a day the user hand-edited, and `leave_wish.target_days` so a period drawn on a calendar need not be a whole number of weeks. Apply-time identity still keys on day_type/is_dubbeldag only, so a wish_id-only difference is a metadata update rather than a collision. The age-4 savable ceiling was applying the per-child figure of 96 to each parent's pool, modelling a two-parent family as able to save 192 days past the child's fourth birthday. `resolve_age4_savable_cap` is now the single place that decides 48 (couple with two parents) versus 96 (everyone else), and both AnalyticsService and the allocator read it. Migration 009 drops `workspace.planning_goal` and `leave_wish.goal_override`. The allocator's tier-3 policy collapses to one rule; `salary_type` still branches, since that reflects what a vacation day actually costs a parent rather than a user preference.
This commit is contained in:
@@ -19,8 +19,6 @@ _FULL_SCHEMA = """
|
||||
CREATE TABLE IF NOT EXISTS workspace (
|
||||
id TEXT PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
planning_goal TEXT NOT NULL DEFAULT 'balanced'
|
||||
CHECK (planning_goal IN ('max_time','max_money','balanced')),
|
||||
planning_mode TEXT NOT NULL DEFAULT 'solo'
|
||||
CHECK (planning_mode IN ('solo','couple')),
|
||||
created_at TIMESTAMP NOT NULL
|
||||
@@ -91,6 +89,7 @@ CREATE TABLE IF NOT EXISTS leave_wish (
|
||||
window_end_day INTEGER NOT NULL DEFAULT 1
|
||||
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,
|
||||
@@ -99,8 +98,6 @@ CREATE TABLE IF NOT EXISTS leave_wish (
|
||||
parent_mode TEXT NOT NULL DEFAULT 'either'
|
||||
CHECK (parent_mode IN ('either','both','specific')),
|
||||
parent_personal_data_uuid TEXT,
|
||||
goal_override TEXT
|
||||
CHECK (goal_override IS NULL OR goal_override IN ('max_time','max_money','balanced')),
|
||||
window_mode TEXT NOT NULL DEFAULT 'fixed'
|
||||
CHECK (window_mode IN ('fixed','flexible')),
|
||||
created_at TIMESTAMP NOT NULL,
|
||||
@@ -154,12 +151,15 @@ CREATE TABLE IF NOT EXISTS planned_leave_day (
|
||||
date DATE NOT NULL,
|
||||
day_type TEXT NOT NULL CHECK (day_type IN ('sjukpenning','lagsta','vacation')),
|
||||
is_dubbeldag INTEGER NOT NULL DEFAULT 0,
|
||||
wish_id TEXT,
|
||||
is_pinned INTEGER NOT NULL DEFAULT 0,
|
||||
created_at TIMESTAMP NOT NULL,
|
||||
updated_at TIMESTAMP NOT NULL,
|
||||
UNIQUE(workspace_id, child_id, date, parent_personal_data_uuid),
|
||||
FOREIGN KEY (workspace_id) REFERENCES workspace(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (child_id) REFERENCES child(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (parent_personal_data_uuid) REFERENCES personal_data(uuid) ON DELETE CASCADE
|
||||
FOREIGN KEY (parent_personal_data_uuid) REFERENCES personal_data(uuid) ON DELETE CASCADE,
|
||||
FOREIGN KEY (wish_id) REFERENCES leave_wish(id) ON DELETE SET NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS day_override (
|
||||
|
||||
Reference in New Issue
Block a user