-- ===================================================================== -- Local extension migration: simple employee payment ledger used by the -- Employee Payment Report UI. Backed by the API; not a Supabase migration. -- ===================================================================== create table if not exists app.employees ( id uuid primary key default gen_random_uuid(), emp_id text not null unique, name text not null, email text, department text, location text, created_at timestamptz not null default now() ); create table if not exists app.employee_transactions ( id uuid primary key default gen_random_uuid(), employee_id uuid not null references app.employees(id) on delete cascade, transaction_date date not null, collection_amount numeric(18,2) not null default 0, deposit_amount numeric(18,2) not null default 0, currency text not null check (currency in ('USD','LBP')), created_at timestamptz not null default now() ); create index if not exists idx_emp_tx_emp on app.employee_transactions(employee_id, transaction_date desc); -- These tables are owned by the API; RLS off, gated at the HTTP layer. alter table app.employees disable row level security; alter table app.employee_transactions disable row level security; grant select, insert, update, delete on app.employees to authenticated; grant select, insert, update, delete on app.employee_transactions to authenticated;