Pre-launch — Gluecron is in final validation. Public signups and git hosting for non-owner users open after launch review.
CodeIssuesPull RequestsActionsSecurityInsightsSettings
✨ AI
More
Blame · Line-by-line history

0114_teams_reconcile.sql

Each line is annotated with the commit that last touched it. Click any SHA to jump to that commit and see the surrounding change.

0114_teams_reconcile.sqlBlame37 lines · 1 contributor
45ac593ccantynz-alt1-- Reconcile the teams feature with the code that uses it.
2--
3-- Same class as 0113. src/db/schema-extensions.ts declared its own `teams`,
4-- `team_members` and `team_repos` alongside src/db/schema.ts, and only
5-- schema.ts is in drizzle.config.ts. Comparing the extensions definitions
6-- against migration 0003 (the real database):
7--
8-- teams extensions adds `permission`, omits the NOT NULL `slug`.
9-- src/routes/orgs.tsx inserts without slug and renders
10-- team.permission — so team creation fails on the NOT NULL
11-- slug, and the badge reads a column that does not exist.
12-- team_members extensions omits `role`; harmless, it has a default.
13-- team_repos HAS NO MIGRATION AT ALL. The table has never existed, yet
14-- orgs.tsx selects and joins it to render a team's repository
15-- list, so that panel could only ever have errored.
16--
17-- Adding rather than removing, for the same reason as 0113: the team create
18-- form collects a permission level and the team page is built to list repos.
19-- Deleting those would throw away working UI to match an accident of history.
20--
21-- `permission` is defaulted so existing rows remain valid.
22
23ALTER TABLE "teams" ADD COLUMN IF NOT EXISTS "permission" text DEFAULT 'read' NOT NULL;
24--> statement-breakpoint
25
26CREATE TABLE IF NOT EXISTS "team_repos" (
27 "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
28 "team_id" uuid NOT NULL,
29 "repository_id" uuid NOT NULL,
30 "permission" text DEFAULT 'read' NOT NULL,
31 "created_at" timestamp DEFAULT now() NOT NULL,
32 CONSTRAINT "team_repos_team_fk" FOREIGN KEY ("team_id") REFERENCES "teams"("id") ON DELETE cascade,
33 CONSTRAINT "team_repos_repo_fk" FOREIGN KEY ("repository_id") REFERENCES "repositories"("id") ON DELETE cascade
34);
35--> statement-breakpoint
36
37CREATE UNIQUE INDEX IF NOT EXISTS "team_repos_unique" ON "team_repos" ("team_id", "repository_id");