using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace marlin.web.Migrations { /// public partial class InitialCreate : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "agents", columns: table => new { id = table.Column(type: "uuid", nullable: false), name = table.Column(type: "text", nullable: false), max_concurrent_jobs = table.Column(type: "integer", nullable: false), last_seen = table.Column(type: "timestamp with time zone", nullable: false), capabilities = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("pk_agents", x => x.id); }); migrationBuilder.CreateTable( name: "sources", columns: table => new { id = table.Column(type: "uuid", nullable: false), upstream_url = table.Column(type: "text", nullable: false), main_branch = table.Column(type: "text", nullable: false), branch_filter = table.Column(type: "text", nullable: false), min_polling_interval = table.Column(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("pk_sources", x => x.id); }); migrationBuilder.CreateTable( name: "jobs", columns: table => new { id = table.Column(type: "uuid", nullable: false), source_id = table.Column(type: "uuid", nullable: false), @ref = table.Column(name: "ref", type: "text", nullable: false), commit = table.Column(type: "text", nullable: false), created_reason = table.Column(type: "text", nullable: false), created_at = table.Column(type: "timestamp with time zone", nullable: false), status = table.Column(type: "integer", nullable: false), agent_id = table.Column(type: "uuid", nullable: true), recipe = table.Column(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(type: "uuid", nullable: false), source_id = table.Column(type: "uuid", nullable: false), name = table.Column(type: "text", nullable: false), head_commit = table.Column(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(type: "uuid", nullable: false), job_id = table.Column(type: "uuid", nullable: false), at = table.Column(type: "timestamp with time zone", nullable: false), status = table.Column(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"); } /// 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"); } } }