Run these in Supabase → SQL Editor. Every script uses IF NOT EXISTS — safe to re-run anytime.
✅
Already have tables? Just run Script 2 (Upgrade). Existing data is untouched.
⚡
Enable Realtime in Supabase → Database → Replication → enable supabase_realtime for projects and branches tables.
⚡
Enable Realtime on Tables
Required
Run once to enable real-time on projects and branches.
ALTER PUBLICATION supabase_realtime ADD TABLE public.projects, public.branches;
1
Fresh Install — Create All Tables
New setup
CREATE TABLE IF NOT EXISTS public.profiles (
id uuid REFERENCES auth.users ON DELETE CASCADE PRIMARY KEY,
name text,
role text DEFAULT'user',
created_at timestamptz DEFAULT now()
);
CREATE TABLE IF NOT EXISTS public.projects (
id uuid DEFAULT gen_random_uuid() PRIMARY KEY,
user_id uuid REFERENCES public.profiles(id) ON DELETE CASCADE NOT NULL,
name text NOT NULL,
date date,
description text,
tags text,
priority text DEFAULT'medium',
assignee text,
created_at timestamptz DEFAULT now()
);
CREATE TABLE IF NOT EXISTS public.branches (
id uuid DEFAULT gen_random_uuid() PRIMARY KEY,
project_id uuid REFERENCES public.projects(id) ON DELETE CASCADE NOT NULL,
name text NOT NULL,
status text DEFAULT'open',
priority text DEFAULT'medium',
assignee text,
date date,
due_date date,
notes text,
created_at timestamptz DEFAULT now()
);
2
Upgrade — Add New Columns
Safe to re-run
ALTER TABLE public.projects ADD COLUMN IF NOT EXISTS description text;
ALTER TABLE public.projects ADD COLUMN IF NOT EXISTS tags text;
ALTER TABLE public.projects ADD COLUMN IF NOT EXISTS priority text DEFAULT'medium';
ALTER TABLE public.projects ADD COLUMN IF NOT EXISTS assignee text;
ALTER TABLE public.branches ADD COLUMN IF NOT EXISTS priority text DEFAULT'medium';
ALTER TABLE public.branches ADD COLUMN IF NOT EXISTS assignee text;
ALTER TABLE public.branches ADD COLUMN IF NOT EXISTS due_date date;
ALTER TABLE public.branches ADD COLUMN IF NOT EXISTS notes text;