| 1 | using AgentForge.Data; |
| 2 | using Microsoft.EntityFrameworkCore.Infrastructure; |
| 3 | using Microsoft.EntityFrameworkCore.Migrations; |
| 4 | |
| 5 | #nullable disable |
| 6 | |
| 7 | namespace AgentForge.Data.Migrations |
| 8 | { |
| 9 | [DbContext(typeof(ForgeDbContext))] |
| 10 | [Migration("20260614210000_AddNestedRepoGroups")] |
| 11 | public partial class AddNestedRepoGroups : Migration |
| 12 | { |
| 13 | /// <inheritdoc /> |
| 14 | protected override void Up(MigrationBuilder migrationBuilder) |
| 15 | { |
| 16 | migrationBuilder.AddColumn<string>( |
| 17 | name: "ParentGroupId", |
| 18 | table: "repo_groups", |
| 19 | type: "TEXT", |
| 20 | nullable: true); |
| 21 | |
| 22 | migrationBuilder.CreateIndex( |
| 23 | name: "IX_repo_groups_ParentGroupId", |
| 24 | table: "repo_groups", |
| 25 | column: "ParentGroupId"); |
| 26 | |
| 27 | migrationBuilder.DropIndex( |
| 28 | name: "IX_repo_groups_OrgId_Slug", |
| 29 | table: "repo_groups"); |
| 30 | |
| 31 | migrationBuilder.CreateIndex( |
| 32 | name: "IX_repo_groups_OrgId_Slug", |
| 33 | table: "repo_groups", |
| 34 | columns: ["OrgId", "Slug"], |
| 35 | unique: true, |
| 36 | filter: "ParentGroupId IS NULL"); |
| 37 | |
| 38 | migrationBuilder.CreateIndex( |
| 39 | name: "IX_repo_groups_OrgId_ParentGroupId_Slug", |
| 40 | table: "repo_groups", |
| 41 | columns: ["OrgId", "ParentGroupId", "Slug"], |
| 42 | unique: true, |
| 43 | filter: "ParentGroupId IS NOT NULL"); |
| 44 | |
| 45 | migrationBuilder.AddForeignKey( |
| 46 | name: "FK_repo_groups_repo_groups_ParentGroupId", |
| 47 | table: "repo_groups", |
| 48 | column: "ParentGroupId", |
| 49 | principalTable: "repo_groups", |
| 50 | principalColumn: "Id"); |
| 51 | } |
| 52 | |
| 53 | /// <inheritdoc /> |
| 54 | protected override void Down(MigrationBuilder migrationBuilder) |
| 55 | { |
| 56 | migrationBuilder.DropForeignKey( |
| 57 | name: "FK_repo_groups_repo_groups_ParentGroupId", |
| 58 | table: "repo_groups"); |
| 59 | |
| 60 | migrationBuilder.DropIndex( |
| 61 | name: "IX_repo_groups_OrgId_ParentGroupId_Slug", |
| 62 | table: "repo_groups"); |
| 63 | |
| 64 | migrationBuilder.DropIndex( |
| 65 | name: "IX_repo_groups_OrgId_Slug", |
| 66 | table: "repo_groups"); |
| 67 | |
| 68 | migrationBuilder.DropIndex( |
| 69 | name: "IX_repo_groups_ParentGroupId", |
| 70 | table: "repo_groups"); |
| 71 | |
| 72 | migrationBuilder.DropColumn( |
| 73 | name: "ParentGroupId", |
| 74 | table: "repo_groups"); |
| 75 | |
| 76 | migrationBuilder.CreateIndex( |
| 77 | name: "IX_repo_groups_OrgId_Slug", |
| 78 | table: "repo_groups", |
| 79 | columns: ["OrgId", "Slug"], |
| 80 | unique: true); |
| 81 | } |
| 82 | } |
| 83 | } |
| 84 | |