|
| 1 | +#nullable disable |
| 2 | + |
| 3 | +namespace ServiceControl.Persistence.Sql.MySQL.Migrations |
| 4 | +{ |
| 5 | + using System; |
| 6 | + using Microsoft.EntityFrameworkCore.Metadata; |
| 7 | + using Microsoft.EntityFrameworkCore.Migrations; |
| 8 | + |
| 9 | + /// <inheritdoc /> |
| 10 | + public partial class InitialCreate : Migration |
| 11 | + { |
| 12 | + /// <inheritdoc /> |
| 13 | + protected override void Up(MigrationBuilder migrationBuilder) |
| 14 | + { |
| 15 | + migrationBuilder.AlterDatabase() |
| 16 | + .Annotation("MySql:CharSet", "utf8mb4"); |
| 17 | + |
| 18 | + migrationBuilder.CreateTable( |
| 19 | + name: "DailyThroughput", |
| 20 | + columns: table => new |
| 21 | + { |
| 22 | + Id = table.Column<int>(type: "int", nullable: false) |
| 23 | + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), |
| 24 | + EndpointName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false) |
| 25 | + .Annotation("MySql:CharSet", "utf8mb4"), |
| 26 | + ThroughputSource = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false) |
| 27 | + .Annotation("MySql:CharSet", "utf8mb4"), |
| 28 | + Date = table.Column<DateOnly>(type: "date", nullable: false), |
| 29 | + MessageCount = table.Column<long>(type: "bigint", nullable: false) |
| 30 | + }, |
| 31 | + constraints: table => |
| 32 | + { |
| 33 | + table.PrimaryKey("PK_DailyThroughput", x => x.Id); |
| 34 | + }) |
| 35 | + .Annotation("MySql:CharSet", "utf8mb4"); |
| 36 | + |
| 37 | + migrationBuilder.CreateTable( |
| 38 | + name: "LicensingMetadata", |
| 39 | + columns: table => new |
| 40 | + { |
| 41 | + Id = table.Column<int>(type: "int", nullable: false) |
| 42 | + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), |
| 43 | + Key = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false) |
| 44 | + .Annotation("MySql:CharSet", "utf8mb4"), |
| 45 | + Data = table.Column<string>(type: "varchar(2000)", maxLength: 2000, nullable: false) |
| 46 | + .Annotation("MySql:CharSet", "utf8mb4") |
| 47 | + }, |
| 48 | + constraints: table => |
| 49 | + { |
| 50 | + table.PrimaryKey("PK_LicensingMetadata", x => x.Id); |
| 51 | + }) |
| 52 | + .Annotation("MySql:CharSet", "utf8mb4"); |
| 53 | + |
| 54 | + migrationBuilder.CreateTable( |
| 55 | + name: "ThroughputEndpoint", |
| 56 | + columns: table => new |
| 57 | + { |
| 58 | + Id = table.Column<int>(type: "int", nullable: false) |
| 59 | + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), |
| 60 | + EndpointName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false) |
| 61 | + .Annotation("MySql:CharSet", "utf8mb4"), |
| 62 | + ThroughputSource = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false) |
| 63 | + .Annotation("MySql:CharSet", "utf8mb4"), |
| 64 | + SanitizedEndpointName = table.Column<string>(type: "longtext", nullable: true) |
| 65 | + .Annotation("MySql:CharSet", "utf8mb4"), |
| 66 | + EndpointIndicators = table.Column<string>(type: "longtext", nullable: true) |
| 67 | + .Annotation("MySql:CharSet", "utf8mb4"), |
| 68 | + UserIndicator = table.Column<string>(type: "longtext", nullable: true) |
| 69 | + .Annotation("MySql:CharSet", "utf8mb4"), |
| 70 | + Scope = table.Column<string>(type: "longtext", nullable: true) |
| 71 | + .Annotation("MySql:CharSet", "utf8mb4"), |
| 72 | + LastCollectedData = table.Column<DateOnly>(type: "date", nullable: false) |
| 73 | + }, |
| 74 | + constraints: table => |
| 75 | + { |
| 76 | + table.PrimaryKey("PK_ThroughputEndpoint", x => x.Id); |
| 77 | + }) |
| 78 | + .Annotation("MySql:CharSet", "utf8mb4"); |
| 79 | + |
| 80 | + migrationBuilder.CreateTable( |
| 81 | + name: "TrialLicense", |
| 82 | + columns: table => new |
| 83 | + { |
| 84 | + Id = table.Column<int>(type: "int", nullable: false, defaultValue: 1), |
| 85 | + TrialEndDate = table.Column<DateOnly>(type: "date", nullable: false) |
| 86 | + }, |
| 87 | + constraints: table => |
| 88 | + { |
| 89 | + table.PrimaryKey("PK_TrialLicense", x => x.Id); |
| 90 | + }) |
| 91 | + .Annotation("MySql:CharSet", "utf8mb4"); |
| 92 | + |
| 93 | + migrationBuilder.CreateIndex( |
| 94 | + name: "UC_DailyThroughput_EndpointName_ThroughputSource_Date", |
| 95 | + table: "DailyThroughput", |
| 96 | + columns: new[] { "EndpointName", "ThroughputSource", "Date" }, |
| 97 | + unique: true); |
| 98 | + |
| 99 | + migrationBuilder.CreateIndex( |
| 100 | + name: "IX_LicensingMetadata_Key", |
| 101 | + table: "LicensingMetadata", |
| 102 | + column: "Key", |
| 103 | + unique: true); |
| 104 | + |
| 105 | + migrationBuilder.CreateIndex( |
| 106 | + name: "UC_ThroughputEndpoint_EndpointName_ThroughputSource", |
| 107 | + table: "ThroughputEndpoint", |
| 108 | + columns: new[] { "EndpointName", "ThroughputSource" }, |
| 109 | + unique: true); |
| 110 | + } |
| 111 | + |
| 112 | + /// <inheritdoc /> |
| 113 | + protected override void Down(MigrationBuilder migrationBuilder) |
| 114 | + { |
| 115 | + migrationBuilder.DropTable( |
| 116 | + name: "DailyThroughput"); |
| 117 | + |
| 118 | + migrationBuilder.DropTable( |
| 119 | + name: "LicensingMetadata"); |
| 120 | + |
| 121 | + migrationBuilder.DropTable( |
| 122 | + name: "ThroughputEndpoint"); |
| 123 | + |
| 124 | + migrationBuilder.DropTable( |
| 125 | + name: "TrialLicense"); |
| 126 | + } |
| 127 | + } |
| 128 | +} |
0 commit comments