| | | 1 | | |
| | | 2 | | using Microsoft.EntityFrameworkCore.Migrations; |
| | | 3 | | |
| | | 4 | | #nullable disable |
| | | 5 | | |
| | | 6 | | namespace Elsa.Persistence.EFCore.PostgreSql.Migrations.Management |
| | | 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: "WorkflowDefinitions", |
| | 2 | 24 | | schema: _schema.Schema, |
| | 2 | 25 | | columns: table => new |
| | 2 | 26 | | { |
| | 2 | 27 | | Id = table.Column<string>(type: "text", nullable: false), |
| | 2 | 28 | | DefinitionId = table.Column<string>(type: "text", nullable: false), |
| | 2 | 29 | | Name = table.Column<string>(type: "text", nullable: true), |
| | 2 | 30 | | Description = table.Column<string>(type: "text", nullable: true), |
| | 2 | 31 | | ToolVersion = table.Column<string>(type: "text", nullable: true), |
| | 2 | 32 | | ProviderName = table.Column<string>(type: "text", nullable: true), |
| | 2 | 33 | | MaterializerName = table.Column<string>(type: "text", nullable: false), |
| | 2 | 34 | | MaterializerContext = table.Column<string>(type: "text", nullable: true), |
| | 2 | 35 | | StringData = table.Column<string>(type: "text", nullable: true), |
| | 2 | 36 | | BinaryData = table.Column<byte[]>(type: "bytea", nullable: true), |
| | 2 | 37 | | IsReadonly = table.Column<bool>(type: "boolean", nullable: false), |
| | 2 | 38 | | Data = table.Column<string>(type: "text", nullable: true), |
| | 2 | 39 | | UsableAsActivity = table.Column<bool>(type: "boolean", nullable: true), |
| | 2 | 40 | | CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false), |
| | 2 | 41 | | Version = table.Column<int>(type: "integer", nullable: false), |
| | 2 | 42 | | IsLatest = table.Column<bool>(type: "boolean", nullable: false), |
| | 2 | 43 | | IsPublished = table.Column<bool>(type: "boolean", nullable: false) |
| | 2 | 44 | | }, |
| | 2 | 45 | | constraints: table => |
| | 2 | 46 | | { |
| | 2 | 47 | | table.PrimaryKey("PK_WorkflowDefinitions", x => x.Id); |
| | 4 | 48 | | }); |
| | | 49 | | |
| | 2 | 50 | | migrationBuilder.CreateTable( |
| | 2 | 51 | | name: "WorkflowInstances", |
| | 2 | 52 | | schema: _schema.Schema, |
| | 2 | 53 | | columns: table => new |
| | 2 | 54 | | { |
| | 2 | 55 | | Id = table.Column<string>(type: "text", nullable: false), |
| | 2 | 56 | | DefinitionId = table.Column<string>(type: "text", nullable: false), |
| | 2 | 57 | | DefinitionVersionId = table.Column<string>(type: "text", nullable: false), |
| | 2 | 58 | | Version = table.Column<int>(type: "integer", nullable: false), |
| | 2 | 59 | | Status = table.Column<string>(type: "text", nullable: false), |
| | 2 | 60 | | SubStatus = table.Column<string>(type: "text", nullable: false), |
| | 2 | 61 | | CorrelationId = table.Column<string>(type: "text", nullable: true), |
| | 2 | 62 | | Name = table.Column<string>(type: "text", nullable: true), |
| | 2 | 63 | | IncidentCount = table.Column<int>(type: "integer", nullable: false), |
| | 2 | 64 | | CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false), |
| | 2 | 65 | | UpdatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false), |
| | 2 | 66 | | FinishedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true), |
| | 2 | 67 | | Data = table.Column<string>(type: "text", nullable: true) |
| | 2 | 68 | | }, |
| | 2 | 69 | | constraints: table => |
| | 2 | 70 | | { |
| | 2 | 71 | | table.PrimaryKey("PK_WorkflowInstances", x => x.Id); |
| | 4 | 72 | | }); |
| | | 73 | | |
| | 2 | 74 | | migrationBuilder.CreateIndex( |
| | 2 | 75 | | name: "IX_WorkflowDefinition_DefinitionId_Version", |
| | 2 | 76 | | schema: _schema.Schema, |
| | 2 | 77 | | table: "WorkflowDefinitions", |
| | 2 | 78 | | columns: new[] { "DefinitionId", "Version" }, |
| | 2 | 79 | | unique: true); |
| | | 80 | | |
| | 2 | 81 | | migrationBuilder.CreateIndex( |
| | 2 | 82 | | name: "IX_WorkflowDefinition_IsLatest", |
| | 2 | 83 | | schema: _schema.Schema, |
| | 2 | 84 | | table: "WorkflowDefinitions", |
| | 2 | 85 | | column: "IsLatest"); |
| | | 86 | | |
| | 2 | 87 | | migrationBuilder.CreateIndex( |
| | 2 | 88 | | name: "IX_WorkflowDefinition_IsPublished", |
| | 2 | 89 | | schema: _schema.Schema, |
| | 2 | 90 | | table: "WorkflowDefinitions", |
| | 2 | 91 | | column: "IsPublished"); |
| | | 92 | | |
| | 2 | 93 | | migrationBuilder.CreateIndex( |
| | 2 | 94 | | name: "IX_WorkflowDefinition_Name", |
| | 2 | 95 | | schema: _schema.Schema, |
| | 2 | 96 | | table: "WorkflowDefinitions", |
| | 2 | 97 | | column: "Name"); |
| | | 98 | | |
| | 2 | 99 | | migrationBuilder.CreateIndex( |
| | 2 | 100 | | name: "IX_WorkflowDefinition_UsableAsActivity", |
| | 2 | 101 | | schema: _schema.Schema, |
| | 2 | 102 | | table: "WorkflowDefinitions", |
| | 2 | 103 | | column: "UsableAsActivity"); |
| | | 104 | | |
| | 2 | 105 | | migrationBuilder.CreateIndex( |
| | 2 | 106 | | name: "IX_WorkflowDefinition_Version", |
| | 2 | 107 | | schema: _schema.Schema, |
| | 2 | 108 | | table: "WorkflowDefinitions", |
| | 2 | 109 | | column: "Version"); |
| | | 110 | | |
| | 2 | 111 | | migrationBuilder.CreateIndex( |
| | 2 | 112 | | name: "IX_WorkflowInstance_CorrelationId", |
| | 2 | 113 | | schema: _schema.Schema, |
| | 2 | 114 | | table: "WorkflowInstances", |
| | 2 | 115 | | column: "CorrelationId"); |
| | | 116 | | |
| | 2 | 117 | | migrationBuilder.CreateIndex( |
| | 2 | 118 | | name: "IX_WorkflowInstance_CreatedAt", |
| | 2 | 119 | | schema: _schema.Schema, |
| | 2 | 120 | | table: "WorkflowInstances", |
| | 2 | 121 | | column: "CreatedAt"); |
| | | 122 | | |
| | 2 | 123 | | migrationBuilder.CreateIndex( |
| | 2 | 124 | | name: "IX_WorkflowInstance_DefinitionId", |
| | 2 | 125 | | schema: _schema.Schema, |
| | 2 | 126 | | table: "WorkflowInstances", |
| | 2 | 127 | | column: "DefinitionId"); |
| | | 128 | | |
| | 2 | 129 | | migrationBuilder.CreateIndex( |
| | 2 | 130 | | name: "IX_WorkflowInstance_FinishedAt", |
| | 2 | 131 | | schema: _schema.Schema, |
| | 2 | 132 | | table: "WorkflowInstances", |
| | 2 | 133 | | column: "FinishedAt"); |
| | | 134 | | |
| | 2 | 135 | | migrationBuilder.CreateIndex( |
| | 2 | 136 | | name: "IX_WorkflowInstance_Name", |
| | 2 | 137 | | schema: _schema.Schema, |
| | 2 | 138 | | table: "WorkflowInstances", |
| | 2 | 139 | | column: "Name"); |
| | | 140 | | |
| | 2 | 141 | | migrationBuilder.CreateIndex( |
| | 2 | 142 | | name: "IX_WorkflowInstance_Status", |
| | 2 | 143 | | schema: _schema.Schema, |
| | 2 | 144 | | table: "WorkflowInstances", |
| | 2 | 145 | | column: "Status"); |
| | | 146 | | |
| | 2 | 147 | | migrationBuilder.CreateIndex( |
| | 2 | 148 | | name: "IX_WorkflowInstance_Status_DefinitionId", |
| | 2 | 149 | | schema: _schema.Schema, |
| | 2 | 150 | | table: "WorkflowInstances", |
| | 2 | 151 | | columns: new[] { "Status", "DefinitionId" }); |
| | | 152 | | |
| | 2 | 153 | | migrationBuilder.CreateIndex( |
| | 2 | 154 | | name: "IX_WorkflowInstance_Status_SubStatus", |
| | 2 | 155 | | schema: _schema.Schema, |
| | 2 | 156 | | table: "WorkflowInstances", |
| | 2 | 157 | | columns: new[] { "Status", "SubStatus" }); |
| | | 158 | | |
| | 2 | 159 | | migrationBuilder.CreateIndex( |
| | 2 | 160 | | name: "IX_WorkflowInstance_Status_SubStatus_DefinitionId_Version", |
| | 2 | 161 | | schema: _schema.Schema, |
| | 2 | 162 | | table: "WorkflowInstances", |
| | 2 | 163 | | columns: new[] { "Status", "SubStatus", "DefinitionId", "Version" }); |
| | | 164 | | |
| | 2 | 165 | | migrationBuilder.CreateIndex( |
| | 2 | 166 | | name: "IX_WorkflowInstance_SubStatus", |
| | 2 | 167 | | schema: _schema.Schema, |
| | 2 | 168 | | table: "WorkflowInstances", |
| | 2 | 169 | | column: "SubStatus"); |
| | | 170 | | |
| | 2 | 171 | | migrationBuilder.CreateIndex( |
| | 2 | 172 | | name: "IX_WorkflowInstance_SubStatus_DefinitionId", |
| | 2 | 173 | | schema: _schema.Schema, |
| | 2 | 174 | | table: "WorkflowInstances", |
| | 2 | 175 | | columns: new[] { "SubStatus", "DefinitionId" }); |
| | | 176 | | |
| | 2 | 177 | | migrationBuilder.CreateIndex( |
| | 2 | 178 | | name: "IX_WorkflowInstance_UpdatedAt", |
| | 2 | 179 | | schema: _schema.Schema, |
| | 2 | 180 | | table: "WorkflowInstances", |
| | 2 | 181 | | column: "UpdatedAt"); |
| | 2 | 182 | | } |
| | | 183 | | |
| | | 184 | | /// <inheritdoc /> |
| | | 185 | | protected override void Down(MigrationBuilder migrationBuilder) |
| | | 186 | | { |
| | 0 | 187 | | migrationBuilder.DropTable( |
| | 0 | 188 | | name: "WorkflowDefinitions", |
| | 0 | 189 | | schema: _schema.Schema); |
| | | 190 | | |
| | 0 | 191 | | migrationBuilder.DropTable( |
| | 0 | 192 | | name: "WorkflowInstances", |
| | 0 | 193 | | schema: _schema.Schema); |
| | 0 | 194 | | } |
| | | 195 | | } |
| | | 196 | | } |