| | | 1 | | using Microsoft.EntityFrameworkCore.Migrations; |
| | | 2 | | |
| | | 3 | | #nullable disable |
| | | 4 | | |
| | | 5 | | namespace Chronicis.Api.Migrations |
| | | 6 | | { |
| | | 7 | | /// <inheritdoc /> |
| | | 8 | | public partial class InitialGuidSchema : Migration |
| | | 9 | | { |
| | | 10 | | /// <inheritdoc /> |
| | | 11 | | protected override void Up(MigrationBuilder migrationBuilder) |
| | | 12 | | { |
| | 0 | 13 | | migrationBuilder.CreateTable( |
| | 0 | 14 | | name: "Users", |
| | 0 | 15 | | columns: table => new |
| | 0 | 16 | | { |
| | 0 | 17 | | Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
| | 0 | 18 | | Auth0UserId = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false), |
| | 0 | 19 | | Email = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false), |
| | 0 | 20 | | DisplayName = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false), |
| | 0 | 21 | | AvatarUrl = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true), |
| | 0 | 22 | | CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false), |
| | 0 | 23 | | LastLoginAt = table.Column<DateTime>(type: "datetime2", nullable: false) |
| | 0 | 24 | | }, |
| | 0 | 25 | | constraints: table => |
| | 0 | 26 | | { |
| | 0 | 27 | | table.PrimaryKey("PK_Users", x => x.Id); |
| | 0 | 28 | | }); |
| | | 29 | | |
| | 0 | 30 | | migrationBuilder.CreateTable( |
| | 0 | 31 | | name: "Worlds", |
| | 0 | 32 | | columns: table => new |
| | 0 | 33 | | { |
| | 0 | 34 | | Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
| | 0 | 35 | | Name = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false), |
| | 0 | 36 | | Description = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: true), |
| | 0 | 37 | | OwnerId = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
| | 0 | 38 | | CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false) |
| | 0 | 39 | | }, |
| | 0 | 40 | | constraints: table => |
| | 0 | 41 | | { |
| | 0 | 42 | | table.PrimaryKey("PK_Worlds", x => x.Id); |
| | 0 | 43 | | table.ForeignKey( |
| | 0 | 44 | | name: "FK_Worlds_Users_OwnerId", |
| | 0 | 45 | | column: x => x.OwnerId, |
| | 0 | 46 | | principalTable: "Users", |
| | 0 | 47 | | principalColumn: "Id", |
| | 0 | 48 | | onDelete: ReferentialAction.Restrict); |
| | 0 | 49 | | }); |
| | | 50 | | |
| | 0 | 51 | | migrationBuilder.CreateTable( |
| | 0 | 52 | | name: "Campaigns", |
| | 0 | 53 | | columns: table => new |
| | 0 | 54 | | { |
| | 0 | 55 | | Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
| | 0 | 56 | | WorldId = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
| | 0 | 57 | | Name = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false), |
| | 0 | 58 | | Description = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: true), |
| | 0 | 59 | | OwnerId = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
| | 0 | 60 | | CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false), |
| | 0 | 61 | | StartedAt = table.Column<DateTime>(type: "datetime2", nullable: true), |
| | 0 | 62 | | EndedAt = table.Column<DateTime>(type: "datetime2", nullable: true) |
| | 0 | 63 | | }, |
| | 0 | 64 | | constraints: table => |
| | 0 | 65 | | { |
| | 0 | 66 | | table.PrimaryKey("PK_Campaigns", x => x.Id); |
| | 0 | 67 | | table.ForeignKey( |
| | 0 | 68 | | name: "FK_Campaigns_Users_OwnerId", |
| | 0 | 69 | | column: x => x.OwnerId, |
| | 0 | 70 | | principalTable: "Users", |
| | 0 | 71 | | principalColumn: "Id", |
| | 0 | 72 | | onDelete: ReferentialAction.Restrict); |
| | 0 | 73 | | table.ForeignKey( |
| | 0 | 74 | | name: "FK_Campaigns_Worlds_WorldId", |
| | 0 | 75 | | column: x => x.WorldId, |
| | 0 | 76 | | principalTable: "Worlds", |
| | 0 | 77 | | principalColumn: "Id", |
| | 0 | 78 | | onDelete: ReferentialAction.Restrict); |
| | 0 | 79 | | }); |
| | | 80 | | |
| | 0 | 81 | | migrationBuilder.CreateTable( |
| | 0 | 82 | | name: "Articles", |
| | 0 | 83 | | columns: table => new |
| | 0 | 84 | | { |
| | 0 | 85 | | Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
| | 0 | 86 | | ParentId = table.Column<Guid>(type: "uniqueidentifier", nullable: true), |
| | 0 | 87 | | WorldId = table.Column<Guid>(type: "uniqueidentifier", nullable: true), |
| | 0 | 88 | | CampaignId = table.Column<Guid>(type: "uniqueidentifier", nullable: true), |
| | 0 | 89 | | Title = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: false), |
| | 0 | 90 | | Slug = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false), |
| | 0 | 91 | | Body = table.Column<string>(type: "nvarchar(max)", nullable: true), |
| | 0 | 92 | | IconEmoji = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true), |
| | 0 | 93 | | Type = table.Column<int>(type: "int", nullable: false), |
| | 0 | 94 | | Visibility = table.Column<int>(type: "int", nullable: false), |
| | 0 | 95 | | CreatedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
| | 0 | 96 | | LastModifiedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: true), |
| | 0 | 97 | | CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false), |
| | 0 | 98 | | ModifiedAt = table.Column<DateTime>(type: "datetime2", nullable: true), |
| | 0 | 99 | | SessionDate = table.Column<DateTime>(type: "datetime2", nullable: true), |
| | 0 | 100 | | InGameDate = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true), |
| | 0 | 101 | | PlayerId = table.Column<Guid>(type: "uniqueidentifier", nullable: true), |
| | 0 | 102 | | AISummary = table.Column<string>(type: "nvarchar(max)", nullable: true), |
| | 0 | 103 | | AISummaryGeneratedAt = table.Column<DateTime>(type: "datetime2", nullable: true), |
| | 0 | 104 | | EffectiveDate = table.Column<DateTime>(type: "datetime2", nullable: false) |
| | 0 | 105 | | }, |
| | 0 | 106 | | constraints: table => |
| | 0 | 107 | | { |
| | 0 | 108 | | table.PrimaryKey("PK_Articles", x => x.Id); |
| | 0 | 109 | | table.ForeignKey( |
| | 0 | 110 | | name: "FK_Articles_Articles_ParentId", |
| | 0 | 111 | | column: x => x.ParentId, |
| | 0 | 112 | | principalTable: "Articles", |
| | 0 | 113 | | principalColumn: "Id", |
| | 0 | 114 | | onDelete: ReferentialAction.Restrict); |
| | 0 | 115 | | table.ForeignKey( |
| | 0 | 116 | | name: "FK_Articles_Campaigns_CampaignId", |
| | 0 | 117 | | column: x => x.CampaignId, |
| | 0 | 118 | | principalTable: "Campaigns", |
| | 0 | 119 | | principalColumn: "Id", |
| | 0 | 120 | | onDelete: ReferentialAction.Restrict); |
| | 0 | 121 | | table.ForeignKey( |
| | 0 | 122 | | name: "FK_Articles_Users_CreatedBy", |
| | 0 | 123 | | column: x => x.CreatedBy, |
| | 0 | 124 | | principalTable: "Users", |
| | 0 | 125 | | principalColumn: "Id", |
| | 0 | 126 | | onDelete: ReferentialAction.Restrict); |
| | 0 | 127 | | table.ForeignKey( |
| | 0 | 128 | | name: "FK_Articles_Users_LastModifiedBy", |
| | 0 | 129 | | column: x => x.LastModifiedBy, |
| | 0 | 130 | | principalTable: "Users", |
| | 0 | 131 | | principalColumn: "Id", |
| | 0 | 132 | | onDelete: ReferentialAction.Restrict); |
| | 0 | 133 | | table.ForeignKey( |
| | 0 | 134 | | name: "FK_Articles_Users_PlayerId", |
| | 0 | 135 | | column: x => x.PlayerId, |
| | 0 | 136 | | principalTable: "Users", |
| | 0 | 137 | | principalColumn: "Id", |
| | 0 | 138 | | onDelete: ReferentialAction.Restrict); |
| | 0 | 139 | | table.ForeignKey( |
| | 0 | 140 | | name: "FK_Articles_Worlds_WorldId", |
| | 0 | 141 | | column: x => x.WorldId, |
| | 0 | 142 | | principalTable: "Worlds", |
| | 0 | 143 | | principalColumn: "Id", |
| | 0 | 144 | | onDelete: ReferentialAction.Restrict); |
| | 0 | 145 | | }); |
| | | 146 | | |
| | 0 | 147 | | migrationBuilder.CreateTable( |
| | 0 | 148 | | name: "CampaignMembers", |
| | 0 | 149 | | columns: table => new |
| | 0 | 150 | | { |
| | 0 | 151 | | Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
| | 0 | 152 | | CampaignId = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
| | 0 | 153 | | UserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
| | 0 | 154 | | Role = table.Column<int>(type: "int", nullable: false), |
| | 0 | 155 | | JoinedAt = table.Column<DateTime>(type: "datetime2", nullable: false), |
| | 0 | 156 | | CharacterName = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true) |
| | 0 | 157 | | }, |
| | 0 | 158 | | constraints: table => |
| | 0 | 159 | | { |
| | 0 | 160 | | table.PrimaryKey("PK_CampaignMembers", x => x.Id); |
| | 0 | 161 | | table.ForeignKey( |
| | 0 | 162 | | name: "FK_CampaignMembers_Campaigns_CampaignId", |
| | 0 | 163 | | column: x => x.CampaignId, |
| | 0 | 164 | | principalTable: "Campaigns", |
| | 0 | 165 | | principalColumn: "Id", |
| | 0 | 166 | | onDelete: ReferentialAction.Cascade); |
| | 0 | 167 | | table.ForeignKey( |
| | 0 | 168 | | name: "FK_CampaignMembers_Users_UserId", |
| | 0 | 169 | | column: x => x.UserId, |
| | 0 | 170 | | principalTable: "Users", |
| | 0 | 171 | | principalColumn: "Id", |
| | 0 | 172 | | onDelete: ReferentialAction.Cascade); |
| | 0 | 173 | | }); |
| | | 174 | | |
| | 0 | 175 | | migrationBuilder.CreateTable( |
| | 0 | 176 | | name: "Hashtags", |
| | 0 | 177 | | columns: table => new |
| | 0 | 178 | | { |
| | 0 | 179 | | Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
| | 0 | 180 | | Name = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false), |
| | 0 | 181 | | LinkedArticleId = table.Column<Guid>(type: "uniqueidentifier", nullable: true), |
| | 0 | 182 | | CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false) |
| | 0 | 183 | | }, |
| | 0 | 184 | | constraints: table => |
| | 0 | 185 | | { |
| | 0 | 186 | | table.PrimaryKey("PK_Hashtags", x => x.Id); |
| | 0 | 187 | | table.ForeignKey( |
| | 0 | 188 | | name: "FK_Hashtags_Articles_LinkedArticleId", |
| | 0 | 189 | | column: x => x.LinkedArticleId, |
| | 0 | 190 | | principalTable: "Articles", |
| | 0 | 191 | | principalColumn: "Id", |
| | 0 | 192 | | onDelete: ReferentialAction.SetNull); |
| | 0 | 193 | | }); |
| | | 194 | | |
| | 0 | 195 | | migrationBuilder.CreateTable( |
| | 0 | 196 | | name: "ArticleHashtags", |
| | 0 | 197 | | columns: table => new |
| | 0 | 198 | | { |
| | 0 | 199 | | Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
| | 0 | 200 | | ArticleId = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
| | 0 | 201 | | HashtagId = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
| | 0 | 202 | | Position = table.Column<int>(type: "int", nullable: false), |
| | 0 | 203 | | CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false) |
| | 0 | 204 | | }, |
| | 0 | 205 | | constraints: table => |
| | 0 | 206 | | { |
| | 0 | 207 | | table.PrimaryKey("PK_ArticleHashtags", x => x.Id); |
| | 0 | 208 | | table.ForeignKey( |
| | 0 | 209 | | name: "FK_ArticleHashtags_Articles_ArticleId", |
| | 0 | 210 | | column: x => x.ArticleId, |
| | 0 | 211 | | principalTable: "Articles", |
| | 0 | 212 | | principalColumn: "Id", |
| | 0 | 213 | | onDelete: ReferentialAction.Cascade); |
| | 0 | 214 | | table.ForeignKey( |
| | 0 | 215 | | name: "FK_ArticleHashtags_Hashtags_HashtagId", |
| | 0 | 216 | | column: x => x.HashtagId, |
| | 0 | 217 | | principalTable: "Hashtags", |
| | 0 | 218 | | principalColumn: "Id", |
| | 0 | 219 | | onDelete: ReferentialAction.Cascade); |
| | 0 | 220 | | }); |
| | | 221 | | |
| | 0 | 222 | | migrationBuilder.CreateIndex( |
| | 0 | 223 | | name: "IX_ArticleHashtags_ArticleId_HashtagId", |
| | 0 | 224 | | table: "ArticleHashtags", |
| | 0 | 225 | | columns: new[] { "ArticleId", "HashtagId" }, |
| | 0 | 226 | | unique: true); |
| | | 227 | | |
| | 0 | 228 | | migrationBuilder.CreateIndex( |
| | 0 | 229 | | name: "IX_ArticleHashtags_HashtagId", |
| | 0 | 230 | | table: "ArticleHashtags", |
| | 0 | 231 | | column: "HashtagId"); |
| | | 232 | | |
| | 0 | 233 | | migrationBuilder.CreateIndex( |
| | 0 | 234 | | name: "IX_Articles_CampaignId", |
| | 0 | 235 | | table: "Articles", |
| | 0 | 236 | | column: "CampaignId"); |
| | | 237 | | |
| | 0 | 238 | | migrationBuilder.CreateIndex( |
| | 0 | 239 | | name: "IX_Articles_CreatedBy", |
| | 0 | 240 | | table: "Articles", |
| | 0 | 241 | | column: "CreatedBy"); |
| | | 242 | | |
| | 0 | 243 | | migrationBuilder.CreateIndex( |
| | 0 | 244 | | name: "IX_Articles_LastModifiedBy", |
| | 0 | 245 | | table: "Articles", |
| | 0 | 246 | | column: "LastModifiedBy"); |
| | | 247 | | |
| | 0 | 248 | | migrationBuilder.CreateIndex( |
| | 0 | 249 | | name: "IX_Articles_ParentId", |
| | 0 | 250 | | table: "Articles", |
| | 0 | 251 | | column: "ParentId"); |
| | | 252 | | |
| | 0 | 253 | | migrationBuilder.CreateIndex( |
| | 0 | 254 | | name: "IX_Articles_ParentId_Slug", |
| | 0 | 255 | | table: "Articles", |
| | 0 | 256 | | columns: new[] { "ParentId", "Slug" }, |
| | 0 | 257 | | unique: true, |
| | 0 | 258 | | filter: "[ParentId] IS NOT NULL"); |
| | | 259 | | |
| | 0 | 260 | | migrationBuilder.CreateIndex( |
| | 0 | 261 | | name: "IX_Articles_PlayerId", |
| | 0 | 262 | | table: "Articles", |
| | 0 | 263 | | column: "PlayerId"); |
| | | 264 | | |
| | 0 | 265 | | migrationBuilder.CreateIndex( |
| | 0 | 266 | | name: "IX_Articles_Slug_Root", |
| | 0 | 267 | | table: "Articles", |
| | 0 | 268 | | column: "Slug", |
| | 0 | 269 | | unique: true, |
| | 0 | 270 | | filter: "[ParentId] IS NULL"); |
| | | 271 | | |
| | 0 | 272 | | migrationBuilder.CreateIndex( |
| | 0 | 273 | | name: "IX_Articles_Title", |
| | 0 | 274 | | table: "Articles", |
| | 0 | 275 | | column: "Title"); |
| | | 276 | | |
| | 0 | 277 | | migrationBuilder.CreateIndex( |
| | 0 | 278 | | name: "IX_Articles_Type", |
| | 0 | 279 | | table: "Articles", |
| | 0 | 280 | | column: "Type"); |
| | | 281 | | |
| | 0 | 282 | | migrationBuilder.CreateIndex( |
| | 0 | 283 | | name: "IX_Articles_WorldId", |
| | 0 | 284 | | table: "Articles", |
| | 0 | 285 | | column: "WorldId"); |
| | | 286 | | |
| | 0 | 287 | | migrationBuilder.CreateIndex( |
| | 0 | 288 | | name: "IX_CampaignMembers_CampaignId_UserId", |
| | 0 | 289 | | table: "CampaignMembers", |
| | 0 | 290 | | columns: new[] { "CampaignId", "UserId" }, |
| | 0 | 291 | | unique: true); |
| | | 292 | | |
| | 0 | 293 | | migrationBuilder.CreateIndex( |
| | 0 | 294 | | name: "IX_CampaignMembers_UserId", |
| | 0 | 295 | | table: "CampaignMembers", |
| | 0 | 296 | | column: "UserId"); |
| | | 297 | | |
| | 0 | 298 | | migrationBuilder.CreateIndex( |
| | 0 | 299 | | name: "IX_Campaigns_OwnerId", |
| | 0 | 300 | | table: "Campaigns", |
| | 0 | 301 | | column: "OwnerId"); |
| | | 302 | | |
| | 0 | 303 | | migrationBuilder.CreateIndex( |
| | 0 | 304 | | name: "IX_Campaigns_WorldId", |
| | 0 | 305 | | table: "Campaigns", |
| | 0 | 306 | | column: "WorldId"); |
| | | 307 | | |
| | 0 | 308 | | migrationBuilder.CreateIndex( |
| | 0 | 309 | | name: "IX_Hashtags_LinkedArticleId", |
| | 0 | 310 | | table: "Hashtags", |
| | 0 | 311 | | column: "LinkedArticleId"); |
| | | 312 | | |
| | 0 | 313 | | migrationBuilder.CreateIndex( |
| | 0 | 314 | | name: "IX_Hashtags_Name", |
| | 0 | 315 | | table: "Hashtags", |
| | 0 | 316 | | column: "Name", |
| | 0 | 317 | | unique: true); |
| | | 318 | | |
| | 0 | 319 | | migrationBuilder.CreateIndex( |
| | 0 | 320 | | name: "IX_Users_Auth0UserId", |
| | 0 | 321 | | table: "Users", |
| | 0 | 322 | | column: "Auth0UserId", |
| | 0 | 323 | | unique: true); |
| | | 324 | | |
| | 0 | 325 | | migrationBuilder.CreateIndex( |
| | 0 | 326 | | name: "IX_Users_Email", |
| | 0 | 327 | | table: "Users", |
| | 0 | 328 | | column: "Email"); |
| | | 329 | | |
| | 0 | 330 | | migrationBuilder.CreateIndex( |
| | 0 | 331 | | name: "IX_Worlds_OwnerId", |
| | 0 | 332 | | table: "Worlds", |
| | 0 | 333 | | column: "OwnerId"); |
| | 0 | 334 | | } |
| | | 335 | | |
| | | 336 | | /// <inheritdoc /> |
| | | 337 | | protected override void Down(MigrationBuilder migrationBuilder) |
| | | 338 | | { |
| | 0 | 339 | | migrationBuilder.DropTable( |
| | 0 | 340 | | name: "ArticleHashtags"); |
| | | 341 | | |
| | 0 | 342 | | migrationBuilder.DropTable( |
| | 0 | 343 | | name: "CampaignMembers"); |
| | | 344 | | |
| | 0 | 345 | | migrationBuilder.DropTable( |
| | 0 | 346 | | name: "Hashtags"); |
| | | 347 | | |
| | 0 | 348 | | migrationBuilder.DropTable( |
| | 0 | 349 | | name: "Articles"); |
| | | 350 | | |
| | 0 | 351 | | migrationBuilder.DropTable( |
| | 0 | 352 | | name: "Campaigns"); |
| | | 353 | | |
| | 0 | 354 | | migrationBuilder.DropTable( |
| | 0 | 355 | | name: "Worlds"); |
| | | 356 | | |
| | 0 | 357 | | migrationBuilder.DropTable( |
| | 0 | 358 | | name: "Users"); |
| | 0 | 359 | | } |
| | | 360 | | } |
| | | 361 | | } |