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