| 1 | using System;
|
|---|
| 2 | using Microsoft.EntityFrameworkCore.Migrations;
|
|---|
| 3 | using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|---|
| 4 |
|
|---|
| 5 | #nullable disable
|
|---|
| 6 |
|
|---|
| 7 | namespace ChapterX.Infrastructure.Migrations
|
|---|
| 8 | {
|
|---|
| 9 | /// <inheritdoc />
|
|---|
| 10 | public partial class InitialCreate : Migration
|
|---|
| 11 | {
|
|---|
| 12 | /// <inheritdoc />
|
|---|
| 13 | protected override void Up(MigrationBuilder migrationBuilder)
|
|---|
| 14 | {
|
|---|
| 15 | migrationBuilder.CreateTable(
|
|---|
| 16 | name: "Genres",
|
|---|
| 17 | columns: table => new
|
|---|
| 18 | {
|
|---|
| 19 | Id = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 20 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|---|
| 21 | Name = table.Column<string>(type: "text", nullable: false)
|
|---|
| 22 | },
|
|---|
| 23 | constraints: table =>
|
|---|
| 24 | {
|
|---|
| 25 | table.PrimaryKey("PK_Genres", x => x.Id);
|
|---|
| 26 | });
|
|---|
| 27 |
|
|---|
| 28 | migrationBuilder.CreateTable(
|
|---|
| 29 | name: "Notifications",
|
|---|
| 30 | columns: table => new
|
|---|
| 31 | {
|
|---|
| 32 | Id = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 33 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|---|
| 34 | Content = table.Column<string>(type: "text", nullable: false),
|
|---|
| 35 | IsRead = table.Column<bool>(type: "boolean", nullable: false),
|
|---|
| 36 | CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|---|
| 37 | ContentTypes = table.Column<int[]>(type: "integer[]", nullable: false)
|
|---|
| 38 | },
|
|---|
| 39 | constraints: table =>
|
|---|
| 40 | {
|
|---|
| 41 | table.PrimaryKey("PK_Notifications", x => x.Id);
|
|---|
| 42 | });
|
|---|
| 43 |
|
|---|
| 44 | migrationBuilder.CreateTable(
|
|---|
| 45 | name: "Users",
|
|---|
| 46 | columns: table => new
|
|---|
| 47 | {
|
|---|
| 48 | Id = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 49 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|---|
| 50 | Username = table.Column<string>(type: "text", nullable: false),
|
|---|
| 51 | Email = table.Column<string>(type: "text", nullable: false),
|
|---|
| 52 | Name = table.Column<string>(type: "text", nullable: false),
|
|---|
| 53 | Surname = table.Column<string>(type: "text", nullable: false),
|
|---|
| 54 | Password = table.Column<string>(type: "text", nullable: false),
|
|---|
| 55 | CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|---|
| 56 | UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
|---|
| 57 | },
|
|---|
| 58 | constraints: table =>
|
|---|
| 59 | {
|
|---|
| 60 | table.PrimaryKey("PK_Users", x => x.Id);
|
|---|
| 61 | });
|
|---|
| 62 |
|
|---|
| 63 | migrationBuilder.CreateTable(
|
|---|
| 64 | name: "Admins",
|
|---|
| 65 | columns: table => new
|
|---|
| 66 | {
|
|---|
| 67 | Id = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 68 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|---|
| 69 | UserId = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 70 | },
|
|---|
| 71 | constraints: table =>
|
|---|
| 72 | {
|
|---|
| 73 | table.PrimaryKey("PK_Admins", x => x.Id);
|
|---|
| 74 | table.ForeignKey(
|
|---|
| 75 | name: "FK_Admins_Users_UserId",
|
|---|
| 76 | column: x => x.UserId,
|
|---|
| 77 | principalTable: "Users",
|
|---|
| 78 | principalColumn: "Id",
|
|---|
| 79 | onDelete: ReferentialAction.Cascade);
|
|---|
| 80 | });
|
|---|
| 81 |
|
|---|
| 82 | migrationBuilder.CreateTable(
|
|---|
| 83 | name: "ReadingLists",
|
|---|
| 84 | columns: table => new
|
|---|
| 85 | {
|
|---|
| 86 | Id = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 87 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|---|
| 88 | Name = table.Column<string>(type: "text", nullable: false),
|
|---|
| 89 | Content = table.Column<string>(type: "text", nullable: true),
|
|---|
| 90 | IsPublic = table.Column<bool>(type: "boolean", nullable: false),
|
|---|
| 91 | CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|---|
| 92 | UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|---|
| 93 | UserId = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 94 | },
|
|---|
| 95 | constraints: table =>
|
|---|
| 96 | {
|
|---|
| 97 | table.PrimaryKey("PK_ReadingLists", x => x.Id);
|
|---|
| 98 | table.ForeignKey(
|
|---|
| 99 | name: "FK_ReadingLists_Users_UserId",
|
|---|
| 100 | column: x => x.UserId,
|
|---|
| 101 | principalTable: "Users",
|
|---|
| 102 | principalColumn: "Id",
|
|---|
| 103 | onDelete: ReferentialAction.Cascade);
|
|---|
| 104 | });
|
|---|
| 105 |
|
|---|
| 106 | migrationBuilder.CreateTable(
|
|---|
| 107 | name: "RegularUsers",
|
|---|
| 108 | columns: table => new
|
|---|
| 109 | {
|
|---|
| 110 | Id = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 111 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|---|
| 112 | UserId = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 113 | },
|
|---|
| 114 | constraints: table =>
|
|---|
| 115 | {
|
|---|
| 116 | table.PrimaryKey("PK_RegularUsers", x => x.Id);
|
|---|
| 117 | table.ForeignKey(
|
|---|
| 118 | name: "FK_RegularUsers_Users_UserId",
|
|---|
| 119 | column: x => x.UserId,
|
|---|
| 120 | principalTable: "Users",
|
|---|
| 121 | principalColumn: "Id",
|
|---|
| 122 | onDelete: ReferentialAction.Cascade);
|
|---|
| 123 | });
|
|---|
| 124 |
|
|---|
| 125 | migrationBuilder.CreateTable(
|
|---|
| 126 | name: "Writers",
|
|---|
| 127 | columns: table => new
|
|---|
| 128 | {
|
|---|
| 129 | Id = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 130 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|---|
| 131 | UserId = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 132 | Bio = table.Column<string>(type: "text", nullable: false)
|
|---|
| 133 | },
|
|---|
| 134 | constraints: table =>
|
|---|
| 135 | {
|
|---|
| 136 | table.PrimaryKey("PK_Writers", x => x.Id);
|
|---|
| 137 | table.ForeignKey(
|
|---|
| 138 | name: "FK_Writers_Users_UserId",
|
|---|
| 139 | column: x => x.UserId,
|
|---|
| 140 | principalTable: "Users",
|
|---|
| 141 | principalColumn: "Id",
|
|---|
| 142 | onDelete: ReferentialAction.Cascade);
|
|---|
| 143 | });
|
|---|
| 144 |
|
|---|
| 145 | migrationBuilder.CreateTable(
|
|---|
| 146 | name: "Stories",
|
|---|
| 147 | columns: table => new
|
|---|
| 148 | {
|
|---|
| 149 | Id = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 150 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|---|
| 151 | MatureContent = table.Column<bool>(type: "boolean", nullable: false),
|
|---|
| 152 | ShortDescription = table.Column<string>(type: "text", nullable: false),
|
|---|
| 153 | Image = table.Column<string>(type: "text", nullable: true),
|
|---|
| 154 | Content = table.Column<string>(type: "text", nullable: false),
|
|---|
| 155 | CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|---|
| 156 | UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|---|
| 157 | UserId = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 158 | WriterId = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 159 | Statuses = table.Column<int[]>(type: "integer[]", nullable: false)
|
|---|
| 160 | },
|
|---|
| 161 | constraints: table =>
|
|---|
| 162 | {
|
|---|
| 163 | table.PrimaryKey("PK_Stories", x => x.Id);
|
|---|
| 164 | table.ForeignKey(
|
|---|
| 165 | name: "FK_Stories_Writers_WriterId",
|
|---|
| 166 | column: x => x.WriterId,
|
|---|
| 167 | principalTable: "Writers",
|
|---|
| 168 | principalColumn: "Id",
|
|---|
| 169 | onDelete: ReferentialAction.Cascade);
|
|---|
| 170 | });
|
|---|
| 171 |
|
|---|
| 172 | migrationBuilder.CreateTable(
|
|---|
| 173 | name: "AISuggestions",
|
|---|
| 174 | columns: table => new
|
|---|
| 175 | {
|
|---|
| 176 | Id = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 177 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|---|
| 178 | OriginalText = table.Column<string>(type: "text", nullable: false),
|
|---|
| 179 | SuggestedText = table.Column<string>(type: "text", nullable: false),
|
|---|
| 180 | Accepted = table.Column<bool>(type: "boolean", nullable: false),
|
|---|
| 181 | CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|---|
| 182 | AppliedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
|
|---|
| 183 | StoryId = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 184 | SuggestionTypes = table.Column<int[]>(type: "integer[]", nullable: false)
|
|---|
| 185 | },
|
|---|
| 186 | constraints: table =>
|
|---|
| 187 | {
|
|---|
| 188 | table.PrimaryKey("PK_AISuggestions", x => x.Id);
|
|---|
| 189 | table.ForeignKey(
|
|---|
| 190 | name: "FK_AISuggestions_Stories_StoryId",
|
|---|
| 191 | column: x => x.StoryId,
|
|---|
| 192 | principalTable: "Stories",
|
|---|
| 193 | principalColumn: "Id",
|
|---|
| 194 | onDelete: ReferentialAction.Cascade);
|
|---|
| 195 | });
|
|---|
| 196 |
|
|---|
| 197 | migrationBuilder.CreateTable(
|
|---|
| 198 | name: "Chapters",
|
|---|
| 199 | columns: table => new
|
|---|
| 200 | {
|
|---|
| 201 | Id = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 202 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|---|
| 203 | Number = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 204 | Name = table.Column<string>(type: "text", nullable: false),
|
|---|
| 205 | Title = table.Column<string>(type: "text", nullable: false),
|
|---|
| 206 | Content = table.Column<string>(type: "text", nullable: false),
|
|---|
| 207 | WordCount = table.Column<int>(type: "integer", nullable: true),
|
|---|
| 208 | Rating = table.Column<decimal>(type: "numeric", nullable: true),
|
|---|
| 209 | PublishedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|---|
| 210 | ViewCount = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 211 | CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|---|
| 212 | UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|---|
| 213 | StoryId = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 214 | },
|
|---|
| 215 | constraints: table =>
|
|---|
| 216 | {
|
|---|
| 217 | table.PrimaryKey("PK_Chapters", x => x.Id);
|
|---|
| 218 | table.ForeignKey(
|
|---|
| 219 | name: "FK_Chapters_Stories_StoryId",
|
|---|
| 220 | column: x => x.StoryId,
|
|---|
| 221 | principalTable: "Stories",
|
|---|
| 222 | principalColumn: "Id",
|
|---|
| 223 | onDelete: ReferentialAction.Cascade);
|
|---|
| 224 | });
|
|---|
| 225 |
|
|---|
| 226 | migrationBuilder.CreateTable(
|
|---|
| 227 | name: "Collaborations",
|
|---|
| 228 | columns: table => new
|
|---|
| 229 | {
|
|---|
| 230 | Id = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 231 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|---|
| 232 | UserId = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 233 | StoryId = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 234 | Role = table.Column<string>(type: "text", nullable: false),
|
|---|
| 235 | JoinedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
|---|
| 236 | },
|
|---|
| 237 | constraints: table =>
|
|---|
| 238 | {
|
|---|
| 239 | table.PrimaryKey("PK_Collaborations", x => x.Id);
|
|---|
| 240 | table.ForeignKey(
|
|---|
| 241 | name: "FK_Collaborations_Stories_StoryId",
|
|---|
| 242 | column: x => x.StoryId,
|
|---|
| 243 | principalTable: "Stories",
|
|---|
| 244 | principalColumn: "Id",
|
|---|
| 245 | onDelete: ReferentialAction.Cascade);
|
|---|
| 246 | table.ForeignKey(
|
|---|
| 247 | name: "FK_Collaborations_Users_UserId",
|
|---|
| 248 | column: x => x.UserId,
|
|---|
| 249 | principalTable: "Users",
|
|---|
| 250 | principalColumn: "Id",
|
|---|
| 251 | onDelete: ReferentialAction.Cascade);
|
|---|
| 252 | });
|
|---|
| 253 |
|
|---|
| 254 | migrationBuilder.CreateTable(
|
|---|
| 255 | name: "Comments",
|
|---|
| 256 | columns: table => new
|
|---|
| 257 | {
|
|---|
| 258 | Id = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 259 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|---|
| 260 | Content = table.Column<string>(type: "text", nullable: false),
|
|---|
| 261 | CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|---|
| 262 | UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|---|
| 263 | UserId = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 264 | StoryId = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 265 | },
|
|---|
| 266 | constraints: table =>
|
|---|
| 267 | {
|
|---|
| 268 | table.PrimaryKey("PK_Comments", x => x.Id);
|
|---|
| 269 | table.ForeignKey(
|
|---|
| 270 | name: "FK_Comments_Stories_StoryId",
|
|---|
| 271 | column: x => x.StoryId,
|
|---|
| 272 | principalTable: "Stories",
|
|---|
| 273 | principalColumn: "Id",
|
|---|
| 274 | onDelete: ReferentialAction.Cascade);
|
|---|
| 275 | table.ForeignKey(
|
|---|
| 276 | name: "FK_Comments_Users_UserId",
|
|---|
| 277 | column: x => x.UserId,
|
|---|
| 278 | principalTable: "Users",
|
|---|
| 279 | principalColumn: "Id",
|
|---|
| 280 | onDelete: ReferentialAction.Cascade);
|
|---|
| 281 | });
|
|---|
| 282 |
|
|---|
| 283 | migrationBuilder.CreateTable(
|
|---|
| 284 | name: "HasGenres",
|
|---|
| 285 | columns: table => new
|
|---|
| 286 | {
|
|---|
| 287 | Id = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 288 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|---|
| 289 | StoryId = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 290 | GenreId = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 291 | },
|
|---|
| 292 | constraints: table =>
|
|---|
| 293 | {
|
|---|
| 294 | table.PrimaryKey("PK_HasGenres", x => x.Id);
|
|---|
| 295 | table.ForeignKey(
|
|---|
| 296 | name: "FK_HasGenres_Genres_GenreId",
|
|---|
| 297 | column: x => x.GenreId,
|
|---|
| 298 | principalTable: "Genres",
|
|---|
| 299 | principalColumn: "Id",
|
|---|
| 300 | onDelete: ReferentialAction.Cascade);
|
|---|
| 301 | table.ForeignKey(
|
|---|
| 302 | name: "FK_HasGenres_Stories_StoryId",
|
|---|
| 303 | column: x => x.StoryId,
|
|---|
| 304 | principalTable: "Stories",
|
|---|
| 305 | principalColumn: "Id",
|
|---|
| 306 | onDelete: ReferentialAction.Cascade);
|
|---|
| 307 | });
|
|---|
| 308 |
|
|---|
| 309 | migrationBuilder.CreateTable(
|
|---|
| 310 | name: "Notifies",
|
|---|
| 311 | columns: table => new
|
|---|
| 312 | {
|
|---|
| 313 | Id = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 314 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|---|
| 315 | UserId = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 316 | NotificationId = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 317 | IsRead = table.Column<bool>(type: "boolean", nullable: false),
|
|---|
| 318 | StoryId = table.Column<int>(type: "integer", nullable: true)
|
|---|
| 319 | },
|
|---|
| 320 | constraints: table =>
|
|---|
| 321 | {
|
|---|
| 322 | table.PrimaryKey("PK_Notifies", x => x.Id);
|
|---|
| 323 | table.ForeignKey(
|
|---|
| 324 | name: "FK_Notifies_Notifications_NotificationId",
|
|---|
| 325 | column: x => x.NotificationId,
|
|---|
| 326 | principalTable: "Notifications",
|
|---|
| 327 | principalColumn: "Id",
|
|---|
| 328 | onDelete: ReferentialAction.Cascade);
|
|---|
| 329 | table.ForeignKey(
|
|---|
| 330 | name: "FK_Notifies_Stories_StoryId",
|
|---|
| 331 | column: x => x.StoryId,
|
|---|
| 332 | principalTable: "Stories",
|
|---|
| 333 | principalColumn: "Id");
|
|---|
| 334 | table.ForeignKey(
|
|---|
| 335 | name: "FK_Notifies_Users_UserId",
|
|---|
| 336 | column: x => x.UserId,
|
|---|
| 337 | principalTable: "Users",
|
|---|
| 338 | principalColumn: "Id",
|
|---|
| 339 | onDelete: ReferentialAction.Cascade);
|
|---|
| 340 | });
|
|---|
| 341 |
|
|---|
| 342 | migrationBuilder.CreateTable(
|
|---|
| 343 | name: "ReadingListItems",
|
|---|
| 344 | columns: table => new
|
|---|
| 345 | {
|
|---|
| 346 | Id = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 347 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|---|
| 348 | ReadingListId = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 349 | StoryId = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 350 | AddedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
|---|
| 351 | },
|
|---|
| 352 | constraints: table =>
|
|---|
| 353 | {
|
|---|
| 354 | table.PrimaryKey("PK_ReadingListItems", x => x.Id);
|
|---|
| 355 | table.ForeignKey(
|
|---|
| 356 | name: "FK_ReadingListItems_ReadingLists_ReadingListId",
|
|---|
| 357 | column: x => x.ReadingListId,
|
|---|
| 358 | principalTable: "ReadingLists",
|
|---|
| 359 | principalColumn: "Id",
|
|---|
| 360 | onDelete: ReferentialAction.Cascade);
|
|---|
| 361 | table.ForeignKey(
|
|---|
| 362 | name: "FK_ReadingListItems_Stories_StoryId",
|
|---|
| 363 | column: x => x.StoryId,
|
|---|
| 364 | principalTable: "Stories",
|
|---|
| 365 | principalColumn: "Id",
|
|---|
| 366 | onDelete: ReferentialAction.Cascade);
|
|---|
| 367 | });
|
|---|
| 368 |
|
|---|
| 369 | migrationBuilder.CreateTable(
|
|---|
| 370 | name: "Likes",
|
|---|
| 371 | columns: table => new
|
|---|
| 372 | {
|
|---|
| 373 | Id = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 374 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|---|
| 375 | UserId = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 376 | ChapterId = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 377 | CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|---|
| 378 | StoryId = table.Column<int>(type: "integer", nullable: true)
|
|---|
| 379 | },
|
|---|
| 380 | constraints: table =>
|
|---|
| 381 | {
|
|---|
| 382 | table.PrimaryKey("PK_Likes", x => x.Id);
|
|---|
| 383 | table.ForeignKey(
|
|---|
| 384 | name: "FK_Likes_Chapters_ChapterId",
|
|---|
| 385 | column: x => x.ChapterId,
|
|---|
| 386 | principalTable: "Chapters",
|
|---|
| 387 | principalColumn: "Id",
|
|---|
| 388 | onDelete: ReferentialAction.Cascade);
|
|---|
| 389 | table.ForeignKey(
|
|---|
| 390 | name: "FK_Likes_Stories_StoryId",
|
|---|
| 391 | column: x => x.StoryId,
|
|---|
| 392 | principalTable: "Stories",
|
|---|
| 393 | principalColumn: "Id");
|
|---|
| 394 | table.ForeignKey(
|
|---|
| 395 | name: "FK_Likes_Users_UserId",
|
|---|
| 396 | column: x => x.UserId,
|
|---|
| 397 | principalTable: "Users",
|
|---|
| 398 | principalColumn: "Id",
|
|---|
| 399 | onDelete: ReferentialAction.Cascade);
|
|---|
| 400 | });
|
|---|
| 401 |
|
|---|
| 402 | migrationBuilder.CreateTable(
|
|---|
| 403 | name: "NeedApprovals",
|
|---|
| 404 | columns: table => new
|
|---|
| 405 | {
|
|---|
| 406 | Id = table.Column<int>(type: "integer", nullable: false)
|
|---|
| 407 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|---|
| 408 | StoryId = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 409 | AdminId = table.Column<int>(type: "integer", nullable: false),
|
|---|
| 410 | Approved = table.Column<bool>(type: "boolean", nullable: false),
|
|---|
| 411 | RequestedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|---|
| 412 | AISuggestionId = table.Column<int>(type: "integer", nullable: true),
|
|---|
| 413 | ChapterId = table.Column<int>(type: "integer", nullable: true)
|
|---|
| 414 | },
|
|---|
| 415 | constraints: table =>
|
|---|
| 416 | {
|
|---|
| 417 | table.PrimaryKey("PK_NeedApprovals", x => x.Id);
|
|---|
| 418 | table.ForeignKey(
|
|---|
| 419 | name: "FK_NeedApprovals_AISuggestions_AISuggestionId",
|
|---|
| 420 | column: x => x.AISuggestionId,
|
|---|
| 421 | principalTable: "AISuggestions",
|
|---|
| 422 | principalColumn: "Id");
|
|---|
| 423 | table.ForeignKey(
|
|---|
| 424 | name: "FK_NeedApprovals_Admins_AdminId",
|
|---|
| 425 | column: x => x.AdminId,
|
|---|
| 426 | principalTable: "Admins",
|
|---|
| 427 | principalColumn: "Id",
|
|---|
| 428 | onDelete: ReferentialAction.Cascade);
|
|---|
| 429 | table.ForeignKey(
|
|---|
| 430 | name: "FK_NeedApprovals_Chapters_ChapterId",
|
|---|
| 431 | column: x => x.ChapterId,
|
|---|
| 432 | principalTable: "Chapters",
|
|---|
| 433 | principalColumn: "Id");
|
|---|
| 434 | table.ForeignKey(
|
|---|
| 435 | name: "FK_NeedApprovals_Stories_StoryId",
|
|---|
| 436 | column: x => x.StoryId,
|
|---|
| 437 | principalTable: "Stories",
|
|---|
| 438 | principalColumn: "Id",
|
|---|
| 439 | onDelete: ReferentialAction.Cascade);
|
|---|
| 440 | });
|
|---|
| 441 |
|
|---|
| 442 | migrationBuilder.CreateIndex(
|
|---|
| 443 | name: "IX_Admins_UserId",
|
|---|
| 444 | table: "Admins",
|
|---|
| 445 | column: "UserId",
|
|---|
| 446 | unique: true);
|
|---|
| 447 |
|
|---|
| 448 | migrationBuilder.CreateIndex(
|
|---|
| 449 | name: "IX_AISuggestions_StoryId",
|
|---|
| 450 | table: "AISuggestions",
|
|---|
| 451 | column: "StoryId");
|
|---|
| 452 |
|
|---|
| 453 | migrationBuilder.CreateIndex(
|
|---|
| 454 | name: "IX_Chapters_StoryId",
|
|---|
| 455 | table: "Chapters",
|
|---|
| 456 | column: "StoryId");
|
|---|
| 457 |
|
|---|
| 458 | migrationBuilder.CreateIndex(
|
|---|
| 459 | name: "IX_Collaborations_StoryId",
|
|---|
| 460 | table: "Collaborations",
|
|---|
| 461 | column: "StoryId");
|
|---|
| 462 |
|
|---|
| 463 | migrationBuilder.CreateIndex(
|
|---|
| 464 | name: "IX_Collaborations_UserId",
|
|---|
| 465 | table: "Collaborations",
|
|---|
| 466 | column: "UserId");
|
|---|
| 467 |
|
|---|
| 468 | migrationBuilder.CreateIndex(
|
|---|
| 469 | name: "IX_Comments_StoryId",
|
|---|
| 470 | table: "Comments",
|
|---|
| 471 | column: "StoryId");
|
|---|
| 472 |
|
|---|
| 473 | migrationBuilder.CreateIndex(
|
|---|
| 474 | name: "IX_Comments_UserId",
|
|---|
| 475 | table: "Comments",
|
|---|
| 476 | column: "UserId");
|
|---|
| 477 |
|
|---|
| 478 | migrationBuilder.CreateIndex(
|
|---|
| 479 | name: "IX_HasGenres_GenreId",
|
|---|
| 480 | table: "HasGenres",
|
|---|
| 481 | column: "GenreId");
|
|---|
| 482 |
|
|---|
| 483 | migrationBuilder.CreateIndex(
|
|---|
| 484 | name: "IX_HasGenres_StoryId",
|
|---|
| 485 | table: "HasGenres",
|
|---|
| 486 | column: "StoryId");
|
|---|
| 487 |
|
|---|
| 488 | migrationBuilder.CreateIndex(
|
|---|
| 489 | name: "IX_Likes_ChapterId",
|
|---|
| 490 | table: "Likes",
|
|---|
| 491 | column: "ChapterId");
|
|---|
| 492 |
|
|---|
| 493 | migrationBuilder.CreateIndex(
|
|---|
| 494 | name: "IX_Likes_StoryId",
|
|---|
| 495 | table: "Likes",
|
|---|
| 496 | column: "StoryId");
|
|---|
| 497 |
|
|---|
| 498 | migrationBuilder.CreateIndex(
|
|---|
| 499 | name: "IX_Likes_UserId",
|
|---|
| 500 | table: "Likes",
|
|---|
| 501 | column: "UserId");
|
|---|
| 502 |
|
|---|
| 503 | migrationBuilder.CreateIndex(
|
|---|
| 504 | name: "IX_NeedApprovals_AdminId",
|
|---|
| 505 | table: "NeedApprovals",
|
|---|
| 506 | column: "AdminId");
|
|---|
| 507 |
|
|---|
| 508 | migrationBuilder.CreateIndex(
|
|---|
| 509 | name: "IX_NeedApprovals_AISuggestionId",
|
|---|
| 510 | table: "NeedApprovals",
|
|---|
| 511 | column: "AISuggestionId");
|
|---|
| 512 |
|
|---|
| 513 | migrationBuilder.CreateIndex(
|
|---|
| 514 | name: "IX_NeedApprovals_ChapterId",
|
|---|
| 515 | table: "NeedApprovals",
|
|---|
| 516 | column: "ChapterId");
|
|---|
| 517 |
|
|---|
| 518 | migrationBuilder.CreateIndex(
|
|---|
| 519 | name: "IX_NeedApprovals_StoryId",
|
|---|
| 520 | table: "NeedApprovals",
|
|---|
| 521 | column: "StoryId");
|
|---|
| 522 |
|
|---|
| 523 | migrationBuilder.CreateIndex(
|
|---|
| 524 | name: "IX_Notifies_NotificationId",
|
|---|
| 525 | table: "Notifies",
|
|---|
| 526 | column: "NotificationId");
|
|---|
| 527 |
|
|---|
| 528 | migrationBuilder.CreateIndex(
|
|---|
| 529 | name: "IX_Notifies_StoryId",
|
|---|
| 530 | table: "Notifies",
|
|---|
| 531 | column: "StoryId");
|
|---|
| 532 |
|
|---|
| 533 | migrationBuilder.CreateIndex(
|
|---|
| 534 | name: "IX_Notifies_UserId",
|
|---|
| 535 | table: "Notifies",
|
|---|
| 536 | column: "UserId");
|
|---|
| 537 |
|
|---|
| 538 | migrationBuilder.CreateIndex(
|
|---|
| 539 | name: "IX_ReadingListItems_ReadingListId",
|
|---|
| 540 | table: "ReadingListItems",
|
|---|
| 541 | column: "ReadingListId");
|
|---|
| 542 |
|
|---|
| 543 | migrationBuilder.CreateIndex(
|
|---|
| 544 | name: "IX_ReadingListItems_StoryId",
|
|---|
| 545 | table: "ReadingListItems",
|
|---|
| 546 | column: "StoryId");
|
|---|
| 547 |
|
|---|
| 548 | migrationBuilder.CreateIndex(
|
|---|
| 549 | name: "IX_ReadingLists_UserId",
|
|---|
| 550 | table: "ReadingLists",
|
|---|
| 551 | column: "UserId");
|
|---|
| 552 |
|
|---|
| 553 | migrationBuilder.CreateIndex(
|
|---|
| 554 | name: "IX_RegularUsers_UserId",
|
|---|
| 555 | table: "RegularUsers",
|
|---|
| 556 | column: "UserId",
|
|---|
| 557 | unique: true);
|
|---|
| 558 |
|
|---|
| 559 | migrationBuilder.CreateIndex(
|
|---|
| 560 | name: "IX_Stories_WriterId",
|
|---|
| 561 | table: "Stories",
|
|---|
| 562 | column: "WriterId");
|
|---|
| 563 |
|
|---|
| 564 | migrationBuilder.CreateIndex(
|
|---|
| 565 | name: "IX_Writers_UserId",
|
|---|
| 566 | table: "Writers",
|
|---|
| 567 | column: "UserId",
|
|---|
| 568 | unique: true);
|
|---|
| 569 | }
|
|---|
| 570 |
|
|---|
| 571 | /// <inheritdoc />
|
|---|
| 572 | protected override void Down(MigrationBuilder migrationBuilder)
|
|---|
| 573 | {
|
|---|
| 574 | migrationBuilder.DropTable(
|
|---|
| 575 | name: "Collaborations");
|
|---|
| 576 |
|
|---|
| 577 | migrationBuilder.DropTable(
|
|---|
| 578 | name: "Comments");
|
|---|
| 579 |
|
|---|
| 580 | migrationBuilder.DropTable(
|
|---|
| 581 | name: "HasGenres");
|
|---|
| 582 |
|
|---|
| 583 | migrationBuilder.DropTable(
|
|---|
| 584 | name: "Likes");
|
|---|
| 585 |
|
|---|
| 586 | migrationBuilder.DropTable(
|
|---|
| 587 | name: "NeedApprovals");
|
|---|
| 588 |
|
|---|
| 589 | migrationBuilder.DropTable(
|
|---|
| 590 | name: "Notifies");
|
|---|
| 591 |
|
|---|
| 592 | migrationBuilder.DropTable(
|
|---|
| 593 | name: "ReadingListItems");
|
|---|
| 594 |
|
|---|
| 595 | migrationBuilder.DropTable(
|
|---|
| 596 | name: "RegularUsers");
|
|---|
| 597 |
|
|---|
| 598 | migrationBuilder.DropTable(
|
|---|
| 599 | name: "Genres");
|
|---|
| 600 |
|
|---|
| 601 | migrationBuilder.DropTable(
|
|---|
| 602 | name: "AISuggestions");
|
|---|
| 603 |
|
|---|
| 604 | migrationBuilder.DropTable(
|
|---|
| 605 | name: "Admins");
|
|---|
| 606 |
|
|---|
| 607 | migrationBuilder.DropTable(
|
|---|
| 608 | name: "Chapters");
|
|---|
| 609 |
|
|---|
| 610 | migrationBuilder.DropTable(
|
|---|
| 611 | name: "Notifications");
|
|---|
| 612 |
|
|---|
| 613 | migrationBuilder.DropTable(
|
|---|
| 614 | name: "ReadingLists");
|
|---|
| 615 |
|
|---|
| 616 | migrationBuilder.DropTable(
|
|---|
| 617 | name: "Stories");
|
|---|
| 618 |
|
|---|
| 619 | migrationBuilder.DropTable(
|
|---|
| 620 | name: "Writers");
|
|---|
| 621 |
|
|---|
| 622 | migrationBuilder.DropTable(
|
|---|
| 623 | name: "Users");
|
|---|
| 624 | }
|
|---|
| 625 | }
|
|---|
| 626 | }
|
|---|