| 1 | using Microsoft.EntityFrameworkCore.Migrations; |
| 2 | |
| 3 | #nullable disable |
| 4 | |
| 5 | namespace AgentForge.Data.Migrations |
| 6 | { |
| 7 | /// <inheritdoc /> |
| 8 | public partial class Initial : Migration |
| 9 | { |
| 10 | /// <inheritdoc /> |
| 11 | protected override void Up(MigrationBuilder migrationBuilder) |
| 12 | { |
| 13 | migrationBuilder.CreateTable( |
| 14 | name: "api_tokens", |
| 15 | columns: table => new |
| 16 | { |
| 17 | Id = table.Column<string>(type: "TEXT", nullable: false), |
| 18 | CreatedAt = table.Column<string>(type: "TEXT", nullable: false), |
| 19 | Name = table.Column<string>(type: "TEXT", nullable: false), |
| 20 | RevokedAt = table.Column<string>(type: "TEXT", nullable: true), |
| 21 | Scopes = table.Column<string>(type: "TEXT", nullable: false), |
| 22 | TokenHash = table.Column<string>(type: "TEXT", nullable: false) |
| 23 | }, |
| 24 | constraints: table => |
| 25 | { |
| 26 | table.PrimaryKey("PK_api_tokens", x => x.Id); |
| 27 | }); |
| 28 | |
| 29 | migrationBuilder.CreateTable( |
| 30 | name: "ci_runs", |
| 31 | columns: table => new |
| 32 | { |
| 33 | Id = table.Column<string>(type: "TEXT", nullable: false), |
| 34 | Commit = table.Column<string>(type: "TEXT", nullable: false), |
| 35 | CreatedAt = table.Column<string>(type: "TEXT", nullable: false), |
| 36 | MrNumber = table.Column<int>(type: "INT", nullable: true), |
| 37 | RepoId = table.Column<string>(type: "TEXT", nullable: false), |
| 38 | Status = table.Column<string>(type: "TEXT", nullable: false), |
| 39 | UpdatedAt = table.Column<string>(type: "TEXT", nullable: false), |
| 40 | Url = table.Column<string>(type: "TEXT", nullable: false) |
| 41 | }, |
| 42 | constraints: table => |
| 43 | { |
| 44 | table.PrimaryKey("PK_ci_runs", x => x.Id); |
| 45 | table.ForeignKey( |
| 46 | name: "FK_ci_runs_repos_RepoId", |
| 47 | column: x => x.RepoId, |
| 48 | principalTable: "repos", |
| 49 | principalColumn: "Id", |
| 50 | onDelete: ReferentialAction.Cascade); |
| 51 | }); |
| 52 | |
| 53 | migrationBuilder.CreateTable( |
| 54 | name: "commit_provenance", |
| 55 | columns: table => new |
| 56 | { |
| 57 | Id = table.Column<string>(type: "TEXT", nullable: false), |
| 58 | Actor = table.Column<string>(type: "TEXT", nullable: false), |
| 59 | Anchors = table.Column<string>(type: "TEXT", nullable: false), |
| 60 | Branch = table.Column<string>(type: "TEXT", nullable: false), |
| 61 | DriveMode = table.Column<string>(type: "TEXT", nullable: true), |
| 62 | IssueNumbers = table.Column<string>(type: "TEXT", nullable: false), |
| 63 | LogicalLineId = table.Column<string>(type: "TEXT", nullable: true), |
| 64 | MrNumber = table.Column<int>(type: "INT", nullable: true), |
| 65 | RecordedAt = table.Column<string>(type: "TEXT", nullable: false), |
| 66 | RepoId = table.Column<string>(type: "TEXT", nullable: false), |
| 67 | RunId = table.Column<string>(type: "TEXT", nullable: true), |
| 68 | Sha = table.Column<string>(type: "TEXT", nullable: false) |
| 69 | }, |
| 70 | constraints: table => |
| 71 | { |
| 72 | table.PrimaryKey("PK_commit_provenance", x => x.Id); |
| 73 | table.ForeignKey( |
| 74 | name: "FK_commit_provenance_repos_RepoId", |
| 75 | column: x => x.RepoId, |
| 76 | principalTable: "repos", |
| 77 | principalColumn: "Id", |
| 78 | onDelete: ReferentialAction.Cascade); |
| 79 | }); |
| 80 | |
| 81 | migrationBuilder.CreateTable( |
| 82 | name: "device_logins", |
| 83 | columns: table => new |
| 84 | { |
| 85 | Id = table.Column<string>(type: "TEXT", nullable: false), |
| 86 | ApprovedAt = table.Column<string>(type: "TEXT", nullable: true), |
| 87 | ClientName = table.Column<string>(type: "TEXT", nullable: false), |
| 88 | CreatedAt = table.Column<string>(type: "TEXT", nullable: false), |
| 89 | DeviceCodeHash = table.Column<string>(type: "TEXT", nullable: false), |
| 90 | ExpiresAt = table.Column<string>(type: "TEXT", nullable: false), |
| 91 | IssuedTokenPlain = table.Column<string>(type: "TEXT", nullable: true), |
| 92 | Scopes = table.Column<string>(type: "TEXT", nullable: false), |
| 93 | Status = table.Column<int>(type: "INT", nullable: false), |
| 94 | TokenName = table.Column<string>(type: "TEXT", nullable: true), |
| 95 | UserCode = table.Column<string>(type: "TEXT", nullable: false) |
| 96 | }, |
| 97 | constraints: table => |
| 98 | { |
| 99 | table.PrimaryKey("PK_device_logins", x => x.Id); |
| 100 | }); |
| 101 | |
| 102 | migrationBuilder.CreateTable( |
| 103 | name: "identities", |
| 104 | columns: table => new |
| 105 | { |
| 106 | Id = table.Column<string>(type: "TEXT", nullable: false), |
| 107 | CreatedAt = table.Column<string>(type: "TEXT", nullable: false), |
| 108 | DisplayName = table.Column<string>(type: "TEXT", nullable: false), |
| 109 | LastLoginAt = table.Column<string>(type: "TEXT", nullable: false), |
| 110 | Login = table.Column<string>(type: "TEXT", nullable: false), |
| 111 | Provider = table.Column<string>(type: "TEXT", nullable: false), |
| 112 | SubjectId = table.Column<string>(type: "TEXT", nullable: false) |
| 113 | }, |
| 114 | constraints: table => |
| 115 | { |
| 116 | table.PrimaryKey("PK_identities", x => x.Id); |
| 117 | }); |
| 118 | |
| 119 | migrationBuilder.CreateTable( |
| 120 | name: "issue_comments", |
| 121 | columns: table => new |
| 122 | { |
| 123 | Id = table.Column<string>(type: "TEXT", nullable: false), |
| 124 | Author = table.Column<string>(type: "TEXT", nullable: false), |
| 125 | Body = table.Column<string>(type: "TEXT", nullable: false), |
| 126 | CreatedAt = table.Column<string>(type: "TEXT", nullable: false), |
| 127 | IssueId = table.Column<string>(type: "TEXT", nullable: false) |
| 128 | }, |
| 129 | constraints: table => |
| 130 | { |
| 131 | table.PrimaryKey("PK_issue_comments", x => x.Id); |
| 132 | table.ForeignKey( |
| 133 | name: "FK_issue_comments_issues_IssueId", |
| 134 | column: x => x.IssueId, |
| 135 | principalTable: "issues", |
| 136 | principalColumn: "Id", |
| 137 | onDelete: ReferentialAction.Cascade); |
| 138 | }); |
| 139 | |
| 140 | migrationBuilder.CreateTable( |
| 141 | name: "issues", |
| 142 | columns: table => new |
| 143 | { |
| 144 | Id = table.Column<string>(type: "TEXT", nullable: false), |
| 145 | Anchors = table.Column<string>(type: "TEXT", nullable: false), |
| 146 | Body = table.Column<string>(type: "TEXT", nullable: false), |
| 147 | CreatedAt = table.Column<string>(type: "TEXT", nullable: false), |
| 148 | CreatedBy = table.Column<string>(type: "TEXT", nullable: false), |
| 149 | Number = table.Column<int>(type: "INT", nullable: false), |
| 150 | RepoId = table.Column<string>(type: "TEXT", nullable: false), |
| 151 | Status = table.Column<string>(type: "TEXT", nullable: false), |
| 152 | Title = table.Column<string>(type: "TEXT", nullable: false) |
| 153 | }, |
| 154 | constraints: table => |
| 155 | { |
| 156 | table.PrimaryKey("PK_issues", x => x.Id); |
| 157 | table.ForeignKey( |
| 158 | name: "FK_issues_repos_RepoId", |
| 159 | column: x => x.RepoId, |
| 160 | principalTable: "repos", |
| 161 | principalColumn: "Id", |
| 162 | onDelete: ReferentialAction.Cascade); |
| 163 | }); |
| 164 | |
| 165 | migrationBuilder.CreateTable( |
| 166 | name: "merge_request_comments", |
| 167 | columns: table => new |
| 168 | { |
| 169 | Id = table.Column<string>(type: "TEXT", nullable: false), |
| 170 | Author = table.Column<string>(type: "TEXT", nullable: false), |
| 171 | Body = table.Column<string>(type: "TEXT", nullable: false), |
| 172 | CreatedAt = table.Column<string>(type: "TEXT", nullable: false), |
| 173 | MergeRequestId = table.Column<string>(type: "TEXT", nullable: false) |
| 174 | }, |
| 175 | constraints: table => |
| 176 | { |
| 177 | table.PrimaryKey("PK_merge_request_comments", x => x.Id); |
| 178 | table.ForeignKey( |
| 179 | name: "FK_merge_request_comments_merge_requests_MergeRequestId", |
| 180 | column: x => x.MergeRequestId, |
| 181 | principalTable: "merge_requests", |
| 182 | principalColumn: "Id", |
| 183 | onDelete: ReferentialAction.Cascade); |
| 184 | }); |
| 185 | |
| 186 | migrationBuilder.CreateTable( |
| 187 | name: "merge_requests", |
| 188 | columns: table => new |
| 189 | { |
| 190 | Id = table.Column<string>(type: "TEXT", nullable: false), |
| 191 | Anchors = table.Column<string>(type: "TEXT", nullable: false), |
| 192 | CreatedAt = table.Column<string>(type: "TEXT", nullable: false), |
| 193 | CreatedBy = table.Column<string>(type: "TEXT", nullable: false), |
| 194 | Number = table.Column<int>(type: "INT", nullable: false), |
| 195 | RepoId = table.Column<string>(type: "TEXT", nullable: false), |
| 196 | SourceBranch = table.Column<string>(type: "TEXT", nullable: false), |
| 197 | Status = table.Column<string>(type: "TEXT", nullable: false), |
| 198 | TargetBranch = table.Column<string>(type: "TEXT", nullable: false), |
| 199 | Title = table.Column<string>(type: "TEXT", nullable: false) |
| 200 | }, |
| 201 | constraints: table => |
| 202 | { |
| 203 | table.PrimaryKey("PK_merge_requests", x => x.Id); |
| 204 | table.ForeignKey( |
| 205 | name: "FK_merge_requests_repos_RepoId", |
| 206 | column: x => x.RepoId, |
| 207 | principalTable: "repos", |
| 208 | principalColumn: "Id", |
| 209 | onDelete: ReferentialAction.Cascade); |
| 210 | }); |
| 211 | |
| 212 | migrationBuilder.CreateTable( |
| 213 | name: "oauth_states", |
| 214 | columns: table => new |
| 215 | { |
| 216 | Id = table.Column<string>(type: "TEXT", nullable: false), |
| 217 | CodeChallenge = table.Column<string>(type: "TEXT", nullable: true), |
| 218 | CodeChallengeMethod = table.Column<string>(type: "TEXT", nullable: true), |
| 219 | CreatedAt = table.Column<string>(type: "TEXT", nullable: false), |
| 220 | ExpiresAt = table.Column<string>(type: "TEXT", nullable: false), |
| 221 | Provider = table.Column<string>(type: "TEXT", nullable: false), |
| 222 | RedirectUri = table.Column<string>(type: "TEXT", nullable: false), |
| 223 | Scopes = table.Column<string>(type: "TEXT", nullable: false), |
| 224 | State = table.Column<string>(type: "TEXT", nullable: false) |
| 225 | }, |
| 226 | constraints: table => |
| 227 | { |
| 228 | table.PrimaryKey("PK_oauth_states", x => x.Id); |
| 229 | }); |
| 230 | |
| 231 | migrationBuilder.CreateTable( |
| 232 | name: "repos", |
| 233 | columns: table => new |
| 234 | { |
| 235 | Id = table.Column<string>(type: "TEXT", nullable: false), |
| 236 | CreatedAt = table.Column<string>(type: "TEXT", nullable: false), |
| 237 | Description = table.Column<string>(type: "TEXT", nullable: false), |
| 238 | DriveMode = table.Column<string>(type: "TEXT", nullable: false), |
| 239 | Name = table.Column<string>(type: "TEXT", nullable: false) |
| 240 | }, |
| 241 | constraints: table => |
| 242 | { |
| 243 | table.PrimaryKey("PK_repos", x => x.Id); |
| 244 | }); |
| 245 | |
| 246 | migrationBuilder.CreateIndex( |
| 247 | name: "IX_api_tokens_TokenHash", |
| 248 | table: "api_tokens", |
| 249 | column: "TokenHash", |
| 250 | unique: true); |
| 251 | |
| 252 | migrationBuilder.CreateIndex( |
| 253 | name: "IX_ci_runs_RepoId_MrNumber", |
| 254 | table: "ci_runs", |
| 255 | columns: new[] { "RepoId", "MrNumber" }); |
| 256 | |
| 257 | migrationBuilder.CreateIndex( |
| 258 | name: "IX_commit_provenance_RepoId", |
| 259 | table: "commit_provenance", |
| 260 | column: "RepoId"); |
| 261 | |
| 262 | migrationBuilder.CreateIndex( |
| 263 | name: "IX_commit_provenance_RepoId_Sha", |
| 264 | table: "commit_provenance", |
| 265 | columns: new[] { "RepoId", "Sha" }, |
| 266 | unique: true); |
| 267 | |
| 268 | migrationBuilder.CreateIndex( |
| 269 | name: "IX_device_logins_DeviceCodeHash", |
| 270 | table: "device_logins", |
| 271 | column: "DeviceCodeHash", |
| 272 | unique: true); |
| 273 | |
| 274 | migrationBuilder.CreateIndex( |
| 275 | name: "IX_device_logins_UserCode", |
| 276 | table: "device_logins", |
| 277 | column: "UserCode"); |
| 278 | |
| 279 | migrationBuilder.CreateIndex( |
| 280 | name: "IX_identities_Provider_SubjectId", |
| 281 | table: "identities", |
| 282 | columns: new[] { "Provider", "SubjectId" }, |
| 283 | unique: true); |
| 284 | |
| 285 | migrationBuilder.CreateIndex( |
| 286 | name: "IX_issue_comments_IssueId", |
| 287 | table: "issue_comments", |
| 288 | column: "IssueId"); |
| 289 | |
| 290 | migrationBuilder.CreateIndex( |
| 291 | name: "IX_issues_RepoId", |
| 292 | table: "issues", |
| 293 | column: "RepoId"); |
| 294 | |
| 295 | migrationBuilder.CreateIndex( |
| 296 | name: "IX_issues_RepoId_Number", |
| 297 | table: "issues", |
| 298 | columns: new[] { "RepoId", "Number" }, |
| 299 | unique: true); |
| 300 | |
| 301 | migrationBuilder.CreateIndex( |
| 302 | name: "IX_merge_request_comments_MergeRequestId", |
| 303 | table: "merge_request_comments", |
| 304 | column: "MergeRequestId"); |
| 305 | |
| 306 | migrationBuilder.CreateIndex( |
| 307 | name: "IX_merge_requests_RepoId", |
| 308 | table: "merge_requests", |
| 309 | column: "RepoId"); |
| 310 | |
| 311 | migrationBuilder.CreateIndex( |
| 312 | name: "IX_merge_requests_RepoId_Number", |
| 313 | table: "merge_requests", |
| 314 | columns: new[] { "RepoId", "Number" }, |
| 315 | unique: true); |
| 316 | |
| 317 | migrationBuilder.CreateIndex( |
| 318 | name: "IX_oauth_states_State", |
| 319 | table: "oauth_states", |
| 320 | column: "State", |
| 321 | unique: true); |
| 322 | |
| 323 | migrationBuilder.CreateIndex( |
| 324 | name: "IX_repos_Name", |
| 325 | table: "repos", |
| 326 | column: "Name", |
| 327 | unique: true); |
| 328 | } |
| 329 | |
| 330 | /// <inheritdoc /> |
| 331 | protected override void Down(MigrationBuilder migrationBuilder) |
| 332 | { |
| 333 | |
| 334 | } |
| 335 | } |
| 336 | } |
| 337 | |