Branchwell

Branchwell / source / migrations / 0002_companies.sql

1-- Company accounts (orgs). Every repository now lives under an owner: owner/project.
2-- do_name keeps the Durable Object key, so repos first pushed under a flat name keep their storage.
3CREATE TABLE IF NOT EXISTS orgs (handle TEXT PRIMARY KEY COLLATE NOCASE, name TEXT NOT NULL, domain TEXT, about TEXT, created_at INTEGER NOT NULL);
4CREATE TABLE IF NOT EXISTS org_members (org TEXT NOT NULL, account_id TEXT NOT NULL, role TEXT NOT NULL DEFAULT 'member', PRIMARY KEY (org, account_id));
5CREATE INDEX IF NOT EXISTS org_members_account ON org_members (account_id);
6ALTER TABLE repos ADD COLUMN owner TEXT;
7ALTER TABLE repos ADD COLUMN do_name TEXT;
8UPDATE repos SET do_name = name WHERE do_name IS NULL;
9CREATE INDEX IF NOT EXISTS repos_owner ON repos (owner);