| | | 1 | | using Microsoft.EntityFrameworkCore.Migrations; |
| | | 2 | | |
| | | 3 | | #nullable disable |
| | | 4 | | |
| | | 5 | | namespace ProjectTemplate.Infrastructure.Data.Migrations; |
| | | 6 | | |
| | | 7 | | /// <inheritdoc /> |
| | | 8 | | public partial class AddAuditAccountabilityContext : Migration |
| | | 9 | | { |
| | | 10 | | /// <inheritdoc /> |
| | | 11 | | protected override void Up(MigrationBuilder migrationBuilder) |
| | | 12 | | { |
| | 2 | 13 | | migrationBuilder.AddColumn<string>( |
| | 2 | 14 | | name: "ActorId", |
| | 2 | 15 | | table: "AuditRecords", |
| | 2 | 16 | | type: "TEXT", |
| | 2 | 17 | | maxLength: 256, |
| | 2 | 18 | | nullable: false, |
| | 2 | 19 | | defaultValue: "Unknown"); |
| | | 20 | | |
| | 2 | 21 | | migrationBuilder.AddColumn<string>( |
| | 2 | 22 | | name: "ActorType", |
| | 2 | 23 | | table: "AuditRecords", |
| | 2 | 24 | | type: "TEXT", |
| | 2 | 25 | | maxLength: 64, |
| | 2 | 26 | | nullable: false, |
| | 2 | 27 | | defaultValue: "Unknown"); |
| | | 28 | | |
| | 2 | 29 | | migrationBuilder.AddColumn<string>( |
| | 2 | 30 | | name: "CorrelationId", |
| | 2 | 31 | | table: "AuditRecords", |
| | 2 | 32 | | type: "TEXT", |
| | 2 | 33 | | maxLength: 128, |
| | 2 | 34 | | nullable: true); |
| | | 35 | | |
| | 2 | 36 | | migrationBuilder.AddColumn<string>( |
| | 2 | 37 | | name: "DecisionAuditRecordId", |
| | 2 | 38 | | table: "AuditRecords", |
| | 2 | 39 | | type: "TEXT", |
| | 2 | 40 | | maxLength: 128, |
| | 2 | 41 | | nullable: true); |
| | | 42 | | |
| | 2 | 43 | | migrationBuilder.AddColumn<string>( |
| | 2 | 44 | | name: "ExecutionAttemptId", |
| | 2 | 45 | | table: "AuditRecords", |
| | 2 | 46 | | type: "TEXT", |
| | 2 | 47 | | maxLength: 128, |
| | 2 | 48 | | nullable: true); |
| | | 49 | | |
| | 2 | 50 | | migrationBuilder.AddColumn<string>( |
| | 2 | 51 | | name: "MutationBatchId", |
| | 2 | 52 | | table: "AuditRecords", |
| | 2 | 53 | | type: "TEXT", |
| | 2 | 54 | | maxLength: 64, |
| | 2 | 55 | | nullable: false, |
| | 2 | 56 | | defaultValue: "legacy"); |
| | | 57 | | |
| | 2 | 58 | | migrationBuilder.AddColumn<string>( |
| | 2 | 59 | | name: "OperationExecutionId", |
| | 2 | 60 | | table: "AuditRecords", |
| | 2 | 61 | | type: "TEXT", |
| | 2 | 62 | | maxLength: 128, |
| | 2 | 63 | | nullable: true); |
| | | 64 | | |
| | 2 | 65 | | migrationBuilder.AddColumn<string>( |
| | 2 | 66 | | name: "OrganizationHash", |
| | 2 | 67 | | table: "AuditRecords", |
| | 2 | 68 | | type: "TEXT", |
| | 2 | 69 | | maxLength: 128, |
| | 2 | 70 | | nullable: true); |
| | | 71 | | |
| | 2 | 72 | | migrationBuilder.AddColumn<string>( |
| | 2 | 73 | | name: "SchemaVersion", |
| | 2 | 74 | | table: "AuditRecords", |
| | 2 | 75 | | type: "TEXT", |
| | 2 | 76 | | maxLength: 32, |
| | 2 | 77 | | nullable: false, |
| | 2 | 78 | | defaultValue: "1.0"); |
| | | 79 | | |
| | 2 | 80 | | migrationBuilder.AddColumn<string>( |
| | 2 | 81 | | name: "SpanId", |
| | 2 | 82 | | table: "AuditRecords", |
| | 2 | 83 | | type: "TEXT", |
| | 2 | 84 | | maxLength: 32, |
| | 2 | 85 | | nullable: true); |
| | | 86 | | |
| | 2 | 87 | | migrationBuilder.AddColumn<string>( |
| | 2 | 88 | | name: "TenantHash", |
| | 2 | 89 | | table: "AuditRecords", |
| | 2 | 90 | | type: "TEXT", |
| | 2 | 91 | | maxLength: 128, |
| | 2 | 92 | | nullable: true); |
| | | 93 | | |
| | 2 | 94 | | migrationBuilder.AddColumn<string>( |
| | 2 | 95 | | name: "TraceId", |
| | 2 | 96 | | table: "AuditRecords", |
| | 2 | 97 | | type: "TEXT", |
| | 2 | 98 | | maxLength: 64, |
| | 2 | 99 | | nullable: true); |
| | | 100 | | |
| | 2 | 101 | | migrationBuilder.CreateIndex( |
| | 2 | 102 | | name: "IX_AuditRecords_CorrelationId", |
| | 2 | 103 | | table: "AuditRecords", |
| | 2 | 104 | | column: "CorrelationId"); |
| | | 105 | | |
| | 2 | 106 | | migrationBuilder.CreateIndex( |
| | 2 | 107 | | name: "IX_AuditRecords_DecisionAuditRecordId", |
| | 2 | 108 | | table: "AuditRecords", |
| | 2 | 109 | | column: "DecisionAuditRecordId"); |
| | | 110 | | |
| | 2 | 111 | | migrationBuilder.CreateIndex( |
| | 2 | 112 | | name: "IX_AuditRecords_MutationBatchId", |
| | 2 | 113 | | table: "AuditRecords", |
| | 2 | 114 | | column: "MutationBatchId"); |
| | | 115 | | |
| | 2 | 116 | | migrationBuilder.CreateIndex( |
| | 2 | 117 | | name: "IX_AuditRecords_OperationExecutionId", |
| | 2 | 118 | | table: "AuditRecords", |
| | 2 | 119 | | column: "OperationExecutionId"); |
| | 2 | 120 | | } |
| | | 121 | | |
| | | 122 | | /// <inheritdoc /> |
| | | 123 | | protected override void Down(MigrationBuilder migrationBuilder) |
| | | 124 | | { |
| | 2 | 125 | | migrationBuilder.DropIndex( |
| | 2 | 126 | | name: "IX_AuditRecords_CorrelationId", |
| | 2 | 127 | | table: "AuditRecords"); |
| | | 128 | | |
| | 2 | 129 | | migrationBuilder.DropIndex( |
| | 2 | 130 | | name: "IX_AuditRecords_DecisionAuditRecordId", |
| | 2 | 131 | | table: "AuditRecords"); |
| | | 132 | | |
| | 2 | 133 | | migrationBuilder.DropIndex( |
| | 2 | 134 | | name: "IX_AuditRecords_MutationBatchId", |
| | 2 | 135 | | table: "AuditRecords"); |
| | | 136 | | |
| | 2 | 137 | | migrationBuilder.DropIndex( |
| | 2 | 138 | | name: "IX_AuditRecords_OperationExecutionId", |
| | 2 | 139 | | table: "AuditRecords"); |
| | | 140 | | |
| | 2 | 141 | | migrationBuilder.DropColumn(name: "ActorId", table: "AuditRecords"); |
| | 2 | 142 | | migrationBuilder.DropColumn(name: "ActorType", table: "AuditRecords"); |
| | 2 | 143 | | migrationBuilder.DropColumn(name: "CorrelationId", table: "AuditRecords"); |
| | 2 | 144 | | migrationBuilder.DropColumn(name: "DecisionAuditRecordId", table: "AuditRecords"); |
| | 2 | 145 | | migrationBuilder.DropColumn(name: "ExecutionAttemptId", table: "AuditRecords"); |
| | 2 | 146 | | migrationBuilder.DropColumn(name: "MutationBatchId", table: "AuditRecords"); |
| | 2 | 147 | | migrationBuilder.DropColumn(name: "OperationExecutionId", table: "AuditRecords"); |
| | 2 | 148 | | migrationBuilder.DropColumn(name: "OrganizationHash", table: "AuditRecords"); |
| | 2 | 149 | | migrationBuilder.DropColumn(name: "SchemaVersion", table: "AuditRecords"); |
| | 2 | 150 | | migrationBuilder.DropColumn(name: "SpanId", table: "AuditRecords"); |
| | 2 | 151 | | migrationBuilder.DropColumn(name: "TenantHash", table: "AuditRecords"); |
| | 2 | 152 | | migrationBuilder.DropColumn(name: "TraceId", table: "AuditRecords"); |
| | 2 | 153 | | } |
| | | 154 | | } |