Your favorite shift management application!
feat: Archive and restore shift presets (#216)
panteL55e998d89286
diff --git a/app/api/presets/[id]/route.ts b/app/api/presets/[id]/route.tsindex 4e59273..adc6a24 100644--- a/app/api/presets/[id]/route.ts+++ b/app/api/presets/[id]/route.ts@@ -90,6 +90,7 @@ export async function PATCH(defaultSignupCapacity,segments: requestedSegments,customFields,+ archived,} = body;// groupName: undefined leaves it unchanged, null explicitly clears it,@@ -143,6 +144,26 @@ export async function PATCH();}+ // An archive toggle is a request of its own and carries no other fields:+ // the generic update below rewrites every shift stamped from this preset,+ // which archiving must never do.+ if (archived !== undefined) {+ if (typeof archived !== "boolean") {+ return NextResponse.json({ error: "Invalid archived" }, { status: 400 });+ }+ const [toggled] = await db+ .update(shiftPresets)+ .set({ archivedAt: archived ? new Date() : null, updatedAt: new Date() })+ .where(eq(shiftPresets.id, id))+ .returning();+ const [withSegs] = await withPresetSegments([toggled]);+ const [result] = await withPresetCustomFields(+ [withSegs],+ await getCalendarCustomFields(existingPreset.calendarId)+ );+ return NextResponse.json(result);+ }+const nextIsAllDay = isAllDay !== undefined ? isAllDay : existingPreset.isAllDay;// Mirrors the shift PUT handler: segments (and the normalized primary range) are only// ever written when split shifts is enabled, otherwise a round-tripped `segments: []`diff --git a/app/api/shifts/route.ts b/app/api/shifts/route.tsindex 7453bd0..cb7269d 100644--- a/app/api/shifts/route.ts+++ b/app/api/shifts/route.ts@@ -244,6 +244,12 @@ export async function POST(request: Request) {{ status: 404 });}+ if (preset.archivedAt) {+ return NextResponse.json(+ { error: "Preset is archived" },+ { status: 400 }+ );+ }const [presetWithFields] = await withPresetCustomFields([preset],customFieldDefinitions@@ -312,6 +318,12 @@ export async function POST(request: Request) {{ status: 404 });}+ if (preset.archivedAt) {+ return NextResponse.json(+ { error: "Preset is archived" },+ { status: 400 }+ );+ }insertValues = {title: preset.title,startTime: preset.isAllDay ? "00:00" : preset.startTime,diff --git a/app/page.tsx b/app/page.tsxindex d726e61..9251628 100644--- a/app/page.tsx+++ b/app/page.tsx@@ -35,7 +35,7 @@ import { ShiftFormData } from "@/components/shift-sheet";import { getCalendarDays, getMonthDays, getWeekDays } from "@/lib/calendar-utils";import { formatDateToLocal, parseLocalDate } from "@/lib/date-utils";import { findNotesForDate } from "@/lib/event-utils";-import { DayLayoutOptions } from "@/lib/shift-display";+import { activePresets, DayLayoutOptions } from "@/lib/shift-display";import { CalendarViewSettings } from "@/lib/view-settings";function toDayLayout(view: CalendarViewSettings): DayLayoutOptions {@@ -331,7 +331,8 @@ function HomeContent() {// The armed presets are page state that outlives the stamp bar: it survives a// calendar switch, going offline and the personal toggle, none of which render// the dock. Derived here so a day click can never stamp without it on screen.- const presetIdSet = new Set(presets.map((p) => p.id));+ // Archived presets drop out of the set, so one archived while armed stops stamping.+ const presetIdSet = new Set(activePresets(presets).map((p) => p.id));const armedPresetIds =canStampPreset && isOnline && calendarView.showStampBar? selectedPresetIds.filter((id) => presetIdSet.has(id))diff --git a/components/preset-list.tsx b/components/preset-list.tsxindex bf90ca4..1f6b8df 100644--- a/components/preset-list.tsx+++ b/components/preset-list.tsx@@ -1,6 +1,6 @@"use client";-import { useMemo } from "react";+import { useMemo, type ReactNode } from "react";import { useTranslations } from "next-intl";import {DndContext,@@ -19,14 +19,14 @@ import {verticalListSortingStrategy,} from "@dnd-kit/sortable";import { CSS } from "@dnd-kit/utilities";-import { Copy, GripVertical, Pencil, Tag, Trash2 } from "lucide-react";+import { Archive, ArchiveRestore, Copy, GripVertical, Pencil, Tag, Trash2 } from "lucide-react";import { ShiftPreset } from "@/lib/db/schema";import { getShiftCode, groupPresetsByName, presetTime, shiftVars } from "@/lib/shift-display";import { ListRow, Pill, RowIconButton, SectionLabel } from "@/components/form-kit";import { cn } from "@/lib/utils";-interface PresetRowActions {- /** Per-preset Own/Any check — edit/delete depend on who created that preset. */+export interface PresetRowActions {+ /** Per-preset Own/Any check — edit/delete/archive depend on who created that preset. */canEdit: (preset: ShiftPreset) => boolean;/** Cloning creates a new preset, so it's gated calendar-wide, not per-row. */canClone: boolean;@@ -35,66 +35,49 @@ interface PresetRowActions {editingId: string | null;deletingId: string | null;cloningId: string | null;+ archivingId: string | null;onEdit: (preset: ShiftPreset) => void;onClone: (preset: ShiftPreset) => void;onDelete: (preset: ShiftPreset) => void;+ onArchive: (preset: ShiftPreset, archived: boolean) => void;}-interface SortablePresetRowProps extends PresetRowActions {+interface PresetRowProps extends PresetRowActions {preset: ShiftPreset;- draggable: boolean;+ /** Rendered as the leading grip; omitted when the row can't be dragged. */+ dragHandle?: ReactNode;}-function SortablePresetRow({+export function PresetRow({preset,- draggable,+ dragHandle,canEdit,canClone,editingId,deletingId,cloningId,+ archivingId,onEdit,onClone,onDelete,-}: SortablePresetRowProps) {+ onArchive,+}: PresetRowProps) {const t = useTranslations();- const {- attributes,- listeners,- setNodeRef,- setActivatorNodeRef,- transform,- transition,- isDragging,- } = useSortable({ id: preset.id, disabled: !draggable });- const busy = deletingId === preset.id || cloningId === preset.id;+ const busy =+ deletingId === preset.id || cloningId === preset.id || archivingId === preset.id;const editable = canEdit(preset);+ const archived = preset.archivedAt !== null;return (- <div- ref={setNodeRef}- style={{- transform: CSS.Transform.toString(transform),- transition: isDragging ? undefined : transition,- }}- className={cn("relative", isDragging && "z-10 opacity-60")}- ><ListRowhighlighted={editingId === preset.id}- className={cn("gap-2.5 py-2.5 pr-1.5", draggable ? "pl-1.5" : "pl-3.5")}- >- {draggable && (- <button- ref={setActivatorNodeRef}- type="button"- aria-label={t("presetSheet.dragHandle")}- className="-my-1 flex h-8 w-6 shrink-0 cursor-grab touch-none items-center justify-center rounded-md text-fg-tertiary transition-colors hover:bg-surface-sunken active:cursor-grabbing"- {...attributes}- {...listeners}- >- <GripVertical className="size-4" />- </button>+ className={cn(+ "gap-2.5 py-2.5 pr-1.5",+ dragHandle ? "pl-1.5" : "pl-3.5",+ archived && "opacity-70")}+ >+ {dragHandle}<spanclassName="shift-solid flex size-[22px] shrink-0 items-center justify-center rounded-[6px] text-[11px] font-bold"style={shiftVars(preset.color)}@@ -109,6 +92,7 @@ function SortablePresetRow({<span className="font-mono text-[12px] text-fg-tertiary">{presetTime(preset, t("presetSheet.allDayShort"))}</span>+ {archived && <Pill tone="warning">{t("preset.archived")}</Pill>}{preset.isSecondary && <Pill>{t("preset.secondary")}</Pill>}{preset.hideFromStats && (<Pill tone="warning">{t("presetSheet.notInStats")}</Pill>@@ -117,7 +101,7 @@ function SortablePresetRow({</div>{(canClone || editable) && (<>- {canClone && (+ {canClone && !archived && (<RowIconButtonicon={Copy}label={t("common.copy")}@@ -125,7 +109,7 @@ function SortablePresetRow({disabled={busy}/>)}- {editable && (+ {editable && !archived && (<RowIconButtonicon={Pencil}label={t("preset.edit")}@@ -133,6 +117,14 @@ function SortablePresetRow({disabled={busy}/>)}+ {editable && (+ <RowIconButton+ icon={archived ? ArchiveRestore : Archive}+ label={archived ? t("preset.restore") : t("preset.archive")}+ onClick={() => onArchive(preset, !archived)}+ disabled={busy}+ />+ )}{editable && (<RowIconButtonicon={Trash2}@@ -145,6 +137,53 @@ function SortablePresetRow({</>)}</ListRow>+ );+}++interface SortablePresetRowProps extends PresetRowActions {+ preset: ShiftPreset;+ draggable: boolean;+}++function SortablePresetRow({ preset, draggable, ...actions }: SortablePresetRowProps) {+ const t = useTranslations();+ const {+ attributes,+ listeners,+ setNodeRef,+ setActivatorNodeRef,+ transform,+ transition,+ isDragging,+ } = useSortable({ id: preset.id, disabled: !draggable });++ return (+ <div+ ref={setNodeRef}+ style={{+ transform: CSS.Transform.toString(transform),+ transition: isDragging ? undefined : transition,+ }}+ className={cn("relative", isDragging && "z-10 opacity-60")}+ >+ <PresetRow+ preset={preset}+ dragHandle={+ draggable ? (+ <button+ ref={setActivatorNodeRef}+ type="button"+ aria-label={t("presetSheet.dragHandle")}+ className="-my-1 flex h-8 w-6 shrink-0 cursor-grab touch-none items-center justify-center rounded-md text-fg-tertiary transition-colors hover:bg-surface-sunken active:cursor-grabbing"+ {...attributes}+ {...listeners}+ >+ <GripVertical className="size-4" />+ </button>+ ) : undefined+ }+ {...actions}+ /></div>);}@@ -241,3 +280,21 @@ export function PresetSection({ label, presets, onReorder, ...actions }: PresetS</section>);}++/** Archived presets: a flat, non-draggable list — order only matters for the stamp bar. */+export function ArchivedPresetSection({+ label,+ presets,+ ...actions+}: PresetRowActions & { label: string; presets: ShiftPreset[] }) {+ return (+ <section>+ <SectionLabel>{label}</SectionLabel>+ <div className="flex flex-col gap-2">+ {presets.map((preset) => (+ <PresetRow key={preset.id} preset={preset} {...actions} />+ ))}+ </div>+ </section>+ );+}diff --git a/components/preset-manage-sheet.tsx b/components/preset-manage-sheet.tsxindex 2299a33..b760eee 100644--- a/components/preset-manage-sheet.tsx+++ b/components/preset-manage-sheet.tsx@@ -2,12 +2,12 @@import { useId, useMemo, useRef, useState } from "react";import { useTranslations } from "next-intl";-import { Loader2 } from "lucide-react";+import { ChevronDown, ChevronUp, Loader2 } from "lucide-react";import { Button } from "@/components/ui/button";import { ConfirmationDialog } from "@/components/ui/confirmation-dialog";import { PanelBody, PanelDialog, PanelFooter } from "@/components/panel-dialog";import { ReadOnlyBanner } from "@/components/read-only-banner";-import { PresetSection } from "@/components/preset-list";+import { ArchivedPresetSection, PresetSection } from "@/components/preset-list";import {EMPTY_PRESET_FORM,PresetFormCard,@@ -15,7 +15,7 @@ import {samePresetForm,} from "@/components/preset-form";import { ShiftPreset } from "@/lib/db/schema";-import { groupPresetsByName } from "@/lib/shift-display";+import { activePresets, groupPresetsByName } from "@/lib/shift-display";import { usePresets, type PresetFormData } from "@/hooks/usePresets";import { useCalendarPermission } from "@/hooks/useCalendarPermission";import { useCalendars } from "@/hooks/useCalendars";@@ -52,8 +52,15 @@ export function PresetsPanel({// Banner-level "no preset capability at all" — individual actions still gate themselves.const isReadOnly =readOnly || (!permission.can("createPreset") && !permission.can("manageOwnPresets"));- const { presets, loading, createPreset, updatePreset, deletePreset, reorderPresets } =- usePresets(calendarId);+ const {+ presets,+ loading,+ createPreset,+ updatePreset,+ deletePreset,+ archivePreset,+ reorderPresets,+ } = usePresets(calendarId);const { calendars } = useCalendars();const splitShiftsEnabled = calendars.find((c) => c.id === calendarId)?.splitShiftsEnabled ?? false;@@ -67,6 +74,8 @@ export function PresetsPanel({const [isSaving, setIsSaving] = useState(false);const [deletingId, setDeletingId] = useState<string | null>(null);const [cloningId, setCloningId] = useState<string | null>(null);+ const [archivingId, setArchivingId] = useState<string | null>(null);+ const [archiveOpen, setArchiveOpen] = useState(false);const [deleteTarget, setDeleteTarget] = useState<ShiftPreset | null>(null);const [pendingDiscard, setPendingDiscard] = useState<(() => void) | null>(null);// Holds the dropped order until the reorder request settles, so rows don't snap back.@@ -90,10 +99,12 @@ export function PresetsPanel({const last = pendingOrder.length;return [...presets].sort((a, b) => (rank.get(a.id) ?? last) - (rank.get(b.id) ?? last));}, [presets, pendingOrder]);- const primary = ordered.filter((p) => !p.isSecondary);- const secondary = ordered.filter((p) => p.isSecondary);+ const active = activePresets(ordered);+ const archived = ordered.filter((p) => p.archivedAt);+ const primary = active.filter((p) => !p.isSecondary);+ const secondary = active.filter((p) => p.isSecondary);const existingGroupNames = useMemo(- () => groupPresetsByName(presets).groups.map((g) => g.name),+ () => groupPresetsByName(activePresets(presets)).groups.map((g) => g.name),[presets]);@@ -184,6 +195,21 @@ export function PresetsPanel({else guardDiscard(onClose);};+ const handleArchive = async (preset: ShiftPreset, nextArchived: boolean) => {+ if (archivingId) return;+ setArchivingId(preset.id);+ try {+ const success = await archivePreset(preset.id, nextArchived);+ if (success) {+ if (nextArchived && editingPreset?.id === preset.id) resetForm();+ if (nextArchived) setArchiveOpen(true);+ onPresetsChange?.();+ }+ } finally {+ setArchivingId(null);+ }+ };+const rowActions = {canEdit: canEditPreset,canClone: canCreate,@@ -191,9 +217,11 @@ export function PresetsPanel({editingId: editingPreset?.id ?? null,deletingId,cloningId,+ archivingId,onEdit: startEdit,onClone: clonePreset,onDelete: setDeleteTarget,+ onArchive: handleArchive,};return (@@ -229,6 +257,34 @@ export function PresetsPanel({/>)}+ {archived.length > 0 && (+ <div>+ <button+ type="button"+ onClick={() => setArchiveOpen((current) => !current)}+ aria-expanded={archiveOpen}+ className="flex w-full items-center gap-1.5 rounded-[9px] px-1 py-1.5 text-[12px] font-semibold uppercase tracking-[0.06em] text-fg-tertiary transition-colors hover:text-fg-secondary"+ >+ {t("presetSheet.archivedSection")}+ <span className="font-mono normal-case tracking-normal opacity-70">+ ({archived.length})+ </span>+ {archiveOpen ? (+ <ChevronUp className="size-3.5" />+ ) : (+ <ChevronDown className="size-3.5" />+ )}+ </button>+ {archiveOpen && (+ <ArchivedPresetSection+ label={t("presetSheet.archivedHint")}+ presets={archived}+ {...rowActions}+ />+ )}+ </div>+ )}+{formVisible && (<PresetFormCardformId={formId}diff --git a/components/preset-select.tsx b/components/preset-select.tsxindex 5ed607f..8c8ebaf 100644--- a/components/preset-select.tsx+++ b/components/preset-select.tsx@@ -49,6 +49,11 @@ export function PresetSelect({ presets, value, onPresetSelect, onClear }: Presetstyle={shiftVars(preset.color)}/>{preset.title}+ {preset.archivedAt && (+ <span className="text-[11px] font-normal opacity-70">+ {t("preset.archived")}+ </span>+ )}</button>);})}diff --git a/components/stamp-dock.tsx b/components/stamp-dock.tsxindex 5bd0034..14faeda 100644--- a/components/stamp-dock.tsx+++ b/components/stamp-dock.tsx@@ -15,11 +15,18 @@ import {} from "lucide-react";import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";import { ShiftPreset } from "@/lib/db/schema";-import { getShiftCode, groupPresetsByName, presetTime, shiftVars } from "@/lib/shift-display";+import {+ activePresets,+ getShiftCode,+ groupPresetsByName,+ presetTime,+ shiftVars,+} from "@/lib/shift-display";import { cn, isMultiSelectClick } from "@/lib/utils";+/** Archived presets are dropped here, which covers the stamp bar, the mobile bar and compare mode at once. */export function splitStampPresets(presets: ShiftPreset[]) {- const { ungrouped, groups } = groupPresetsByName(presets);+ const { ungrouped, groups } = groupPresetsByName(activePresets(presets));const ordered = [...ungrouped, ...groups.flatMap((group) => group.items)];return {primary: ordered.filter((p) => !p.isSecondary),@@ -313,7 +320,7 @@ export function MultiSelectToggle({export function StampDock({ presets, selectedPresetIds, onSelectPreset, onManage }: StampProps) {const t = useTranslations();const { primary, secondary } = splitStampPresets(presets);- const groups = useMemo(() => groupPresetsByName(presets).groups, [presets]);+ const groups = useMemo(() => groupPresetsByName(activePresets(presets)).groups, [presets]);const [multiMode, setMultiMode] = useState(false);const activeIds = new Set(selectedPresetIds);@@ -327,7 +334,7 @@ export function StampDock({ presets, selectedPresetIds, onSelectPreset, onManage{t("calendarView.stamp")}</span><div className="flex min-w-0 items-center gap-1.5 overflow-x-auto [scrollbar-width:none]">- {presets.length === 0 && (+ {primary.length === 0 && secondary.length === 0 && (<buttontype="button"onClick={onManage}@@ -432,10 +439,10 @@ export function MobilePresetBar({const [moreOpen, setMoreOpen] = useState(false);const [multiMode, setMultiMode] = useState(false);const { primary, secondary } = splitStampPresets(presets);- const groups = useMemo(() => groupPresetsByName(presets).groups, [presets]);+ const groups = useMemo(() => groupPresetsByName(activePresets(presets)).groups, [presets]);const activeIds = new Set(selectedPresetIds);- const activePresets = presets.filter((p) => activeIds.has(p.id));- const activeSecondary = activePresets.filter((p) => p.isSecondary);+ const armed = presets.filter((p) => activeIds.has(p.id));+ const activeSecondary = armed.filter((p) => p.isSecondary);// Otherwise the list would pop up by itself once nothing secondary is armed anymoreif (moreOpen && secondary.length === 0) setMoreOpen(false);@@ -459,7 +466,7 @@ export function MobilePresetBar({)}<div className="flex items-center gap-2 py-2.5 pl-3 pr-3"><div className="flex min-w-0 flex-1 gap-2 overflow-x-auto pb-0.5 [scrollbar-width:thin]">- {presets.length === 0 && (+ {primary.length === 0 && secondary.length === 0 && (<buttontype="button"onClick={onManage}@@ -546,13 +553,13 @@ export function MobilePresetBar({</div><MultiSelectToggle variant="bar" active={multiMode} onClick={() => setMultiMode((m) => !m)} /></div>- {activePresets.length > 0 && (+ {armed.length > 0 && (<div className="flex items-center gap-2 px-4 pb-2.5 text-[12px] leading-snug text-fg-secondary"><Hand className="size-4 shrink-0" /><span className="min-w-0 flex-1">- {activePresets.length === 1- ? t("calendarView.stampHint", { title: activePresets[0].title })- : t("calendarView.stampHintMulti", { count: activePresets.length })}+ {armed.length === 1+ ? t("calendarView.stampHint", { title: armed[0].title })+ : t("calendarView.stampHintMulti", { count: armed.length })}</span><buttontype="button"diff --git a/drizzle/0028_dapper_karnak.sql b/drizzle/0028_dapper_karnak.sqlnew file mode 100644index 0000000..d689f80--- /dev/null+++ b/drizzle/0028_dapper_karnak.sql@@ -0,0 +1 @@+ALTER TABLE `shift_presets` ADD `archived_at` integer;\ No newline at end of filediff --git a/drizzle/meta/0028_snapshot.json b/drizzle/meta/0028_snapshot.jsonnew file mode 100644index 0000000..56ccb18--- /dev/null+++ b/drizzle/meta/0028_snapshot.json@@ -0,0 +1,2519 @@+{+ "version": "6",+ "dialect": "sqlite",+ "id": "c88eee0a-2374-4827-8143-61807b963512",+ "prevId": "114ad1a7-59d2-4003-8924-65546bb35bba",+ "tables": {+ "account": {+ "name": "account",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "account_id": {+ "name": "account_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "provider_id": {+ "name": "provider_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "access_token": {+ "name": "access_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "refresh_token": {+ "name": "refresh_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "id_token": {+ "name": "id_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "access_token_expires_at": {+ "name": "access_token_expires_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "refresh_token_expires_at": {+ "name": "refresh_token_expires_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "scope": {+ "name": "scope",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "password": {+ "name": "password",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(cast(unixepoch('subsecond') * 1000 as integer))"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "account_userId_idx": {+ "name": "account_userId_idx",+ "columns": [+ "user_id"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "account_user_id_user_id_fk": {+ "name": "account_user_id_user_id_fk",+ "tableFrom": "account",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "audit_logs": {+ "name": "audit_logs",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "action": {+ "name": "action",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "resource_type": {+ "name": "resource_type",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "resource_id": {+ "name": "resource_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "metadata": {+ "name": "metadata",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "ip_address": {+ "name": "ip_address",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "user_agent": {+ "name": "user_agent",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "severity": {+ "name": "severity",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'info'"+ },+ "is_user_visible": {+ "name": "is_user_visible",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "timestamp": {+ "name": "timestamp",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ }+ },+ "indexes": {+ "audit_logs_userId_timestamp_idx": {+ "name": "audit_logs_userId_timestamp_idx",+ "columns": [+ "user_id",+ "timestamp"+ ],+ "isUnique": false+ },+ "audit_logs_action_timestamp_idx": {+ "name": "audit_logs_action_timestamp_idx",+ "columns": [+ "action",+ "timestamp"+ ],+ "isUnique": false+ },+ "audit_logs_userVisible_userId_timestamp_idx": {+ "name": "audit_logs_userVisible_userId_timestamp_idx",+ "columns": [+ "is_user_visible",+ "user_id",+ "timestamp"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "audit_logs_user_id_user_id_fk": {+ "name": "audit_logs_user_id_user_id_fk",+ "tableFrom": "audit_logs",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "calendar_access_tokens": {+ "name": "calendar_access_tokens",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "calendar_id": {+ "name": "calendar_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "token": {+ "name": "token",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "bundle_id": {+ "name": "bundle_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "expires_at": {+ "name": "expires_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "created_by": {+ "name": "created_by",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ },+ "last_used_at": {+ "name": "last_used_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "usage_count": {+ "name": "usage_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "is_active": {+ "name": "is_active",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": true+ }+ },+ "indexes": {+ "calendar_access_tokens_token_unique": {+ "name": "calendar_access_tokens_token_unique",+ "columns": [+ "token"+ ],+ "isUnique": true+ },+ "calendar_access_tokens_token_idx": {+ "name": "calendar_access_tokens_token_idx",+ "columns": [+ "token"+ ],+ "isUnique": false+ },+ "calendar_access_tokens_calendarId_isActive_idx": {+ "name": "calendar_access_tokens_calendarId_isActive_idx",+ "columns": [+ "calendar_id",+ "is_active"+ ],+ "isUnique": false+ },+ "calendar_access_tokens_createdBy_idx": {+ "name": "calendar_access_tokens_createdBy_idx",+ "columns": [+ "created_by"+ ],+ "isUnique": false+ },+ "calendar_access_tokens_bundleId_idx": {+ "name": "calendar_access_tokens_bundleId_idx",+ "columns": [+ "bundle_id"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "calendar_access_tokens_calendar_id_calendars_id_fk": {+ "name": "calendar_access_tokens_calendar_id_calendars_id_fk",+ "tableFrom": "calendar_access_tokens",+ "tableTo": "calendars",+ "columnsFrom": [+ "calendar_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "calendar_access_tokens_bundle_id_calendar_permission_bundles_id_fk": {+ "name": "calendar_access_tokens_bundle_id_calendar_permission_bundles_id_fk",+ "tableFrom": "calendar_access_tokens",+ "tableTo": "calendar_permission_bundles",+ "columnsFrom": [+ "bundle_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "restrict",+ "onUpdate": "no action"+ },+ "calendar_access_tokens_created_by_user_id_fk": {+ "name": "calendar_access_tokens_created_by_user_id_fk",+ "tableFrom": "calendar_access_tokens",+ "tableTo": "user",+ "columnsFrom": [+ "created_by"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "calendar_custom_fields": {+ "name": "calendar_custom_fields",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "calendar_id": {+ "name": "calendar_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "key": {+ "name": "key",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "label": {+ "name": "label",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "options": {+ "name": "options",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "required": {+ "name": "required",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "show_in_calendar": {+ "name": "show_in_calendar",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "order": {+ "name": "order",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "created_by": {+ "name": "created_by",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ }+ },+ "indexes": {+ "calendar_custom_fields_calendarId_idx": {+ "name": "calendar_custom_fields_calendarId_idx",+ "columns": [+ "calendar_id"+ ],+ "isUnique": false+ },+ "calendar_custom_fields_calendarId_key_idx": {+ "name": "calendar_custom_fields_calendarId_key_idx",+ "columns": [+ "calendar_id",+ "key"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {+ "calendar_custom_fields_calendar_id_calendars_id_fk": {+ "name": "calendar_custom_fields_calendar_id_calendars_id_fk",+ "tableFrom": "calendar_custom_fields",+ "tableTo": "calendars",+ "columnsFrom": [+ "calendar_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "calendar_custom_fields_created_by_user_id_fk": {+ "name": "calendar_custom_fields_created_by_user_id_fk",+ "tableFrom": "calendar_custom_fields",+ "tableTo": "user",+ "columnsFrom": [+ "created_by"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "calendar_notes": {+ "name": "calendar_notes",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "calendar_id": {+ "name": "calendar_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "date": {+ "name": "date",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "note": {+ "name": "note",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'note'"+ },+ "color": {+ "name": "color",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "recurring_pattern": {+ "name": "recurring_pattern",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'none'"+ },+ "recurring_interval": {+ "name": "recurring_interval",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "created_by": {+ "name": "created_by",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "calendar_notes_calendar_id_calendars_id_fk": {+ "name": "calendar_notes_calendar_id_calendars_id_fk",+ "tableFrom": "calendar_notes",+ "tableTo": "calendars",+ "columnsFrom": [+ "calendar_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "calendar_notes_created_by_user_id_fk": {+ "name": "calendar_notes_created_by_user_id_fk",+ "tableFrom": "calendar_notes",+ "tableTo": "user",+ "columnsFrom": [+ "created_by"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "calendar_permission_bundles": {+ "name": "calendar_permission_bundles",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "calendar_id": {+ "name": "calendar_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "seed_key": {+ "name": "seed_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "capabilities": {+ "name": "capabilities",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ }+ },+ "indexes": {+ "calendar_permission_bundles_calendarId_idx": {+ "name": "calendar_permission_bundles_calendarId_idx",+ "columns": [+ "calendar_id"+ ],+ "isUnique": false+ },+ "calendar_permission_bundles_calendarId_seedKey_idx": {+ "name": "calendar_permission_bundles_calendarId_seedKey_idx",+ "columns": [+ "calendar_id",+ "seed_key"+ ],+ "isUnique": true,+ "where": "\"calendar_permission_bundles\".\"seed_key\" is not null"+ }+ },+ "foreignKeys": {+ "calendar_permission_bundles_calendar_id_calendars_id_fk": {+ "name": "calendar_permission_bundles_calendar_id_calendars_id_fk",+ "tableFrom": "calendar_permission_bundles",+ "tableTo": "calendars",+ "columnsFrom": [+ "calendar_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "calendar_shares": {+ "name": "calendar_shares",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "calendar_id": {+ "name": "calendar_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "bundle_id": {+ "name": "bundle_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "shared_by": {+ "name": "shared_by",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ }+ },+ "indexes": {+ "calendar_shares_calendarId_idx": {+ "name": "calendar_shares_calendarId_idx",+ "columns": [+ "calendar_id"+ ],+ "isUnique": false+ },+ "calendar_shares_userId_idx": {+ "name": "calendar_shares_userId_idx",+ "columns": [+ "user_id"+ ],+ "isUnique": false+ },+ "calendar_shares_bundleId_idx": {+ "name": "calendar_shares_bundleId_idx",+ "columns": [+ "bundle_id"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "calendar_shares_calendar_id_calendars_id_fk": {+ "name": "calendar_shares_calendar_id_calendars_id_fk",+ "tableFrom": "calendar_shares",+ "tableTo": "calendars",+ "columnsFrom": [+ "calendar_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "calendar_shares_user_id_user_id_fk": {+ "name": "calendar_shares_user_id_user_id_fk",+ "tableFrom": "calendar_shares",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "calendar_shares_bundle_id_calendar_permission_bundles_id_fk": {+ "name": "calendar_shares_bundle_id_calendar_permission_bundles_id_fk",+ "tableFrom": "calendar_shares",+ "tableTo": "calendar_permission_bundles",+ "columnsFrom": [+ "bundle_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "restrict",+ "onUpdate": "no action"+ },+ "calendar_shares_shared_by_user_id_fk": {+ "name": "calendar_shares_shared_by_user_id_fk",+ "tableFrom": "calendar_shares",+ "tableTo": "user",+ "columnsFrom": [+ "shared_by"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "calendars": {+ "name": "calendars",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "color": {+ "name": "color",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'#3b82f6'"+ },+ "owner_id": {+ "name": "owner_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "guest_bundle_id": {+ "name": "guest_bundle_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "signups_enabled": {+ "name": "signups_enabled",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": true+ },+ "split_shifts_enabled": {+ "name": "split_shifts_enabled",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "view_settings": {+ "name": "view_settings",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ }+ },+ "indexes": {+ "calendars_ownerId_idx": {+ "name": "calendars_ownerId_idx",+ "columns": [+ "owner_id"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "calendars_owner_id_user_id_fk": {+ "name": "calendars_owner_id_user_id_fk",+ "tableFrom": "calendars",+ "tableTo": "user",+ "columnsFrom": [+ "owner_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "external_syncs": {+ "name": "external_syncs",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "calendar_id": {+ "name": "calendar_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "sync_type": {+ "name": "sync_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'icloud'"+ },+ "calendar_url": {+ "name": "calendar_url",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "color": {+ "name": "color",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'#3b82f6'"+ },+ "display_mode": {+ "name": "display_mode",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'normal'"+ },+ "is_hidden": {+ "name": "is_hidden",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "hide_from_stats": {+ "name": "hide_from_stats",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "auto_sync_interval": {+ "name": "auto_sync_interval",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "is_one_time_import": {+ "name": "is_one_time_import",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "last_synced_at": {+ "name": "last_synced_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "external_syncs_calendar_id_calendars_id_fk": {+ "name": "external_syncs_calendar_id_calendars_id_fk",+ "tableFrom": "external_syncs",+ "tableTo": "calendars",+ "columnsFrom": [+ "calendar_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "preset_custom_field_values": {+ "name": "preset_custom_field_values",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "preset_id": {+ "name": "preset_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "field_id": {+ "name": "field_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "value": {+ "name": "value",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "preset_custom_field_values_presetId_idx": {+ "name": "preset_custom_field_values_presetId_idx",+ "columns": [+ "preset_id"+ ],+ "isUnique": false+ },+ "preset_custom_field_values_presetId_fieldId_idx": {+ "name": "preset_custom_field_values_presetId_fieldId_idx",+ "columns": [+ "preset_id",+ "field_id"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {+ "preset_custom_field_values_preset_id_shift_presets_id_fk": {+ "name": "preset_custom_field_values_preset_id_shift_presets_id_fk",+ "tableFrom": "preset_custom_field_values",+ "tableTo": "shift_presets",+ "columnsFrom": [+ "preset_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "preset_custom_field_values_field_id_calendar_custom_fields_id_fk": {+ "name": "preset_custom_field_values_field_id_calendar_custom_fields_id_fk",+ "tableFrom": "preset_custom_field_values",+ "tableTo": "calendar_custom_fields",+ "columnsFrom": [+ "field_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "preset_time_segments": {+ "name": "preset_time_segments",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "preset_id": {+ "name": "preset_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "start_time": {+ "name": "start_time",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "end_time": {+ "name": "end_time",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ }+ },+ "indexes": {+ "preset_time_segments_presetId_idx": {+ "name": "preset_time_segments_presetId_idx",+ "columns": [+ "preset_id"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "preset_time_segments_preset_id_shift_presets_id_fk": {+ "name": "preset_time_segments_preset_id_shift_presets_id_fk",+ "tableFrom": "preset_time_segments",+ "tableTo": "shift_presets",+ "columnsFrom": [+ "preset_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "session": {+ "name": "session",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "expires_at": {+ "name": "expires_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "token": {+ "name": "token",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(cast(unixepoch('subsecond') * 1000 as integer))"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "ip_address": {+ "name": "ip_address",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "user_agent": {+ "name": "user_agent",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "impersonated_by": {+ "name": "impersonated_by",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "session_token_unique": {+ "name": "session_token_unique",+ "columns": [+ "token"+ ],+ "isUnique": true+ },+ "session_userId_idx": {+ "name": "session_userId_idx",+ "columns": [+ "user_id"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "session_user_id_user_id_fk": {+ "name": "session_user_id_user_id_fk",+ "tableFrom": "session",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "shift_custom_field_values": {+ "name": "shift_custom_field_values",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "shift_id": {+ "name": "shift_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "field_id": {+ "name": "field_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "value": {+ "name": "value",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "shift_custom_field_values_shiftId_idx": {+ "name": "shift_custom_field_values_shiftId_idx",+ "columns": [+ "shift_id"+ ],+ "isUnique": false+ },+ "shift_custom_field_values_shiftId_fieldId_idx": {+ "name": "shift_custom_field_values_shiftId_fieldId_idx",+ "columns": [+ "shift_id",+ "field_id"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {+ "shift_custom_field_values_shift_id_shifts_id_fk": {+ "name": "shift_custom_field_values_shift_id_shifts_id_fk",+ "tableFrom": "shift_custom_field_values",+ "tableTo": "shifts",+ "columnsFrom": [+ "shift_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "shift_custom_field_values_field_id_calendar_custom_fields_id_fk": {+ "name": "shift_custom_field_values_field_id_calendar_custom_fields_id_fk",+ "tableFrom": "shift_custom_field_values",+ "tableTo": "calendar_custom_fields",+ "columnsFrom": [+ "field_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "shift_presets": {+ "name": "shift_presets",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "calendar_id": {+ "name": "calendar_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "start_time": {+ "name": "start_time",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "end_time": {+ "name": "end_time",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "color": {+ "name": "color",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'#3b82f6'"+ },+ "notes": {+ "name": "notes",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "group_name": {+ "name": "group_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "is_secondary": {+ "name": "is_secondary",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "is_all_day": {+ "name": "is_all_day",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "hide_from_stats": {+ "name": "hide_from_stats",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "default_signup_capacity": {+ "name": "default_signup_capacity",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "order": {+ "name": "order",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "archived_at": {+ "name": "archived_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "created_by": {+ "name": "created_by",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "shift_presets_calendar_id_calendars_id_fk": {+ "name": "shift_presets_calendar_id_calendars_id_fk",+ "tableFrom": "shift_presets",+ "tableTo": "calendars",+ "columnsFrom": [+ "calendar_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "shift_presets_created_by_user_id_fk": {+ "name": "shift_presets_created_by_user_id_fk",+ "tableFrom": "shift_presets",+ "tableTo": "user",+ "columnsFrom": [+ "created_by"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "shift_signups": {+ "name": "shift_signups",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "shift_id": {+ "name": "shift_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "signed_up_by": {+ "name": "signed_up_by",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ }+ },+ "indexes": {+ "shift_signups_shiftId_idx": {+ "name": "shift_signups_shiftId_idx",+ "columns": [+ "shift_id"+ ],+ "isUnique": false+ },+ "shift_signups_userId_idx": {+ "name": "shift_signups_userId_idx",+ "columns": [+ "user_id"+ ],+ "isUnique": false+ },+ "shift_signups_shiftId_userId_idx": {+ "name": "shift_signups_shiftId_userId_idx",+ "columns": [+ "shift_id",+ "user_id"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {+ "shift_signups_shift_id_shifts_id_fk": {+ "name": "shift_signups_shift_id_shifts_id_fk",+ "tableFrom": "shift_signups",+ "tableTo": "shifts",+ "columnsFrom": [+ "shift_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "shift_signups_user_id_user_id_fk": {+ "name": "shift_signups_user_id_user_id_fk",+ "tableFrom": "shift_signups",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "shift_signups_signed_up_by_user_id_fk": {+ "name": "shift_signups_signed_up_by_user_id_fk",+ "tableFrom": "shift_signups",+ "tableTo": "user",+ "columnsFrom": [+ "signed_up_by"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "shift_time_segments": {+ "name": "shift_time_segments",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "shift_id": {+ "name": "shift_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "start_time": {+ "name": "start_time",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "end_time": {+ "name": "end_time",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ }+ },+ "indexes": {+ "shift_time_segments_shiftId_idx": {+ "name": "shift_time_segments_shiftId_idx",+ "columns": [+ "shift_id"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "shift_time_segments_shift_id_shifts_id_fk": {+ "name": "shift_time_segments_shift_id_shifts_id_fk",+ "tableFrom": "shift_time_segments",+ "tableTo": "shifts",+ "columnsFrom": [+ "shift_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "shifts": {+ "name": "shifts",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "calendar_id": {+ "name": "calendar_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "preset_id": {+ "name": "preset_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "date": {+ "name": "date",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "start_time": {+ "name": "start_time",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "end_time": {+ "name": "end_time",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "color": {+ "name": "color",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'#3b82f6'"+ },+ "notes": {+ "name": "notes",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "is_all_day": {+ "name": "is_all_day",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "is_secondary": {+ "name": "is_secondary",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "signup_capacity": {+ "name": "signup_capacity",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "external_event_id": {+ "name": "external_event_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "external_sync_id": {+ "name": "external_sync_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "synced_from_external": {+ "name": "synced_from_external",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "created_by": {+ "name": "created_by",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "shifts_calendar_id_calendars_id_fk": {+ "name": "shifts_calendar_id_calendars_id_fk",+ "tableFrom": "shifts",+ "tableTo": "calendars",+ "columnsFrom": [+ "calendar_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "shifts_preset_id_shift_presets_id_fk": {+ "name": "shifts_preset_id_shift_presets_id_fk",+ "tableFrom": "shifts",+ "tableTo": "shift_presets",+ "columnsFrom": [+ "preset_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "shifts_external_sync_id_external_syncs_id_fk": {+ "name": "shifts_external_sync_id_external_syncs_id_fk",+ "tableFrom": "shifts",+ "tableTo": "external_syncs",+ "columnsFrom": [+ "external_sync_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "shifts_created_by_user_id_fk": {+ "name": "shifts_created_by_user_id_fk",+ "tableFrom": "shifts",+ "tableTo": "user",+ "columnsFrom": [+ "created_by"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "sync_logs": {+ "name": "sync_logs",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "calendar_id": {+ "name": "calendar_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "external_sync_id": {+ "name": "external_sync_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "external_sync_name": {+ "name": "external_sync_name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "error_message": {+ "name": "error_message",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "shifts_created": {+ "name": "shifts_created",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "shifts_updated": {+ "name": "shifts_updated",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "shifts_deleted": {+ "name": "shifts_deleted",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "sync_type": {+ "name": "sync_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'auto'"+ },+ "is_read": {+ "name": "is_read",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "synced_at": {+ "name": "synced_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "sync_logs_calendar_id_calendars_id_fk": {+ "name": "sync_logs_calendar_id_calendars_id_fk",+ "tableFrom": "sync_logs",+ "tableTo": "calendars",+ "columnsFrom": [+ "calendar_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "sync_logs_external_sync_id_external_syncs_id_fk": {+ "name": "sync_logs_external_sync_id_external_syncs_id_fk",+ "tableFrom": "sync_logs",+ "tableTo": "external_syncs",+ "columnsFrom": [+ "external_sync_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "system_settings": {+ "name": "system_settings",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false,+ "default": "'default'"+ },+ "update_check_enabled": {+ "name": "update_check_enabled",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": true+ },+ "update_banner_visibility": {+ "name": "update_banner_visibility",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'all'"+ },+ "allow_guest_access": {+ "name": "allow_guest_access",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "user": {+ "name": "user",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "email": {+ "name": "email",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "email_verified": {+ "name": "email_verified",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "image": {+ "name": "image",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(cast(unixepoch('subsecond') * 1000 as integer))"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(cast(unixepoch('subsecond') * 1000 as integer))"+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "banned": {+ "name": "banned",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": false+ },+ "ban_reason": {+ "name": "ban_reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "ban_expires": {+ "name": "ban_expires",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "must_change_password": {+ "name": "must_change_password",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ }+ },+ "indexes": {+ "user_email_unique": {+ "name": "user_email_unique",+ "columns": [+ "email"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "user_calendar_subscriptions": {+ "name": "user_calendar_subscriptions",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "calendar_id": {+ "name": "calendar_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'subscribed'"+ },+ "source": {+ "name": "source",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'guest'"+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ }+ },+ "indexes": {+ "user_calendar_subscriptions_userId_idx": {+ "name": "user_calendar_subscriptions_userId_idx",+ "columns": [+ "user_id"+ ],+ "isUnique": false+ },+ "user_calendar_subscriptions_calendarId_idx": {+ "name": "user_calendar_subscriptions_calendarId_idx",+ "columns": [+ "calendar_id"+ ],+ "isUnique": false+ },+ "user_calendar_subscriptions_status_idx": {+ "name": "user_calendar_subscriptions_status_idx",+ "columns": [+ "status"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "user_calendar_subscriptions_user_id_user_id_fk": {+ "name": "user_calendar_subscriptions_user_id_user_id_fk",+ "tableFrom": "user_calendar_subscriptions",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_calendar_subscriptions_calendar_id_calendars_id_fk": {+ "name": "user_calendar_subscriptions_calendar_id_calendars_id_fk",+ "tableFrom": "user_calendar_subscriptions",+ "tableTo": "calendars",+ "columnsFrom": [+ "calendar_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "user_preferences": {+ "name": "user_preferences",+ "columns": {+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "view_settings": {+ "name": "view_settings",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "user_preferences_user_id_user_id_fk": {+ "name": "user_preferences_user_id_user_id_fk",+ "tableFrom": "user_preferences",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "verification": {+ "name": "verification",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "identifier": {+ "name": "identifier",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "value": {+ "name": "value",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "expires_at": {+ "name": "expires_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(cast(unixepoch('subsecond') * 1000 as integer))"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ }+ },+ "views": {},+ "enums": {},+ "_meta": {+ "schemas": {},+ "tables": {},+ "columns": {}+ },+ "internal": {+ "indexes": {}+ }+}\ No newline at end of filediff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.jsonindex 1c5d8b3..3285b10 100644--- a/drizzle/meta/_journal.json+++ b/drizzle/meta/_journal.json@@ -197,6 +197,13 @@"when": 1789753626628,"tag": "0027_lush_thunderbolt","breakpoints": true+ },+ {+ "idx": 28,+ "version": "6",+ "when": 1789823233140,+ "tag": "0028_dapper_karnak",+ "breakpoints": true}]}\ No newline at end of filediff --git a/hooks/useCompareMode.ts b/hooks/useCompareMode.tsindex a701ff6..e20641d 100644--- a/hooks/useCompareMode.ts+++ b/hooks/useCompareMode.ts@@ -156,7 +156,8 @@ export function useCompareMode({await Promise.all(selectedPresetIds.map(async (presetId) => {const preset = calendarPresets.find((p) => p.id === presetId);- if (!preset) return;+ // Archived presets neither stamp nor un-stamp, same as on the server.+ if (!preset || preset.archivedAt) return;const existingShift = calendarShifts.find((shift) =>diff --git a/hooks/usePresets.ts b/hooks/usePresets.tsindex f084f87..d46fb30 100644--- a/hooks/usePresets.ts+++ b/hooks/usePresets.ts@@ -95,6 +95,24 @@ async function deletePresetApi(presetId: string): Promise<void> {}}+async function archivePresetApi(+ presetId: string,+ archived: boolean+): Promise<ShiftPresetWithValues> {+ const response = await fetch(`/api/presets/${presetId}`, {+ method: "PATCH",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify({ archived }),+ });++ if (!response.ok) {+ const errorData = await response.json();+ throw new Error(errorData.error || "Failed to archive preset");+ }++ return await response.json();+}+async function reorderPresetsApi(calendarId: string,presetOrders: Array<{ id: string; order: number }>@@ -132,6 +150,7 @@ function createOptimisticPreset(segments: formData.segments,customFields: formData.customFields ?? {},order: 999, // Will be corrected by server+ archivedAt: null,createdBy: null,createdAt: new Date(),updatedAt: new Date(),@@ -284,6 +303,49 @@ export function usePresets(calendarId: string | undefined) {},});+ // Archive / restore preset mutation+ const archiveMutation = useMutation({+ mutationFn: ({ presetId, archived }: { presetId: string; archived: boolean }) =>+ archivePresetApi(presetId, archived),+ onMutate: async ({ presetId, archived }) => {+ await queryClient.cancelQueries({+ queryKey: queryKeys.presets.byCalendar(calendarId!),+ });+ const previous = queryClient.getQueryData(+ queryKeys.presets.byCalendar(calendarId!)+ );+ queryClient.setQueryData(+ queryKeys.presets.byCalendar(calendarId!),+ (old: ShiftPresetWithValues[] = []) =>+ old.map((p) =>+ p.id === presetId+ ? { ...p, archivedAt: archived ? new Date() : null, updatedAt: new Date() }+ : p+ )+ );+ return { previous };+ },+ onError: (error, variables, context) => {+ queryClient.setQueryData(+ queryKeys.presets.byCalendar(calendarId!),+ context?.previous+ );+ toast.error(+ error instanceof Error+ ? error.message+ : t("common.updateError", { item: t("preset.preset") })+ );+ },+ onSuccess: (_data, { archived }) => {+ toast.success(archived ? t("preset.archivedToast") : t("preset.restoredToast"));+ },+ onSettled: () => {+ queryClient.invalidateQueries({+ queryKey: queryKeys.presets.byCalendar(calendarId!),+ });+ },+ });+// Reorder presets mutationconst reorderMutation = useMutation({mutationFn: (presetOrders: Array<{ id: string; order: number }>) =>@@ -359,6 +421,14 @@ export function usePresets(calendarId: string | undefined) {return false;}},+ archivePreset: async (presetId: string, archived: boolean) => {+ try {+ await archiveMutation.mutateAsync({ presetId, archived });+ return true;+ } catch {+ return false;+ }+ },reorderPresets: async (presetOrders: Array<{ id: string; order: number }>) => {diff --git a/hooks/useShiftForm.ts b/hooks/useShiftForm.tsindex 42846f1..2596913 100644--- a/hooks/useShiftForm.ts+++ b/hooks/useShiftForm.ts@@ -3,6 +3,7 @@ import { ShiftFormData } from "@/components/shift-sheet";import { ShiftWithCalendar } from "@/lib/types";import { formatDateToLocal } from "@/lib/date-utils";import { usePresets, type ShiftPresetWithValues } from "@/hooks/usePresets";+import { activePresets } from "@/lib/shift-display";import { DEFAULT_COLOR } from "@/lib/constants";interface UseShiftFormOptions {@@ -36,7 +37,16 @@ export function useShiftForm({customFields: shift?.customFields ?? {},});- const { presets, createPreset } = usePresets(calendarId);+ const { presets: allPresets, createPreset } = usePresets(calendarId);+ // An archived preset can no longer be picked, but the one an edited shift was+ // stamped from stays in the list so its selection isn't silently dropped.+ const selectablePresets = activePresets(allPresets);+ const archivedCurrent = shift?.presetId+ ? allPresets.find((p) => p.id === shift.presetId && p.archivedAt)+ : undefined;+ const presets = archivedCurrent+ ? [...selectablePresets, archivedCurrent]+ : selectablePresets;const [saveAsPreset, setSaveAsPreset] = useState(false);const [presetName, setPresetName] = useState("");diff --git a/lib/db/schema.ts b/lib/db/schema.tsindex b769d7b..b41457e 100644--- a/lib/db/schema.ts+++ b/lib/db/schema.ts@@ -388,6 +388,9 @@ export const shiftPresets = sqliteTable("shift_presets", {// Copied into signupCapacity on shifts created from this presetdefaultSignupCapacity: integer("default_signup_capacity"),order: integer("order").notNull().default(0),+ // null = active. Archived presets can no longer create shifts, but shifts+ // already stamped from them stay untouched.+ archivedAt: integer("archived_at", { mode: "timestamp" }),// null = no known creator, see shifts.createdBy above.createdBy: text("created_by").references(() => user.id, {onDelete: "set null",diff --git a/lib/shift-display.ts b/lib/shift-display.tsindex 96dd733..5f193c6 100644--- a/lib/shift-display.ts+++ b/lib/shift-display.ts@@ -202,6 +202,11 @@ export function formatTimeRange(times: {.join(", ");}+/** Presets that may still create shifts — archived ones stay loaded for existing shifts, stats colors and the manage sheet. */+export function activePresets<T extends { archivedAt: Date | null }>(presets: T[]): T[] {+ return presets.filter((p) => !p.archivedAt);+}+export interface PresetGroup {name: string;items: ShiftPreset[];diff --git a/messages/cs.json b/messages/cs.jsonindex 9cd3309..ba4914f 100644--- a/messages/cs.json+++ b/messages/cs.json@@ -199,6 +199,11 @@"preset": {"preset": "Předvolba","edit": "Upravit předvolbu",+ "archive": "Archivovat šablonu",+ "restore": "Obnovit šablonu",+ "archived": "Archivováno",+ "archivedToast": "Šablona archivována",+ "restoredToast": "Šablona obnovena","saveAsPreset": "Uložit jako předvolbu","presetName": "Název předvolby","presetNamePlaceholder": "např. Ranní směna, večerní směna...",@@ -818,6 +823,8 @@"delete": "Smazat předvolbu","dragHandle": "Přetažením změníte pořadí","secondarySection": "Pod „Další“",+ "archivedSection": "Archiv",+ "archivedHint": "Už nevytváří nové směny","markAsSecondaryHint": "V liště šablon se zobrazí až po kliknutí na „Další“","defaultSignupCapacityLabel": "Maximalni pocet osob","defaultSignupCapacityHint": "Určuje, kolik lidí se může přihlásit na směny vytvořené z této šablony. Nechte prázdné pro neomezený počet. Při vytvoření směny se zkopíruje a lze ho u každé směny upravit."diff --git a/messages/de.json b/messages/de.jsonindex c7f2612..491dba8 100644--- a/messages/de.json+++ b/messages/de.json@@ -199,6 +199,11 @@"preset": {"preset": "Vorlage","edit": "Vorlage bearbeiten",+ "archive": "Vorlage archivieren",+ "restore": "Vorlage reaktivieren",+ "archived": "Archiviert",+ "archivedToast": "Vorlage archiviert",+ "restoredToast": "Vorlage reaktiviert","saveAsPreset": "Als Vorlage speichern","presetName": "Vorlagenname","presetNamePlaceholder": "z.B. Frühschicht, Spätschicht...",@@ -818,6 +823,8 @@"delete": "Vorlage löschen","dragHandle": "Zum Sortieren ziehen","secondarySection": "Unter „Weitere“",+ "archivedSection": "Archiv",+ "archivedHint": "Erstellt keine neuen Schichten mehr","markAsSecondaryHint": "Erscheint in der Vorlagenleiste erst nach Klick auf „Weitere“","defaultSignupCapacityLabel": "Maximale Anzahl Personen","defaultSignupCapacityHint": "Legt fest, wie viele Personen sich für Schichten aus dieser Vorlage eintragen können. Leer lassen für unbegrenzt viele Anmeldungen. Wird beim Anlegen übernommen und kann pro Schicht angepasst werden."diff --git a/messages/en.json b/messages/en.jsonindex 0cfea9c..c9b5b62 100644--- a/messages/en.json+++ b/messages/en.json@@ -199,6 +199,11 @@"preset": {"preset": "Preset","edit": "Edit Preset",+ "archive": "Archive preset",+ "restore": "Restore preset",+ "archived": "Archived",+ "archivedToast": "Preset archived",+ "restoredToast": "Preset restored","saveAsPreset": "Save as preset","presetName": "Preset name","presetNamePlaceholder": "e.g., Morning Shift, Evening Shift...",@@ -818,6 +823,8 @@"delete": "Delete preset","dragHandle": "Drag to reorder","secondarySection": "Under “More”",+ "archivedSection": "Archive",+ "archivedHint": "No longer creates new shifts","markAsSecondaryHint": "Shows in the preset bar only after clicking “More”","defaultSignupCapacityLabel": "Maximum number of people","defaultSignupCapacityHint": "Sets how many people can sign up for shifts created from this preset. Leave empty for unlimited signups. Copied when a shift is created and can be adjusted per shift."diff --git a/messages/es.json b/messages/es.jsonindex 9b6a221..98cc11b 100644--- a/messages/es.json+++ b/messages/es.json@@ -199,6 +199,11 @@"preset": {"preset": "Preajuste","edit": "Editar preajuste",+ "archive": "Archivar plantilla",+ "restore": "Restaurar plantilla",+ "archived": "Archivada",+ "archivedToast": "Plantilla archivada",+ "restoredToast": "Plantilla restaurada","saveAsPreset": "Guardar como preajuste","presetName": "Nombre del preajuste","presetNamePlaceholder": "ej., Turno de mañana, Turno de tarde...",@@ -818,6 +823,8 @@"delete": "Eliminar preajuste","dragHandle": "Arrastrar para ordenar","secondarySection": "En «Más»",+ "archivedSection": "Archivo",+ "archivedHint": "Ya no crea turnos nuevos","markAsSecondaryHint": "Aparece en la barra de plantillas solo al pulsar «Más»","defaultSignupCapacityLabel": "Numero maximo de personas","defaultSignupCapacityHint": "Define cuántas personas pueden inscribirse en turnos creados a partir de esta plantilla. Déjalo vacío para inscripciones ilimitadas. Se copia al crear el turno y puede ajustarse por turno."diff --git a/messages/fr.json b/messages/fr.jsonindex 42ab293..3fd906c 100755--- a/messages/fr.json+++ b/messages/fr.json@@ -199,6 +199,11 @@"preset": {"preset": "Modèle","edit": "Modifier le modèle",+ "archive": "Archiver le modèle",+ "restore": "Réactiver le modèle",+ "archived": "Archivé",+ "archivedToast": "Modèle archivé",+ "restoredToast": "Modèle réactivé","saveAsPreset": "Enregistrer comme modèle","presetName": "Nom du modèle","presetNamePlaceholder": "ex. : Créneau matin, Créneau soir...",@@ -818,6 +823,8 @@"delete": "Supprimer le modèle","dragHandle": "Glisser pour réordonner","secondarySection": "Sous « Plus »",+ "archivedSection": "Archives",+ "archivedHint": "Ne crée plus de nouveaux créneaux","markAsSecondaryHint": "N’apparaît dans la barre de modèles qu’après un clic sur « Plus »","defaultSignupCapacityLabel": "Nombre maximum de personnes","defaultSignupCapacityHint": "Définit combien de personnes peuvent s'inscrire aux gardes créées à partir de ce modèle. Laissez vide pour un nombre illimité. Copié à la création et modifiable pour chaque garde."diff --git a/messages/it.json b/messages/it.jsonindex 972cead..e59eb78 100644--- a/messages/it.json+++ b/messages/it.json@@ -199,6 +199,11 @@"preset": {"preset": "Preset","edit": "Modifica Preset",+ "archive": "Archivia modello",+ "restore": "Ripristina modello",+ "archived": "Archiviato",+ "archivedToast": "Modello archiviato",+ "restoredToast": "Modello ripristinato","saveAsPreset": "Salva come preset","presetName": "Nome preset","presetNamePlaceholder": "es., Turno Mattutino, Turno Serale...",@@ -818,6 +823,8 @@"delete": "Elimina preset","dragHandle": "Trascina per riordinare","secondarySection": "Sotto «Altri»",+ "archivedSection": "Archivio",+ "archivedHint": "Non crea più nuovi turni","markAsSecondaryHint": "Compare nella barra dei modelli solo dopo aver cliccato «Altri»","defaultSignupCapacityLabel": "Numero massimo di persone","defaultSignupCapacityHint": "Stabilisce quante persone possono iscriversi ai turni creati da questo modello. Lascia vuoto per un numero illimitato. Viene copiato alla creazione e può essere modificato per ogni turno."