diff options
Diffstat (limited to 'src/marlin.web/Migrations/20260903141622_InitialCreate.cs')
| -rw-r--r-- | src/marlin.web/Migrations/20260903141622_InitialCreate.cs | 154 |
1 files changed, 154 insertions, 0 deletions
diff --git a/src/marlin.web/Migrations/20260903141622_InitialCreate.cs b/src/marlin.web/Migrations/20260903141622_InitialCreate.cs new file mode 100644 index 0000000..2ebcc67 --- /dev/null +++ b/src/marlin.web/Migrations/20260903141622_InitialCreate.cs @@ -0,0 +1,154 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace marlin.web.Migrations +{ + /// <inheritdoc /> + public partial class InitialCreate : Migration + { + /// <inheritdoc /> + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "agents", + columns: table => new + { + id = table.Column<Guid>(type: "uuid", nullable: false), + name = table.Column<string>(type: "text", nullable: false), + max_concurrent_jobs = table.Column<int>(type: "integer", nullable: false), + last_seen = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), + capabilities = table.Column<string>(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_agents", x => x.id); + }); + + migrationBuilder.CreateTable( + name: "sources", + columns: table => new + { + id = table.Column<Guid>(type: "uuid", nullable: false), + upstream_url = table.Column<string>(type: "text", nullable: false), + main_branch = table.Column<string>(type: "text", nullable: false), + branch_filter = table.Column<string>(type: "text", nullable: false), + min_polling_interval = table.Column<int>(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_sources", x => x.id); + }); + + migrationBuilder.CreateTable( + name: "jobs", + columns: table => new + { + id = table.Column<Guid>(type: "uuid", nullable: false), + source_id = table.Column<Guid>(type: "uuid", nullable: false), + @ref = table.Column<string>(name: "ref", type: "text", nullable: false), + commit = table.Column<string>(type: "text", nullable: false), + created_reason = table.Column<string>(type: "text", nullable: false), + created_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), + status = table.Column<int>(type: "integer", nullable: false), + agent_id = table.Column<Guid>(type: "uuid", nullable: true), + recipe = table.Column<string>(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_jobs", x => x.id); + table.ForeignKey( + name: "fk_jobs_agents_agent_id", + column: x => x.agent_id, + principalTable: "agents", + principalColumn: "id"); + table.ForeignKey( + name: "fk_jobs_sources_source_id", + column: x => x.source_id, + principalTable: "sources", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "source_branches", + columns: table => new + { + id = table.Column<Guid>(type: "uuid", nullable: false), + source_id = table.Column<Guid>(type: "uuid", nullable: false), + name = table.Column<string>(type: "text", nullable: false), + head_commit = table.Column<string>(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_source_branches", x => x.id); + table.ForeignKey( + name: "fk_source_branches_sources_source_id", + column: x => x.source_id, + principalTable: "sources", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "job_status_update", + columns: table => new + { + id = table.Column<Guid>(type: "uuid", nullable: false), + job_id = table.Column<Guid>(type: "uuid", nullable: false), + at = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), + status = table.Column<int>(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_job_status_update", x => x.id); + table.ForeignKey( + name: "fk_job_status_update_jobs_job_id", + column: x => x.job_id, + principalTable: "jobs", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "ix_job_status_update_job_id", + table: "job_status_update", + column: "job_id"); + + migrationBuilder.CreateIndex( + name: "ix_jobs_agent_id", + table: "jobs", + column: "agent_id"); + + migrationBuilder.CreateIndex( + name: "ix_jobs_source_id", + table: "jobs", + column: "source_id"); + + migrationBuilder.CreateIndex( + name: "ix_source_branches_source_id", + table: "source_branches", + column: "source_id"); + } + + /// <inheritdoc /> + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "job_status_update"); + + migrationBuilder.DropTable( + name: "source_branches"); + + migrationBuilder.DropTable( + name: "jobs"); + + migrationBuilder.DropTable( + name: "agents"); + + migrationBuilder.DropTable( + name: "sources"); + } + } +} |
