Blame · Line-by-line history
0035_pinned_repos.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.
| 8ec29ff | 1 | -- Block J13 — Pinned repositories on user profile. |
| 2 | -- | |
| 3 | -- Users can pin up to 6 repositories that appear at the top of their | |
| 4 | -- profile page. Ordering is explicit via `position` (0-indexed). | |
| 5 | ||
| 6 | CREATE TABLE IF NOT EXISTS "pinned_repositories" ( | |
| 7 | "id" uuid PRIMARY KEY DEFAULT gen_random_uuid(), | |
| 8 | "user_id" uuid NOT NULL REFERENCES "users"("id") ON DELETE CASCADE, | |
| 9 | "repository_id" uuid NOT NULL REFERENCES "repositories"("id") ON DELETE CASCADE, | |
| 10 | "position" integer NOT NULL DEFAULT 0, | |
| 11 | "pinned_at" timestamp NOT NULL DEFAULT now() | |
| 12 | ); | |
| 13 | ||
| 14 | CREATE UNIQUE INDEX IF NOT EXISTS "pinned_repositories_user_repo_unique" | |
| 15 | ON "pinned_repositories" ("user_id", "repository_id"); | |
| 16 | ||
| 17 | CREATE INDEX IF NOT EXISTS "pinned_repositories_user_position_idx" | |
| 18 | ON "pinned_repositories" ("user_id", "position"); |