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

0012_ai_native.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.

0012_ai_native.sqlBlame68 lines · 1 contributor
3cbe3d6Claude1-- Gluecron migration 0012: Block D — AI-native differentiation.
2--
3-- Tables:
4-- codebase_explanations — D6: per-commit cached "explain this codebase" markdown
5-- dep_update_runs — D2: AI dependency bumper run history
6-- code_chunks — D1: per-repo code chunks with (optional) embeddings
7
8--> statement-breakpoint
9CREATE TABLE IF NOT EXISTS "codebase_explanations" (
10 "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
11 "repository_id" uuid NOT NULL,
12 "commit_sha" text NOT NULL,
13 "summary" text NOT NULL,
14 "markdown" text NOT NULL,
15 "model" text NOT NULL,
16 "generated_at" timestamp DEFAULT now() NOT NULL,
17 CONSTRAINT "codebase_explanations_repo_fk" FOREIGN KEY ("repository_id") REFERENCES "repositories"("id") ON DELETE cascade
18);
19
20--> statement-breakpoint
21CREATE UNIQUE INDEX IF NOT EXISTS "codebase_explanations_repo_sha" ON "codebase_explanations" ("repository_id", "commit_sha");
22
23--> statement-breakpoint
24CREATE TABLE IF NOT EXISTS "dep_update_runs" (
25 "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
26 "repository_id" uuid NOT NULL,
27 "status" text NOT NULL DEFAULT 'pending',
28 "ecosystem" text NOT NULL,
29 "manifest_path" text NOT NULL,
30 "attempted_bumps" text NOT NULL DEFAULT '[]',
31 "applied_bumps" text NOT NULL DEFAULT '[]',
32 "branch_name" text,
33 "pr_number" integer,
34 "error_message" text,
35 "triggered_by" uuid,
36 "created_at" timestamp DEFAULT now() NOT NULL,
37 "completed_at" timestamp,
38 CONSTRAINT "dep_update_runs_repo_fk" FOREIGN KEY ("repository_id") REFERENCES "repositories"("id") ON DELETE cascade,
39 CONSTRAINT "dep_update_runs_user_fk" FOREIGN KEY ("triggered_by") REFERENCES "users"("id") ON DELETE set null
40);
41
42--> statement-breakpoint
43CREATE INDEX IF NOT EXISTS "dep_update_runs_repo" ON "dep_update_runs" ("repository_id");
44--> statement-breakpoint
45CREATE INDEX IF NOT EXISTS "dep_update_runs_created" ON "dep_update_runs" ("created_at");
46
47--> statement-breakpoint
48-- D1: code chunks for semantic search. Embedding stored as JSON-encoded
49-- number array in text to avoid requiring pgvector; helper lib does cosine
50-- similarity in JS. Upgrade path: ALTER COLUMN embedding TYPE vector(1024).
51CREATE TABLE IF NOT EXISTS "code_chunks" (
52 "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
53 "repository_id" uuid NOT NULL,
54 "commit_sha" text NOT NULL,
55 "path" text NOT NULL,
56 "start_line" integer NOT NULL,
57 "end_line" integer NOT NULL,
58 "content" text NOT NULL,
59 "embedding" text,
60 "embedding_model" text,
61 "created_at" timestamp DEFAULT now() NOT NULL,
62 CONSTRAINT "code_chunks_repo_fk" FOREIGN KEY ("repository_id") REFERENCES "repositories"("id") ON DELETE cascade
63);
64
65--> statement-breakpoint
66CREATE INDEX IF NOT EXISTS "code_chunks_repo" ON "code_chunks" ("repository_id");
67--> statement-breakpoint
68CREATE INDEX IF NOT EXISTS "code_chunks_repo_path" ON "code_chunks" ("repository_id", "path");