Forge
csharp3407750f
1using AgentForge.Abstractions;
2
3namespace AgentForge.Plugin.MergeRequest;
4
5internal static class ForgeMergeRequestSchemaBootstrap
6{
7 internal static void Apply(IForgeMigrationContext context)
8 {
9 context.TryAddColumn("merge_requests", "CreatedBy", "TEXT NOT NULL DEFAULT ''");
10 EnsureMergeRequestCommentsTable(context);
11 context.ApplyPendingMigrations();
12 }
13
14 private static void EnsureMergeRequestCommentsTable(IForgeMigrationContext context)
15 {
16 if (context.TableExists("merge_request_comments"))
17 return;
18
19 context.ExecuteSql(
20 """
21 CREATE TABLE IF NOT EXISTS "merge_request_comments" (
22 "Id" TEXT PRIMARY KEY,
23 "Author" TEXT NOT NULL,
24 "Body" TEXT NOT NULL,
25 "CreatedAt" TEXT NOT NULL,
26 "MergeRequestId" TEXT NOT NULL,
27 CONSTRAINT "FK_merge_request_comments_merge_requests_MergeRequestId" FOREIGN KEY ("MergeRequestId") REFERENCES "merge_requests" ("Id") ON DELETE CASCADE);
28 """);
29 context.ExecuteSql(
30 """
31 CREATE INDEX IF NOT EXISTS "IX_merge_request_comments_MergeRequestId" ON "merge_request_comments" ("MergeRequestId");
32 """);
33 }
34}
35
View only · write via MCP/CIDE