Pre-launch — Gluecron is in final validation. Public signups and git hosting for non-owner users open after launch review.
CodeIssuesDiscussionsWikiPull RequestsProjectsCommitsActionsReleasesContributorsPulse● GatesSecuritySettingsDeploymentsPipelineInsightsAgents✨ Explain✨ Ask AI✨ Workspace✨ Spec✨ Tests▓ Debt Map✨ NL Search🏛 Archaeology
Blame · Line-by-line history

0014_gists.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.

0014_gists.sqlBlame73 lines · 1 contributor
1e162a8Claude1-- Gluecron migration 0014: Block E4 — Gists.
2--
3-- User-owned small snippets/files that behave like tiny repos. DB-backed
4-- (no git bare repo for v1): each gist owns a collection of gist_files, and
5-- every edit appends a gist_revisions row containing a JSON snapshot of the
6-- full file set at that revision.
7--
8-- Tables:
9-- gists — top-level gist row (owner, slug, title, description)
10-- gist_files — individual files on a gist (filename, language, content)
11-- gist_revisions — per-edit snapshots (JSON {filename: content})
12-- gist_stars — per-user stars
13
14--> statement-breakpoint
15CREATE TABLE IF NOT EXISTS "gists" (
16 "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
17 "owner_id" uuid NOT NULL,
18 "slug" text NOT NULL UNIQUE,
19 "title" text NOT NULL DEFAULT '',
20 "description" text NOT NULL DEFAULT '',
21 "is_public" boolean NOT NULL DEFAULT true,
22 "created_at" timestamp DEFAULT now() NOT NULL,
23 "updated_at" timestamp DEFAULT now() NOT NULL,
24 CONSTRAINT "gists_owner_fk" FOREIGN KEY ("owner_id") REFERENCES "users"("id") ON DELETE cascade
25);
26
27--> statement-breakpoint
28CREATE INDEX IF NOT EXISTS "gists_owner" ON "gists" ("owner_id");
29
30--> statement-breakpoint
31CREATE TABLE IF NOT EXISTS "gist_files" (
32 "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
33 "gist_id" uuid NOT NULL,
34 "filename" text NOT NULL,
35 "language" text,
36 "content" text NOT NULL DEFAULT '',
37 "size_bytes" integer NOT NULL DEFAULT 0,
38 CONSTRAINT "gist_files_gist_fk" FOREIGN KEY ("gist_id") REFERENCES "gists"("id") ON DELETE cascade
39);
40
41--> statement-breakpoint
42CREATE INDEX IF NOT EXISTS "gist_files_gist" ON "gist_files" ("gist_id");
43--> statement-breakpoint
44CREATE UNIQUE INDEX IF NOT EXISTS "gist_files_gist_filename" ON "gist_files" ("gist_id", "filename");
45
46--> statement-breakpoint
47CREATE TABLE IF NOT EXISTS "gist_revisions" (
48 "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
49 "gist_id" uuid NOT NULL,
50 "revision" integer NOT NULL,
51 "snapshot" text NOT NULL DEFAULT '{}',
52 "author_id" uuid NOT NULL,
53 "message" text,
54 "created_at" timestamp DEFAULT now() NOT NULL,
55 CONSTRAINT "gist_revisions_gist_fk" FOREIGN KEY ("gist_id") REFERENCES "gists"("id") ON DELETE cascade,
56 CONSTRAINT "gist_revisions_author_fk" FOREIGN KEY ("author_id") REFERENCES "users"("id") ON DELETE cascade
57);
58
59--> statement-breakpoint
60CREATE INDEX IF NOT EXISTS "gist_revisions_gist_rev" ON "gist_revisions" ("gist_id", "revision");
61
62--> statement-breakpoint
63CREATE TABLE IF NOT EXISTS "gist_stars" (
64 "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
65 "gist_id" uuid NOT NULL,
66 "user_id" uuid NOT NULL,
67 "created_at" timestamp DEFAULT now() NOT NULL,
68 CONSTRAINT "gist_stars_gist_fk" FOREIGN KEY ("gist_id") REFERENCES "gists"("id") ON DELETE cascade,
69 CONSTRAINT "gist_stars_user_fk" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE cascade
70);
71
72--> statement-breakpoint
73CREATE UNIQUE INDEX IF NOT EXISTS "gist_stars_gist_user" ON "gist_stars" ("gist_id", "user_id");