feat(db): add external_calendars table and link to calendar events (migration v14)
Stores display name and color per synced Google/Apple calendar. calendar_events gains a calendar_ref_id FK for join-based name/color lookup.
This commit is contained in:
@@ -523,6 +523,27 @@ const MIGRATIONS = [
|
||||
CREATE INDEX IF NOT EXISTS idx_meals_recipe_id ON meals(recipe_id);
|
||||
`,
|
||||
},
|
||||
{
|
||||
version: 14,
|
||||
description: 'Externe Kalender-Metadaten (Name, Farbe) und Verknüpfung mit Events',
|
||||
up: `
|
||||
CREATE TABLE IF NOT EXISTS external_calendars (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
source TEXT NOT NULL CHECK(source IN ('google', 'apple')),
|
||||
external_id TEXT NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
color TEXT,
|
||||
UNIQUE(source, external_id)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_ext_cal_source ON external_calendars(source, external_id);
|
||||
|
||||
ALTER TABLE calendar_events ADD COLUMN calendar_ref_id INTEGER
|
||||
REFERENCES external_calendars(id) ON DELETE SET NULL;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_cal_events_ref ON calendar_events(calendar_ref_id);
|
||||
`,
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user