feat(fase-9): migration 015 — users.theme column for dark mode

Adds `theme text not null default 'system' check (theme in
('light','dark','system'))` to public.users. New users get 'system' so
the UI follows the OS preference until they opt in; existing rows
backfill via the default.

Includes pgTAP test 009 (8 assertions covering column existence/type,
default value, valid transitions, and the check constraint rejecting
unknown values). Wires the theme field into the hand-curated
database.ts type so PostgREST queries stay typed.

Also hardens `just db-types` to bail out (instead of truncating
database.ts) when the supabase CLI is missing — the recipe was silently
wiping the file on this dev machine.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-18 01:06:18 +02:00
parent 93153cd750
commit 3efe0b9be0
4 changed files with 102 additions and 2 deletions

View File

@@ -9,6 +9,7 @@ export type AvatarTypeEnum = 'initials' | 'emoji' | 'upload';
export type MemberRoleEnum = 'admin' | 'member' | 'guest';
export type ListStatusEnum = 'active' | 'completed' | 'archived';
export type NoteColor = 'yellow' | 'green' | 'blue' | 'pink' | 'purple' | 'orange' | 'gray' | 'red';
export type ThemeMode = 'light' | 'dark' | 'system';
export interface Database {
public: {
@@ -22,6 +23,7 @@ export interface Database {
avatar_type: AvatarTypeEnum;
avatar_emoji: string | null;
avatar_url: string | null;
theme: ThemeMode;
created_at: string;
updated_at: string;
};
@@ -33,6 +35,7 @@ export interface Database {
avatar_type?: AvatarTypeEnum;
avatar_emoji?: string | null;
avatar_url?: string | null;
theme?: ThemeMode;
created_at?: string;
updated_at?: string;
};
@@ -44,6 +47,7 @@ export interface Database {
avatar_type?: AvatarTypeEnum;
avatar_emoji?: string | null;
avatar_url?: string | null;
theme?: ThemeMode;
created_at?: string;
updated_at?: string;
};