| | | 1 | | |
| | | 2 | | using Microsoft.EntityFrameworkCore.Migrations; |
| | | 3 | | |
| | | 4 | | #nullable disable |
| | | 5 | | |
| | | 6 | | namespace Elsa.Persistence.EFCore.PostgreSql.Migrations.Alterations |
| | | 7 | | { |
| | | 8 | | /// <inheritdoc /> |
| | | 9 | | public partial class Initial : Migration |
| | | 10 | | { |
| | | 11 | | private readonly IElsaDbContextSchema _schema; |
| | 2 | 12 | | public Initial(IElsaDbContextSchema schema) |
| | | 13 | | { |
| | 2 | 14 | | _schema = schema ?? throw new ArgumentNullException(nameof(schema)); |
| | 2 | 15 | | } |
| | | 16 | | /// <inheritdoc /> |
| | | 17 | | protected override void Up(MigrationBuilder migrationBuilder) |
| | | 18 | | { |
| | 2 | 19 | | migrationBuilder.EnsureSchema( |
| | 2 | 20 | | name: _schema.Schema); |
| | | 21 | | |
| | 2 | 22 | | migrationBuilder.CreateTable( |
| | 2 | 23 | | name: "AlterationJobs", |
| | 2 | 24 | | schema: _schema.Schema, |
| | 2 | 25 | | columns: table => new |
| | 2 | 26 | | { |
| | 2 | 27 | | Id = table.Column<string>(type: "text", nullable: false), |
| | 2 | 28 | | PlanId = table.Column<string>(type: "text", nullable: false), |
| | 2 | 29 | | WorkflowInstanceId = table.Column<string>(type: "text", nullable: false), |
| | 2 | 30 | | Status = table.Column<int>(type: "integer", nullable: false), |
| | 2 | 31 | | CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false), |
| | 2 | 32 | | StartedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true), |
| | 2 | 33 | | CompletedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true), |
| | 2 | 34 | | SerializedLog = table.Column<string>(type: "text", nullable: true) |
| | 2 | 35 | | }, |
| | 2 | 36 | | constraints: table => |
| | 2 | 37 | | { |
| | 2 | 38 | | table.PrimaryKey("PK_AlterationJobs", x => x.Id); |
| | 4 | 39 | | }); |
| | | 40 | | |
| | 2 | 41 | | migrationBuilder.CreateTable( |
| | 2 | 42 | | name: "AlterationPlans", |
| | 2 | 43 | | schema: _schema.Schema, |
| | 2 | 44 | | columns: table => new |
| | 2 | 45 | | { |
| | 2 | 46 | | Id = table.Column<string>(type: "text", nullable: false), |
| | 2 | 47 | | Status = table.Column<int>(type: "integer", nullable: false), |
| | 2 | 48 | | CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false), |
| | 2 | 49 | | StartedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true), |
| | 2 | 50 | | CompletedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true), |
| | 2 | 51 | | SerializedAlterations = table.Column<string>(type: "text", nullable: true), |
| | 2 | 52 | | SerializedWorkflowInstanceIds = table.Column<string>(type: "text", nullable: true) |
| | 2 | 53 | | }, |
| | 2 | 54 | | constraints: table => |
| | 2 | 55 | | { |
| | 2 | 56 | | table.PrimaryKey("PK_AlterationPlans", x => x.Id); |
| | 4 | 57 | | }); |
| | | 58 | | |
| | 2 | 59 | | migrationBuilder.CreateIndex( |
| | 2 | 60 | | name: "IX_AlterationJob_CompletedAt", |
| | 2 | 61 | | schema: _schema.Schema, |
| | 2 | 62 | | table: "AlterationJobs", |
| | 2 | 63 | | column: "CompletedAt"); |
| | | 64 | | |
| | 2 | 65 | | migrationBuilder.CreateIndex( |
| | 2 | 66 | | name: "IX_AlterationJob_CreatedAt", |
| | 2 | 67 | | schema: _schema.Schema, |
| | 2 | 68 | | table: "AlterationJobs", |
| | 2 | 69 | | column: "CreatedAt"); |
| | | 70 | | |
| | 2 | 71 | | migrationBuilder.CreateIndex( |
| | 2 | 72 | | name: "IX_AlterationJob_PlanId", |
| | 2 | 73 | | schema: _schema.Schema, |
| | 2 | 74 | | table: "AlterationJobs", |
| | 2 | 75 | | column: "PlanId"); |
| | | 76 | | |
| | 2 | 77 | | migrationBuilder.CreateIndex( |
| | 2 | 78 | | name: "IX_AlterationJob_StartedAt", |
| | 2 | 79 | | schema: _schema.Schema, |
| | 2 | 80 | | table: "AlterationJobs", |
| | 2 | 81 | | column: "StartedAt"); |
| | | 82 | | |
| | 2 | 83 | | migrationBuilder.CreateIndex( |
| | 2 | 84 | | name: "IX_AlterationJob_Status", |
| | 2 | 85 | | schema: _schema.Schema, |
| | 2 | 86 | | table: "AlterationJobs", |
| | 2 | 87 | | column: "Status"); |
| | | 88 | | |
| | 2 | 89 | | migrationBuilder.CreateIndex( |
| | 2 | 90 | | name: "IX_AlterationJob_WorkflowInstanceId", |
| | 2 | 91 | | schema: _schema.Schema, |
| | 2 | 92 | | table: "AlterationJobs", |
| | 2 | 93 | | column: "WorkflowInstanceId"); |
| | | 94 | | |
| | 2 | 95 | | migrationBuilder.CreateIndex( |
| | 2 | 96 | | name: "IX_AlterationPlan_CompletedAt", |
| | 2 | 97 | | schema: _schema.Schema, |
| | 2 | 98 | | table: "AlterationPlans", |
| | 2 | 99 | | column: "CompletedAt"); |
| | | 100 | | |
| | 2 | 101 | | migrationBuilder.CreateIndex( |
| | 2 | 102 | | name: "IX_AlterationPlan_CreatedAt", |
| | 2 | 103 | | schema: _schema.Schema, |
| | 2 | 104 | | table: "AlterationPlans", |
| | 2 | 105 | | column: "CreatedAt"); |
| | | 106 | | |
| | 2 | 107 | | migrationBuilder.CreateIndex( |
| | 2 | 108 | | name: "IX_AlterationPlan_StartedAt", |
| | 2 | 109 | | schema: _schema.Schema, |
| | 2 | 110 | | table: "AlterationPlans", |
| | 2 | 111 | | column: "StartedAt"); |
| | | 112 | | |
| | 2 | 113 | | migrationBuilder.CreateIndex( |
| | 2 | 114 | | name: "IX_AlterationPlan_Status", |
| | 2 | 115 | | schema: _schema.Schema, |
| | 2 | 116 | | table: "AlterationPlans", |
| | 2 | 117 | | column: "Status"); |
| | 2 | 118 | | } |
| | | 119 | | |
| | | 120 | | /// <inheritdoc /> |
| | | 121 | | protected override void Down(MigrationBuilder migrationBuilder) |
| | | 122 | | { |
| | 0 | 123 | | migrationBuilder.DropTable( |
| | 0 | 124 | | name: "AlterationJobs", |
| | 0 | 125 | | schema: _schema.Schema); |
| | | 126 | | |
| | 0 | 127 | | migrationBuilder.DropTable( |
| | 0 | 128 | | name: "AlterationPlans", |
| | 0 | 129 | | schema: _schema.Schema); |
| | 0 | 130 | | } |
| | | 131 | | } |
| | | 132 | | } |