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. |
| 3 | CREATE TABLE IF NOT EXISTS orgs (handle TEXT PRIMARY KEY COLLATE NOCASE, name TEXT NOT NULL, domain TEXT, about TEXT, created_at INTEGER NOT NULL); |
| 4 | CREATE 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)); |
| 5 | CREATE INDEX IF NOT EXISTS org_members_account ON org_members (account_id); |
| 6 | ALTER TABLE repos ADD COLUMN owner TEXT; |
| 7 | ALTER TABLE repos ADD COLUMN do_name TEXT; |
| 8 | UPDATE repos SET do_name = name WHERE do_name IS NULL; |
| 9 | CREATE INDEX IF NOT EXISTS repos_owner ON repos (owner); |