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

0013_discussions.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.

0013_discussions.sqlBlame50 lines · 1 contributor
1e162a8Claude1-- Gluecron migration 0013: Block E2 — Discussions.
2--
3-- Tables:
4-- discussions — forum-style threaded conversations attached to a repo
5-- discussion_comments — comments (optionally nested 1 level via parent_comment_id)
6--
7-- Discussions mirror GitHub Discussions: pinned + categorised threads that live
8-- alongside issues/PRs but are conversational rather than work-tracking.
9
10--> statement-breakpoint
11CREATE TABLE IF NOT EXISTS "discussions" (
12 "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
13 "number" serial NOT NULL,
14 "repository_id" uuid NOT NULL,
15 "author_id" uuid NOT NULL,
16 "category" text NOT NULL DEFAULT 'general',
17 "title" text NOT NULL,
18 "body" text,
19 "state" text NOT NULL DEFAULT 'open',
20 "locked" boolean NOT NULL DEFAULT false,
21 "answer_comment_id" uuid,
22 "pinned" boolean NOT NULL DEFAULT false,
23 "created_at" timestamp DEFAULT now() NOT NULL,
24 "updated_at" timestamp DEFAULT now() NOT NULL,
25 CONSTRAINT "discussions_repo_fk" FOREIGN KEY ("repository_id") REFERENCES "repositories"("id") ON DELETE cascade,
26 CONSTRAINT "discussions_author_fk" FOREIGN KEY ("author_id") REFERENCES "users"("id")
27);
28
29--> statement-breakpoint
30CREATE INDEX IF NOT EXISTS "discussions_repo" ON "discussions" ("repository_id");
31--> statement-breakpoint
32CREATE UNIQUE INDEX IF NOT EXISTS "discussions_repo_number" ON "discussions" ("repository_id", "number");
33
34--> statement-breakpoint
35CREATE TABLE IF NOT EXISTS "discussion_comments" (
36 "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
37 "discussion_id" uuid NOT NULL,
38 "parent_comment_id" uuid,
39 "author_id" uuid NOT NULL,
40 "body" text NOT NULL,
41 "is_answer" boolean NOT NULL DEFAULT false,
42 "created_at" timestamp DEFAULT now() NOT NULL,
43 "updated_at" timestamp DEFAULT now() NOT NULL,
44 CONSTRAINT "discussion_comments_discussion_fk" FOREIGN KEY ("discussion_id") REFERENCES "discussions"("id") ON DELETE cascade,
45 CONSTRAINT "discussion_comments_parent_fk" FOREIGN KEY ("parent_comment_id") REFERENCES "discussion_comments"("id") ON DELETE cascade,
46 CONSTRAINT "discussion_comments_author_fk" FOREIGN KEY ("author_id") REFERENCES "users"("id")
47);
48
49--> statement-breakpoint
50CREATE INDEX IF NOT EXISTS "discussion_comments_discussion" ON "discussion_comments" ("discussion_id");