Run the following SQL in your Supabase project's SQL Editor to create the required tables.
-- Positions table
CREATE TABLE IF NOT EXISTS positions (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
created_at timestamptz NOT NULL DEFAULT now(),
ticker text NOT NULL,
entry_date date NOT NULL,
entry_price float NOT NULL,
shares float NOT NULL,
quadrant text,
tranche int,
notes text,
active boolean DEFAULT true,
commission float DEFAULT 0,
exit_commission float DEFAULT 0
);
-- Capital events table
CREATE TABLE IF NOT EXISTS capital_events (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
date date NOT NULL,
amount float NOT NULL,
type text NOT NULL,
notes text
);
-- Dividend events table
CREATE TABLE IF NOT EXISTS dividend_events (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
date date NOT NULL,
ticker text NOT NULL,
amount_per_share float NOT NULL,
shares_held float NOT NULL,
gross_received float NOT NULL,
withholding_rate float DEFAULT 0,
net_received float,
reinvested boolean DEFAULT false,
notes text
);
-- Migration: add commission columns to positions (safe to re-run)
ALTER TABLE positions ADD COLUMN IF NOT EXISTS commission float DEFAULT 0;
ALTER TABLE positions ADD COLUMN IF NOT EXISTS exit_commission float DEFAULT 0;
-- Migration: update dividend_events for withholding (safe to re-run)
ALTER TABLE dividend_events RENAME COLUMN total_received TO gross_received;
ALTER TABLE dividend_events ADD COLUMN IF NOT EXISTS withholding_rate float DEFAULT 0;
ALTER TABLE dividend_events ADD COLUMN IF NOT EXISTS net_received float;