-- Paste in Supabase → SQL Editor → Run All
create table if not exists accounts (
id uuid default gen_random_uuid() primary key,
user_id uuid references auth.users(id) on delete cascade not null,
name text not null,
type text not null,
balance numeric default 0,
currency text default 'INR',
billing_day integer,
credit_limit numeric,
color text default '#f59e0b',
created_at timestamptz default now()
);
create table if not exists transactions (
id uuid default gen_random_uuid() primary key,
user_id uuid references auth.users(id) on delete cascade not null,
account_id uuid references accounts(id) on delete cascade,
amount numeric not null,
type text not null,
category text default 'Other',
description text default '',
txn_at timestamptz not null default now(),
to_account_id uuid references accounts(id) on delete set null,
created_at timestamptz default now()
);
alter table accounts enable row level security;
alter table transactions enable row level security;
create policy "own_accounts" on accounts for all
using (auth.uid() = user_id) with check (auth.uid() = user_id);
create policy "own_transactions" on transactions for all
using (auth.uid() = user_id) with check (auth.uid() = user_id);
-- Upgrading from v2? Run these extra lines:
-- alter table accounts add column if not exists user_id uuid references auth.users(id) on delete cascade;
-- alter table transactions add column if not exists user_id uuid references auth.users(id) on delete cascade;
-- drop policy if exists "all_accounts" on accounts;
-- drop policy if exists "all_transactions" on transactions;
-- (then create the policies above)
Step 2 of 2 — Sign In
⚠️ First time? Disable email confirmation in Supabase first: Dashboard → Authentication → Settings → uncheck "Enable email confirmations" → Save Otherwise signup will show "email not verified" error.
Using on a new device? Get a login link from Settings ⚙ on your existing device.