-- ===================================================================== -- 0000 — Basis-Schema (employees + admin_users) -- ===================================================================== -- Die ursprünglichen Kern-Tabellen wurden früher direkt in Supabase Studio -- angelegt und waren NICHT als Migration erfasst — die folgenden -- Migrationen (0001 ff.) setzen sie voraus und erweitern sie nur additiv -- (alle per `add column if not exists`). Auf einer komplett leeren DB fehlten -- sie dadurch, womit `bundle-migrations` allein keine frische Instanz -- bootstrappen konnte. -- -- Diese Migration schließt die Lücke. Sie ist bewusst `if not exists`: -- auf bestehenden Instanzen (Prod/Demo) ein No-Op, auf leeren DBs legt sie -- die Basis. Spaltenstand entspricht dem aktuellen, generierten Typ -- (lib/database.types.ts) — alle späteren Migrationen sind additiv und -- bleiben damit No-Ops auf diesen Spalten. create table if not exists public.employees ( id uuid primary key default gen_random_uuid(), slug text not null unique, academic_title text, qualification text, qualification_en text, first_name text not null, last_name text not null, position text not null, position_en text, company text not null, org_unit_id uuid, address text, street text, postal_code text, city text, email text not null, phone_office text not null, phone_mobile text, website text, linkedin_url text, xing_url text, calendar_url text, photo_url text, show_mobile boolean not null default false, show_linkedin boolean not null default false, show_xing boolean not null default false, active boolean not null default true, calendar_embed boolean not null default false, successor_employee_id uuid, successor_note text, location_id uuid, person_id uuid, trusted_token text, trusted_token_expires_at timestamptz, trusted_token_created_at timestamptz, trusted_reveal text[] not null default '{}', created_at timestamptz not null default now(), updated_at timestamptz not null default now() ); create table if not exists public.admin_users ( id uuid primary key default gen_random_uuid(), email text not null unique, password_hash text not null, created_at timestamptz not null default now(), name text, role text not null default 'admin', invited_by uuid, last_login_at timestamptz, totp_secret text, totp_enabled boolean not null default false, totp_backup_codes text[] not null default '{}', totp_enabled_at timestamptz );