20260328145416_Initial.cs
45,374 bytes
| 1 | using System; |
|---|---|
| 2 | using Microsoft.EntityFrameworkCore.Migrations; |
| 3 | using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; |
| 4 | |
| 5 | #nullable disable |
| 6 | |
| 7 | namespace App.DAL.EF.Migrations |
| 8 | { |
| 9 | /// <inheritdoc /> |
| 10 | public partial class Initial : Migration |
| 11 | { |
| 12 | /// <inheritdoc /> |
| 13 | protected override void Up(MigrationBuilder migrationBuilder) |
| 14 | { |
| 15 | migrationBuilder.CreateTable( |
| 16 | name: "AspNetRoles", |
| 17 | columns: table => new |
| 18 | { |
| 19 | Id = table.Column<Guid>(type: "uuid", nullable: false), |
| 20 | Name = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true), |
| 21 | NormalizedName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true), |
| 22 | ConcurrencyStamp = table.Column<string>(type: "text", nullable: true) |
| 23 | }, |
| 24 | constraints: table => |
| 25 | { |
| 26 | table.PrimaryKey("PK_AspNetRoles", x => x.Id); |
| 27 | }); |
| 28 | |
| 29 | migrationBuilder.CreateTable( |
| 30 | name: "AspNetUsers", |
| 31 | columns: table => new |
| 32 | { |
| 33 | Id = table.Column<Guid>(type: "uuid", nullable: false), |
| 34 | FirstName = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false), |
| 35 | LastName = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false), |
| 36 | UserName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true), |
| 37 | NormalizedUserName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true), |
| 38 | Email = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true), |
| 39 | NormalizedEmail = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true), |
| 40 | EmailConfirmed = table.Column<bool>(type: "boolean", nullable: false), |
| 41 | PasswordHash = table.Column<string>(type: "text", nullable: true), |
| 42 | SecurityStamp = table.Column<string>(type: "text", nullable: true), |
| 43 | ConcurrencyStamp = table.Column<string>(type: "text", nullable: true), |
| 44 | PhoneNumber = table.Column<string>(type: "text", nullable: true), |
| 45 | PhoneNumberConfirmed = table.Column<bool>(type: "boolean", nullable: false), |
| 46 | TwoFactorEnabled = table.Column<bool>(type: "boolean", nullable: false), |
| 47 | LockoutEnd = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true), |
| 48 | LockoutEnabled = table.Column<bool>(type: "boolean", nullable: false), |
| 49 | AccessFailedCount = table.Column<int>(type: "integer", nullable: false) |
| 50 | }, |
| 51 | constraints: table => |
| 52 | { |
| 53 | table.PrimaryKey("PK_AspNetUsers", x => x.Id); |
| 54 | }); |
| 55 | |
| 56 | migrationBuilder.CreateTable( |
| 57 | name: "Currencies", |
| 58 | columns: table => new |
| 59 | { |
| 60 | Id = table.Column<Guid>(type: "uuid", nullable: false), |
| 61 | Code = table.Column<string>(type: "character varying(3)", maxLength: 3, nullable: false), |
| 62 | Name = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false), |
| 63 | Symbol = table.Column<string>(type: "character varying(10)", maxLength: 10, nullable: false) |
| 64 | }, |
| 65 | constraints: table => |
| 66 | { |
| 67 | table.PrimaryKey("PK_Currencies", x => x.Id); |
| 68 | }); |
| 69 | |
| 70 | migrationBuilder.CreateTable( |
| 71 | name: "DataProtectionKeys", |
| 72 | columns: table => new |
| 73 | { |
| 74 | Id = table.Column<int>(type: "integer", nullable: false) |
| 75 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), |
| 76 | FriendlyName = table.Column<string>(type: "text", nullable: true), |
| 77 | Xml = table.Column<string>(type: "text", nullable: true) |
| 78 | }, |
| 79 | constraints: table => |
| 80 | { |
| 81 | table.PrimaryKey("PK_DataProtectionKeys", x => x.Id); |
| 82 | }); |
| 83 | |
| 84 | migrationBuilder.CreateTable( |
| 85 | name: "AspNetRoleClaims", |
| 86 | columns: table => new |
| 87 | { |
| 88 | Id = table.Column<int>(type: "integer", nullable: false) |
| 89 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), |
| 90 | RoleId = table.Column<Guid>(type: "uuid", nullable: false), |
| 91 | ClaimType = table.Column<string>(type: "text", nullable: true), |
| 92 | ClaimValue = table.Column<string>(type: "text", nullable: true) |
| 93 | }, |
| 94 | constraints: table => |
| 95 | { |
| 96 | table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id); |
| 97 | table.ForeignKey( |
| 98 | name: "FK_AspNetRoleClaims_AspNetRoles_RoleId", |
| 99 | column: x => x.RoleId, |
| 100 | principalTable: "AspNetRoles", |
| 101 | principalColumn: "Id", |
| 102 | onDelete: ReferentialAction.Restrict); |
| 103 | }); |
| 104 | |
| 105 | migrationBuilder.CreateTable( |
| 106 | name: "AspNetUserClaims", |
| 107 | columns: table => new |
| 108 | { |
| 109 | Id = table.Column<int>(type: "integer", nullable: false) |
| 110 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), |
| 111 | UserId = table.Column<Guid>(type: "uuid", nullable: false), |
| 112 | ClaimType = table.Column<string>(type: "text", nullable: true), |
| 113 | ClaimValue = table.Column<string>(type: "text", nullable: true) |
| 114 | }, |
| 115 | constraints: table => |
| 116 | { |
| 117 | table.PrimaryKey("PK_AspNetUserClaims", x => x.Id); |
| 118 | table.ForeignKey( |
| 119 | name: "FK_AspNetUserClaims_AspNetUsers_UserId", |
| 120 | column: x => x.UserId, |
| 121 | principalTable: "AspNetUsers", |
| 122 | principalColumn: "Id", |
| 123 | onDelete: ReferentialAction.Restrict); |
| 124 | }); |
| 125 | |
| 126 | migrationBuilder.CreateTable( |
| 127 | name: "AspNetUserLogins", |
| 128 | columns: table => new |
| 129 | { |
| 130 | LoginProvider = table.Column<string>(type: "text", nullable: false), |
| 131 | ProviderKey = table.Column<string>(type: "text", nullable: false), |
| 132 | ProviderDisplayName = table.Column<string>(type: "text", nullable: true), |
| 133 | UserId = table.Column<Guid>(type: "uuid", nullable: false) |
| 134 | }, |
| 135 | constraints: table => |
| 136 | { |
| 137 | table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey }); |
| 138 | table.ForeignKey( |
| 139 | name: "FK_AspNetUserLogins_AspNetUsers_UserId", |
| 140 | column: x => x.UserId, |
| 141 | principalTable: "AspNetUsers", |
| 142 | principalColumn: "Id", |
| 143 | onDelete: ReferentialAction.Restrict); |
| 144 | }); |
| 145 | |
| 146 | migrationBuilder.CreateTable( |
| 147 | name: "AspNetUserRoles", |
| 148 | columns: table => new |
| 149 | { |
| 150 | UserId = table.Column<Guid>(type: "uuid", nullable: false), |
| 151 | RoleId = table.Column<Guid>(type: "uuid", nullable: false) |
| 152 | }, |
| 153 | constraints: table => |
| 154 | { |
| 155 | table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId }); |
| 156 | table.ForeignKey( |
| 157 | name: "FK_AspNetUserRoles_AspNetRoles_RoleId", |
| 158 | column: x => x.RoleId, |
| 159 | principalTable: "AspNetRoles", |
| 160 | principalColumn: "Id", |
| 161 | onDelete: ReferentialAction.Restrict); |
| 162 | table.ForeignKey( |
| 163 | name: "FK_AspNetUserRoles_AspNetUsers_UserId", |
| 164 | column: x => x.UserId, |
| 165 | principalTable: "AspNetUsers", |
| 166 | principalColumn: "Id", |
| 167 | onDelete: ReferentialAction.Restrict); |
| 168 | }); |
| 169 | |
| 170 | migrationBuilder.CreateTable( |
| 171 | name: "AspNetUserTokens", |
| 172 | columns: table => new |
| 173 | { |
| 174 | UserId = table.Column<Guid>(type: "uuid", nullable: false), |
| 175 | LoginProvider = table.Column<string>(type: "text", nullable: false), |
| 176 | Name = table.Column<string>(type: "text", nullable: false), |
| 177 | Value = table.Column<string>(type: "text", nullable: true) |
| 178 | }, |
| 179 | constraints: table => |
| 180 | { |
| 181 | table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name }); |
| 182 | table.ForeignKey( |
| 183 | name: "FK_AspNetUserTokens_AspNetUsers_UserId", |
| 184 | column: x => x.UserId, |
| 185 | principalTable: "AspNetUsers", |
| 186 | principalColumn: "Id", |
| 187 | onDelete: ReferentialAction.Restrict); |
| 188 | }); |
| 189 | |
| 190 | migrationBuilder.CreateTable( |
| 191 | name: "RefreshTokens", |
| 192 | columns: table => new |
| 193 | { |
| 194 | Id = table.Column<Guid>(type: "uuid", nullable: false), |
| 195 | RefreshToken = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false), |
| 196 | ExpirationDT = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), |
| 197 | PreviousRefreshToken = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true), |
| 198 | PreviousExpirationDT = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), |
| 199 | AppUserId = table.Column<Guid>(type: "uuid", nullable: false) |
| 200 | }, |
| 201 | constraints: table => |
| 202 | { |
| 203 | table.PrimaryKey("PK_RefreshTokens", x => x.Id); |
| 204 | table.ForeignKey( |
| 205 | name: "FK_RefreshTokens_AspNetUsers_AppUserId", |
| 206 | column: x => x.AppUserId, |
| 207 | principalTable: "AspNetUsers", |
| 208 | principalColumn: "Id", |
| 209 | onDelete: ReferentialAction.Restrict); |
| 210 | }); |
| 211 | |
| 212 | migrationBuilder.CreateTable( |
| 213 | name: "Trips", |
| 214 | columns: table => new |
| 215 | { |
| 216 | Id = table.Column<Guid>(type: "uuid", nullable: false), |
| 217 | Name = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: false), |
| 218 | Description = table.Column<string>(type: "text", nullable: true), |
| 219 | Destination = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: true), |
| 220 | StartDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: true), |
| 221 | EndDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: true), |
| 222 | Status = table.Column<int>(type: "integer", nullable: false), |
| 223 | DefaultCurrencyId = table.Column<Guid>(type: "uuid", nullable: false), |
| 224 | CreatedById = table.Column<Guid>(type: "uuid", nullable: false) |
| 225 | }, |
| 226 | constraints: table => |
| 227 | { |
| 228 | table.PrimaryKey("PK_Trips", x => x.Id); |
| 229 | table.ForeignKey( |
| 230 | name: "FK_Trips_AspNetUsers_CreatedById", |
| 231 | column: x => x.CreatedById, |
| 232 | principalTable: "AspNetUsers", |
| 233 | principalColumn: "Id", |
| 234 | onDelete: ReferentialAction.Restrict); |
| 235 | table.ForeignKey( |
| 236 | name: "FK_Trips_Currencies_DefaultCurrencyId", |
| 237 | column: x => x.DefaultCurrencyId, |
| 238 | principalTable: "Currencies", |
| 239 | principalColumn: "Id", |
| 240 | onDelete: ReferentialAction.Restrict); |
| 241 | }); |
| 242 | |
| 243 | migrationBuilder.CreateTable( |
| 244 | name: "BudgetCategories", |
| 245 | columns: table => new |
| 246 | { |
| 247 | Id = table.Column<Guid>(type: "uuid", nullable: false), |
| 248 | TripId = table.Column<Guid>(type: "uuid", nullable: false), |
| 249 | Name = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false), |
| 250 | IconName = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: true), |
| 251 | PlannedAmount = table.Column<decimal>(type: "numeric", nullable: true), |
| 252 | DisplayOrder = table.Column<int>(type: "integer", nullable: false) |
| 253 | }, |
| 254 | constraints: table => |
| 255 | { |
| 256 | table.PrimaryKey("PK_BudgetCategories", x => x.Id); |
| 257 | table.ForeignKey( |
| 258 | name: "FK_BudgetCategories_Trips_TripId", |
| 259 | column: x => x.TripId, |
| 260 | principalTable: "Trips", |
| 261 | principalColumn: "Id", |
| 262 | onDelete: ReferentialAction.Restrict); |
| 263 | }); |
| 264 | |
| 265 | migrationBuilder.CreateTable( |
| 266 | name: "SettlementPlans", |
| 267 | columns: table => new |
| 268 | { |
| 269 | Id = table.Column<Guid>(type: "uuid", nullable: false), |
| 270 | TripId = table.Column<Guid>(type: "uuid", nullable: false), |
| 271 | CreatedByUserId = table.Column<Guid>(type: "uuid", nullable: false), |
| 272 | TotalAmount = table.Column<decimal>(type: "numeric", nullable: false), |
| 273 | Status = table.Column<int>(type: "integer", nullable: false), |
| 274 | CompletedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true) |
| 275 | }, |
| 276 | constraints: table => |
| 277 | { |
| 278 | table.PrimaryKey("PK_SettlementPlans", x => x.Id); |
| 279 | table.ForeignKey( |
| 280 | name: "FK_SettlementPlans_AspNetUsers_CreatedByUserId", |
| 281 | column: x => x.CreatedByUserId, |
| 282 | principalTable: "AspNetUsers", |
| 283 | principalColumn: "Id", |
| 284 | onDelete: ReferentialAction.Restrict); |
| 285 | table.ForeignKey( |
| 286 | name: "FK_SettlementPlans_Trips_TripId", |
| 287 | column: x => x.TripId, |
| 288 | principalTable: "Trips", |
| 289 | principalColumn: "Id", |
| 290 | onDelete: ReferentialAction.Restrict); |
| 291 | }); |
| 292 | |
| 293 | migrationBuilder.CreateTable( |
| 294 | name: "SplitPresets", |
| 295 | columns: table => new |
| 296 | { |
| 297 | Id = table.Column<Guid>(type: "uuid", nullable: false), |
| 298 | TripId = table.Column<Guid>(type: "uuid", nullable: false), |
| 299 | Name = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: false), |
| 300 | SplitMethod = table.Column<int>(type: "integer", nullable: false), |
| 301 | CreatedById = table.Column<Guid>(type: "uuid", nullable: false) |
| 302 | }, |
| 303 | constraints: table => |
| 304 | { |
| 305 | table.PrimaryKey("PK_SplitPresets", x => x.Id); |
| 306 | table.ForeignKey( |
| 307 | name: "FK_SplitPresets_AspNetUsers_CreatedById", |
| 308 | column: x => x.CreatedById, |
| 309 | principalTable: "AspNetUsers", |
| 310 | principalColumn: "Id", |
| 311 | onDelete: ReferentialAction.Restrict); |
| 312 | table.ForeignKey( |
| 313 | name: "FK_SplitPresets_Trips_TripId", |
| 314 | column: x => x.TripId, |
| 315 | principalTable: "Trips", |
| 316 | principalColumn: "Id", |
| 317 | onDelete: ReferentialAction.Restrict); |
| 318 | }); |
| 319 | |
| 320 | migrationBuilder.CreateTable( |
| 321 | name: "TripInvitations", |
| 322 | columns: table => new |
| 323 | { |
| 324 | Id = table.Column<Guid>(type: "uuid", nullable: false), |
| 325 | TripId = table.Column<Guid>(type: "uuid", nullable: false), |
| 326 | InvitedByUserId = table.Column<Guid>(type: "uuid", nullable: false), |
| 327 | Token = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false), |
| 328 | Status = table.Column<int>(type: "integer", nullable: false), |
| 329 | ExpiresAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), |
| 330 | RespondedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true) |
| 331 | }, |
| 332 | constraints: table => |
| 333 | { |
| 334 | table.PrimaryKey("PK_TripInvitations", x => x.Id); |
| 335 | table.ForeignKey( |
| 336 | name: "FK_TripInvitations_AspNetUsers_InvitedByUserId", |
| 337 | column: x => x.InvitedByUserId, |
| 338 | principalTable: "AspNetUsers", |
| 339 | principalColumn: "Id", |
| 340 | onDelete: ReferentialAction.Restrict); |
| 341 | table.ForeignKey( |
| 342 | name: "FK_TripInvitations_Trips_TripId", |
| 343 | column: x => x.TripId, |
| 344 | principalTable: "Trips", |
| 345 | principalColumn: "Id", |
| 346 | onDelete: ReferentialAction.Restrict); |
| 347 | }); |
| 348 | |
| 349 | migrationBuilder.CreateTable( |
| 350 | name: "TripParticipants", |
| 351 | columns: table => new |
| 352 | { |
| 353 | Id = table.Column<Guid>(type: "uuid", nullable: false), |
| 354 | TripId = table.Column<Guid>(type: "uuid", nullable: false), |
| 355 | UserId = table.Column<Guid>(type: "uuid", nullable: false), |
| 356 | Role = table.Column<int>(type: "integer", nullable: false), |
| 357 | Nickname = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: true), |
| 358 | JoinedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), |
| 359 | LeftAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true), |
| 360 | IsActive = table.Column<bool>(type: "boolean", nullable: false) |
| 361 | }, |
| 362 | constraints: table => |
| 363 | { |
| 364 | table.PrimaryKey("PK_TripParticipants", x => x.Id); |
| 365 | table.ForeignKey( |
| 366 | name: "FK_TripParticipants_AspNetUsers_UserId", |
| 367 | column: x => x.UserId, |
| 368 | principalTable: "AspNetUsers", |
| 369 | principalColumn: "Id", |
| 370 | onDelete: ReferentialAction.Restrict); |
| 371 | table.ForeignKey( |
| 372 | name: "FK_TripParticipants_Trips_TripId", |
| 373 | column: x => x.TripId, |
| 374 | principalTable: "Trips", |
| 375 | principalColumn: "Id", |
| 376 | onDelete: ReferentialAction.Restrict); |
| 377 | }); |
| 378 | |
| 379 | migrationBuilder.CreateTable( |
| 380 | name: "TripPolls", |
| 381 | columns: table => new |
| 382 | { |
| 383 | Id = table.Column<Guid>(type: "uuid", nullable: false), |
| 384 | TripId = table.Column<Guid>(type: "uuid", nullable: false), |
| 385 | CreatedByUserId = table.Column<Guid>(type: "uuid", nullable: false), |
| 386 | Question = table.Column<string>(type: "character varying(500)", maxLength: 500, nullable: false), |
| 387 | AllowMultipleVotes = table.Column<bool>(type: "boolean", nullable: false), |
| 388 | IsAnonymous = table.Column<bool>(type: "boolean", nullable: false), |
| 389 | ClosedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true) |
| 390 | }, |
| 391 | constraints: table => |
| 392 | { |
| 393 | table.PrimaryKey("PK_TripPolls", x => x.Id); |
| 394 | table.ForeignKey( |
| 395 | name: "FK_TripPolls_AspNetUsers_CreatedByUserId", |
| 396 | column: x => x.CreatedByUserId, |
| 397 | principalTable: "AspNetUsers", |
| 398 | principalColumn: "Id", |
| 399 | onDelete: ReferentialAction.Restrict); |
| 400 | table.ForeignKey( |
| 401 | name: "FK_TripPolls_Trips_TripId", |
| 402 | column: x => x.TripId, |
| 403 | principalTable: "Trips", |
| 404 | principalColumn: "Id", |
| 405 | onDelete: ReferentialAction.Restrict); |
| 406 | }); |
| 407 | |
| 408 | migrationBuilder.CreateTable( |
| 409 | name: "TripWishlistItems", |
| 410 | columns: table => new |
| 411 | { |
| 412 | Id = table.Column<Guid>(type: "uuid", nullable: false), |
| 413 | TripId = table.Column<Guid>(type: "uuid", nullable: false), |
| 414 | AddedByUserId = table.Column<Guid>(type: "uuid", nullable: false), |
| 415 | Title = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: false), |
| 416 | Description = table.Column<string>(type: "text", nullable: true), |
| 417 | Category = table.Column<int>(type: "integer", nullable: false), |
| 418 | Priority = table.Column<int>(type: "integer", nullable: false), |
| 419 | EstimatedCost = table.Column<decimal>(type: "numeric", nullable: true), |
| 420 | Url = table.Column<string>(type: "character varying(500)", maxLength: 500, nullable: true), |
| 421 | Location = table.Column<string>(type: "character varying(300)", maxLength: 300, nullable: true), |
| 422 | IsCompleted = table.Column<bool>(type: "boolean", nullable: false), |
| 423 | CompletedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true), |
| 424 | DisplayOrder = table.Column<int>(type: "integer", nullable: false) |
| 425 | }, |
| 426 | constraints: table => |
| 427 | { |
| 428 | table.PrimaryKey("PK_TripWishlistItems", x => x.Id); |
| 429 | table.ForeignKey( |
| 430 | name: "FK_TripWishlistItems_AspNetUsers_AddedByUserId", |
| 431 | column: x => x.AddedByUserId, |
| 432 | principalTable: "AspNetUsers", |
| 433 | principalColumn: "Id", |
| 434 | onDelete: ReferentialAction.Restrict); |
| 435 | table.ForeignKey( |
| 436 | name: "FK_TripWishlistItems_Trips_TripId", |
| 437 | column: x => x.TripId, |
| 438 | principalTable: "Trips", |
| 439 | principalColumn: "Id", |
| 440 | onDelete: ReferentialAction.Restrict); |
| 441 | }); |
| 442 | |
| 443 | migrationBuilder.CreateTable( |
| 444 | name: "BudgetCategoryTranslations", |
| 445 | columns: table => new |
| 446 | { |
| 447 | Id = table.Column<Guid>(type: "uuid", nullable: false), |
| 448 | BudgetCategoryId = table.Column<Guid>(type: "uuid", nullable: false), |
| 449 | Culture = table.Column<string>(type: "character varying(5)", maxLength: 5, nullable: false), |
| 450 | Name = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false) |
| 451 | }, |
| 452 | constraints: table => |
| 453 | { |
| 454 | table.PrimaryKey("PK_BudgetCategoryTranslations", x => x.Id); |
| 455 | table.ForeignKey( |
| 456 | name: "FK_BudgetCategoryTranslations_BudgetCategories_BudgetCategoryId", |
| 457 | column: x => x.BudgetCategoryId, |
| 458 | principalTable: "BudgetCategories", |
| 459 | principalColumn: "Id", |
| 460 | onDelete: ReferentialAction.Restrict); |
| 461 | }); |
| 462 | |
| 463 | migrationBuilder.CreateTable( |
| 464 | name: "Expenses", |
| 465 | columns: table => new |
| 466 | { |
| 467 | Id = table.Column<Guid>(type: "uuid", nullable: false), |
| 468 | TripId = table.Column<Guid>(type: "uuid", nullable: false), |
| 469 | PaidByUserId = table.Column<Guid>(type: "uuid", nullable: false), |
| 470 | BudgetCategoryId = table.Column<Guid>(type: "uuid", nullable: true), |
| 471 | CurrencyId = table.Column<Guid>(type: "uuid", nullable: true), |
| 472 | Amount = table.Column<decimal>(type: "numeric", nullable: false), |
| 473 | Description = table.Column<string>(type: "character varying(500)", maxLength: 500, nullable: true), |
| 474 | ExpenseDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), |
| 475 | SplitMethod = table.Column<int>(type: "integer", nullable: false) |
| 476 | }, |
| 477 | constraints: table => |
| 478 | { |
| 479 | table.PrimaryKey("PK_Expenses", x => x.Id); |
| 480 | table.ForeignKey( |
| 481 | name: "FK_Expenses_AspNetUsers_PaidByUserId", |
| 482 | column: x => x.PaidByUserId, |
| 483 | principalTable: "AspNetUsers", |
| 484 | principalColumn: "Id", |
| 485 | onDelete: ReferentialAction.Restrict); |
| 486 | table.ForeignKey( |
| 487 | name: "FK_Expenses_BudgetCategories_BudgetCategoryId", |
| 488 | column: x => x.BudgetCategoryId, |
| 489 | principalTable: "BudgetCategories", |
| 490 | principalColumn: "Id", |
| 491 | onDelete: ReferentialAction.Restrict); |
| 492 | table.ForeignKey( |
| 493 | name: "FK_Expenses_Currencies_CurrencyId", |
| 494 | column: x => x.CurrencyId, |
| 495 | principalTable: "Currencies", |
| 496 | principalColumn: "Id", |
| 497 | onDelete: ReferentialAction.Restrict); |
| 498 | table.ForeignKey( |
| 499 | name: "FK_Expenses_Trips_TripId", |
| 500 | column: x => x.TripId, |
| 501 | principalTable: "Trips", |
| 502 | principalColumn: "Id", |
| 503 | onDelete: ReferentialAction.Restrict); |
| 504 | }); |
| 505 | |
| 506 | migrationBuilder.CreateTable( |
| 507 | name: "SettlementPayments", |
| 508 | columns: table => new |
| 509 | { |
| 510 | Id = table.Column<Guid>(type: "uuid", nullable: false), |
| 511 | SettlementPlanId = table.Column<Guid>(type: "uuid", nullable: false), |
| 512 | FromUserId = table.Column<Guid>(type: "uuid", nullable: false), |
| 513 | ToUserId = table.Column<Guid>(type: "uuid", nullable: false), |
| 514 | Amount = table.Column<decimal>(type: "numeric", nullable: false), |
| 515 | Status = table.Column<int>(type: "integer", nullable: false), |
| 516 | MarkedPaidAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true), |
| 517 | ConfirmedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true) |
| 518 | }, |
| 519 | constraints: table => |
| 520 | { |
| 521 | table.PrimaryKey("PK_SettlementPayments", x => x.Id); |
| 522 | table.ForeignKey( |
| 523 | name: "FK_SettlementPayments_AspNetUsers_FromUserId", |
| 524 | column: x => x.FromUserId, |
| 525 | principalTable: "AspNetUsers", |
| 526 | principalColumn: "Id", |
| 527 | onDelete: ReferentialAction.Restrict); |
| 528 | table.ForeignKey( |
| 529 | name: "FK_SettlementPayments_AspNetUsers_ToUserId", |
| 530 | column: x => x.ToUserId, |
| 531 | principalTable: "AspNetUsers", |
| 532 | principalColumn: "Id", |
| 533 | onDelete: ReferentialAction.Restrict); |
| 534 | table.ForeignKey( |
| 535 | name: "FK_SettlementPayments_SettlementPlans_SettlementPlanId", |
| 536 | column: x => x.SettlementPlanId, |
| 537 | principalTable: "SettlementPlans", |
| 538 | principalColumn: "Id", |
| 539 | onDelete: ReferentialAction.Restrict); |
| 540 | }); |
| 541 | |
| 542 | migrationBuilder.CreateTable( |
| 543 | name: "SplitPresetMembers", |
| 544 | columns: table => new |
| 545 | { |
| 546 | Id = table.Column<Guid>(type: "uuid", nullable: false), |
| 547 | SplitPresetId = table.Column<Guid>(type: "uuid", nullable: false), |
| 548 | UserId = table.Column<Guid>(type: "uuid", nullable: false), |
| 549 | ShareWeight = table.Column<decimal>(type: "numeric", nullable: true), |
| 550 | Percentage = table.Column<decimal>(type: "numeric", nullable: true) |
| 551 | }, |
| 552 | constraints: table => |
| 553 | { |
| 554 | table.PrimaryKey("PK_SplitPresetMembers", x => x.Id); |
| 555 | table.ForeignKey( |
| 556 | name: "FK_SplitPresetMembers_AspNetUsers_UserId", |
| 557 | column: x => x.UserId, |
| 558 | principalTable: "AspNetUsers", |
| 559 | principalColumn: "Id", |
| 560 | onDelete: ReferentialAction.Restrict); |
| 561 | table.ForeignKey( |
| 562 | name: "FK_SplitPresetMembers_SplitPresets_SplitPresetId", |
| 563 | column: x => x.SplitPresetId, |
| 564 | principalTable: "SplitPresets", |
| 565 | principalColumn: "Id", |
| 566 | onDelete: ReferentialAction.Restrict); |
| 567 | }); |
| 568 | |
| 569 | migrationBuilder.CreateTable( |
| 570 | name: "TripPollOptions", |
| 571 | columns: table => new |
| 572 | { |
| 573 | Id = table.Column<Guid>(type: "uuid", nullable: false), |
| 574 | PollId = table.Column<Guid>(type: "uuid", nullable: false), |
| 575 | Text = table.Column<string>(type: "character varying(300)", maxLength: 300, nullable: false), |
| 576 | DisplayOrder = table.Column<int>(type: "integer", nullable: false) |
| 577 | }, |
| 578 | constraints: table => |
| 579 | { |
| 580 | table.PrimaryKey("PK_TripPollOptions", x => x.Id); |
| 581 | table.ForeignKey( |
| 582 | name: "FK_TripPollOptions_TripPolls_PollId", |
| 583 | column: x => x.PollId, |
| 584 | principalTable: "TripPolls", |
| 585 | principalColumn: "Id", |
| 586 | onDelete: ReferentialAction.Restrict); |
| 587 | }); |
| 588 | |
| 589 | migrationBuilder.CreateTable( |
| 590 | name: "TripWishlistVotes", |
| 591 | columns: table => new |
| 592 | { |
| 593 | Id = table.Column<Guid>(type: "uuid", nullable: false), |
| 594 | WishlistItemId = table.Column<Guid>(type: "uuid", nullable: false), |
| 595 | UserId = table.Column<Guid>(type: "uuid", nullable: false), |
| 596 | IsInterested = table.Column<bool>(type: "boolean", nullable: false) |
| 597 | }, |
| 598 | constraints: table => |
| 599 | { |
| 600 | table.PrimaryKey("PK_TripWishlistVotes", x => x.Id); |
| 601 | table.ForeignKey( |
| 602 | name: "FK_TripWishlistVotes_AspNetUsers_UserId", |
| 603 | column: x => x.UserId, |
| 604 | principalTable: "AspNetUsers", |
| 605 | principalColumn: "Id", |
| 606 | onDelete: ReferentialAction.Restrict); |
| 607 | table.ForeignKey( |
| 608 | name: "FK_TripWishlistVotes_TripWishlistItems_WishlistItemId", |
| 609 | column: x => x.WishlistItemId, |
| 610 | principalTable: "TripWishlistItems", |
| 611 | principalColumn: "Id", |
| 612 | onDelete: ReferentialAction.Restrict); |
| 613 | }); |
| 614 | |
| 615 | migrationBuilder.CreateTable( |
| 616 | name: "ExpenseSplits", |
| 617 | columns: table => new |
| 618 | { |
| 619 | Id = table.Column<Guid>(type: "uuid", nullable: false), |
| 620 | ExpenseId = table.Column<Guid>(type: "uuid", nullable: false), |
| 621 | UserId = table.Column<Guid>(type: "uuid", nullable: false), |
| 622 | Amount = table.Column<decimal>(type: "numeric", nullable: false), |
| 623 | Percentage = table.Column<decimal>(type: "numeric", nullable: true) |
| 624 | }, |
| 625 | constraints: table => |
| 626 | { |
| 627 | table.PrimaryKey("PK_ExpenseSplits", x => x.Id); |
| 628 | table.ForeignKey( |
| 629 | name: "FK_ExpenseSplits_AspNetUsers_UserId", |
| 630 | column: x => x.UserId, |
| 631 | principalTable: "AspNetUsers", |
| 632 | principalColumn: "Id", |
| 633 | onDelete: ReferentialAction.Restrict); |
| 634 | table.ForeignKey( |
| 635 | name: "FK_ExpenseSplits_Expenses_ExpenseId", |
| 636 | column: x => x.ExpenseId, |
| 637 | principalTable: "Expenses", |
| 638 | principalColumn: "Id", |
| 639 | onDelete: ReferentialAction.Restrict); |
| 640 | }); |
| 641 | |
| 642 | migrationBuilder.CreateTable( |
| 643 | name: "TripPollVotes", |
| 644 | columns: table => new |
| 645 | { |
| 646 | Id = table.Column<Guid>(type: "uuid", nullable: false), |
| 647 | PollOptionId = table.Column<Guid>(type: "uuid", nullable: false), |
| 648 | UserId = table.Column<Guid>(type: "uuid", nullable: false) |
| 649 | }, |
| 650 | constraints: table => |
| 651 | { |
| 652 | table.PrimaryKey("PK_TripPollVotes", x => x.Id); |
| 653 | table.ForeignKey( |
| 654 | name: "FK_TripPollVotes_AspNetUsers_UserId", |
| 655 | column: x => x.UserId, |
| 656 | principalTable: "AspNetUsers", |
| 657 | principalColumn: "Id", |
| 658 | onDelete: ReferentialAction.Restrict); |
| 659 | table.ForeignKey( |
| 660 | name: "FK_TripPollVotes_TripPollOptions_PollOptionId", |
| 661 | column: x => x.PollOptionId, |
| 662 | principalTable: "TripPollOptions", |
| 663 | principalColumn: "Id", |
| 664 | onDelete: ReferentialAction.Restrict); |
| 665 | }); |
| 666 | |
| 667 | migrationBuilder.CreateIndex( |
| 668 | name: "IX_AspNetRoleClaims_RoleId", |
| 669 | table: "AspNetRoleClaims", |
| 670 | column: "RoleId"); |
| 671 | |
| 672 | migrationBuilder.CreateIndex( |
| 673 | name: "RoleNameIndex", |
| 674 | table: "AspNetRoles", |
| 675 | column: "NormalizedName", |
| 676 | unique: true); |
| 677 | |
| 678 | migrationBuilder.CreateIndex( |
| 679 | name: "IX_AspNetUserClaims_UserId", |
| 680 | table: "AspNetUserClaims", |
| 681 | column: "UserId"); |
| 682 | |
| 683 | migrationBuilder.CreateIndex( |
| 684 | name: "IX_AspNetUserLogins_UserId", |
| 685 | table: "AspNetUserLogins", |
| 686 | column: "UserId"); |
| 687 | |
| 688 | migrationBuilder.CreateIndex( |
| 689 | name: "IX_AspNetUserRoles_RoleId", |
| 690 | table: "AspNetUserRoles", |
| 691 | column: "RoleId"); |
| 692 | |
| 693 | migrationBuilder.CreateIndex( |
| 694 | name: "EmailIndex", |
| 695 | table: "AspNetUsers", |
| 696 | column: "NormalizedEmail"); |
| 697 | |
| 698 | migrationBuilder.CreateIndex( |
| 699 | name: "UserNameIndex", |
| 700 | table: "AspNetUsers", |
| 701 | column: "NormalizedUserName", |
| 702 | unique: true); |
| 703 | |
| 704 | migrationBuilder.CreateIndex( |
| 705 | name: "IX_BudgetCategories_TripId", |
| 706 | table: "BudgetCategories", |
| 707 | column: "TripId"); |
| 708 | |
| 709 | migrationBuilder.CreateIndex( |
| 710 | name: "IX_BudgetCategoryTranslations_BudgetCategoryId", |
| 711 | table: "BudgetCategoryTranslations", |
| 712 | column: "BudgetCategoryId"); |
| 713 | |
| 714 | migrationBuilder.CreateIndex( |
| 715 | name: "IX_Expenses_BudgetCategoryId", |
| 716 | table: "Expenses", |
| 717 | column: "BudgetCategoryId"); |
| 718 | |
| 719 | migrationBuilder.CreateIndex( |
| 720 | name: "IX_Expenses_CurrencyId", |
| 721 | table: "Expenses", |
| 722 | column: "CurrencyId"); |
| 723 | |
| 724 | migrationBuilder.CreateIndex( |
| 725 | name: "IX_Expenses_PaidByUserId", |
| 726 | table: "Expenses", |
| 727 | column: "PaidByUserId"); |
| 728 | |
| 729 | migrationBuilder.CreateIndex( |
| 730 | name: "IX_Expenses_TripId", |
| 731 | table: "Expenses", |
| 732 | column: "TripId"); |
| 733 | |
| 734 | migrationBuilder.CreateIndex( |
| 735 | name: "IX_ExpenseSplits_ExpenseId", |
| 736 | table: "ExpenseSplits", |
| 737 | column: "ExpenseId"); |
| 738 | |
| 739 | migrationBuilder.CreateIndex( |
| 740 | name: "IX_ExpenseSplits_UserId", |
| 741 | table: "ExpenseSplits", |
| 742 | column: "UserId"); |
| 743 | |
| 744 | migrationBuilder.CreateIndex( |
| 745 | name: "IX_RefreshTokens_AppUserId", |
| 746 | table: "RefreshTokens", |
| 747 | column: "AppUserId"); |
| 748 | |
| 749 | migrationBuilder.CreateIndex( |
| 750 | name: "IX_SettlementPayments_FromUserId", |
| 751 | table: "SettlementPayments", |
| 752 | column: "FromUserId"); |
| 753 | |
| 754 | migrationBuilder.CreateIndex( |
| 755 | name: "IX_SettlementPayments_SettlementPlanId", |
| 756 | table: "SettlementPayments", |
| 757 | column: "SettlementPlanId"); |
| 758 | |
| 759 | migrationBuilder.CreateIndex( |
| 760 | name: "IX_SettlementPayments_ToUserId", |
| 761 | table: "SettlementPayments", |
| 762 | column: "ToUserId"); |
| 763 | |
| 764 | migrationBuilder.CreateIndex( |
| 765 | name: "IX_SettlementPlans_CreatedByUserId", |
| 766 | table: "SettlementPlans", |
| 767 | column: "CreatedByUserId"); |
| 768 | |
| 769 | migrationBuilder.CreateIndex( |
| 770 | name: "IX_SettlementPlans_TripId", |
| 771 | table: "SettlementPlans", |
| 772 | column: "TripId"); |
| 773 | |
| 774 | migrationBuilder.CreateIndex( |
| 775 | name: "IX_SplitPresetMembers_SplitPresetId", |
| 776 | table: "SplitPresetMembers", |
| 777 | column: "SplitPresetId"); |
| 778 | |
| 779 | migrationBuilder.CreateIndex( |
| 780 | name: "IX_SplitPresetMembers_UserId", |
| 781 | table: "SplitPresetMembers", |
| 782 | column: "UserId"); |
| 783 | |
| 784 | migrationBuilder.CreateIndex( |
| 785 | name: "IX_SplitPresets_CreatedById", |
| 786 | table: "SplitPresets", |
| 787 | column: "CreatedById"); |
| 788 | |
| 789 | migrationBuilder.CreateIndex( |
| 790 | name: "IX_SplitPresets_TripId", |
| 791 | table: "SplitPresets", |
| 792 | column: "TripId"); |
| 793 | |
| 794 | migrationBuilder.CreateIndex( |
| 795 | name: "IX_TripInvitations_InvitedByUserId", |
| 796 | table: "TripInvitations", |
| 797 | column: "InvitedByUserId"); |
| 798 | |
| 799 | migrationBuilder.CreateIndex( |
| 800 | name: "IX_TripInvitations_Token", |
| 801 | table: "TripInvitations", |
| 802 | column: "Token", |
| 803 | unique: true); |
| 804 | |
| 805 | migrationBuilder.CreateIndex( |
| 806 | name: "IX_TripInvitations_TripId", |
| 807 | table: "TripInvitations", |
| 808 | column: "TripId"); |
| 809 | |
| 810 | migrationBuilder.CreateIndex( |
| 811 | name: "IX_TripParticipants_TripId_UserId", |
| 812 | table: "TripParticipants", |
| 813 | columns: new[] { "TripId", "UserId" }, |
| 814 | unique: true); |
| 815 | |
| 816 | migrationBuilder.CreateIndex( |
| 817 | name: "IX_TripParticipants_UserId", |
| 818 | table: "TripParticipants", |
| 819 | column: "UserId"); |
| 820 | |
| 821 | migrationBuilder.CreateIndex( |
| 822 | name: "IX_TripPollOptions_PollId", |
| 823 | table: "TripPollOptions", |
| 824 | column: "PollId"); |
| 825 | |
| 826 | migrationBuilder.CreateIndex( |
| 827 | name: "IX_TripPolls_CreatedByUserId", |
| 828 | table: "TripPolls", |
| 829 | column: "CreatedByUserId"); |
| 830 | |
| 831 | migrationBuilder.CreateIndex( |
| 832 | name: "IX_TripPolls_TripId", |
| 833 | table: "TripPolls", |
| 834 | column: "TripId"); |
| 835 | |
| 836 | migrationBuilder.CreateIndex( |
| 837 | name: "IX_TripPollVotes_PollOptionId_UserId", |
| 838 | table: "TripPollVotes", |
| 839 | columns: new[] { "PollOptionId", "UserId" }, |
| 840 | unique: true); |
| 841 | |
| 842 | migrationBuilder.CreateIndex( |
| 843 | name: "IX_TripPollVotes_UserId", |
| 844 | table: "TripPollVotes", |
| 845 | column: "UserId"); |
| 846 | |
| 847 | migrationBuilder.CreateIndex( |
| 848 | name: "IX_Trips_CreatedById", |
| 849 | table: "Trips", |
| 850 | column: "CreatedById"); |
| 851 | |
| 852 | migrationBuilder.CreateIndex( |
| 853 | name: "IX_Trips_DefaultCurrencyId", |
| 854 | table: "Trips", |
| 855 | column: "DefaultCurrencyId"); |
| 856 | |
| 857 | migrationBuilder.CreateIndex( |
| 858 | name: "IX_TripWishlistItems_AddedByUserId", |
| 859 | table: "TripWishlistItems", |
| 860 | column: "AddedByUserId"); |
| 861 | |
| 862 | migrationBuilder.CreateIndex( |
| 863 | name: "IX_TripWishlistItems_TripId", |
| 864 | table: "TripWishlistItems", |
| 865 | column: "TripId"); |
| 866 | |
| 867 | migrationBuilder.CreateIndex( |
| 868 | name: "IX_TripWishlistVotes_UserId", |
| 869 | table: "TripWishlistVotes", |
| 870 | column: "UserId"); |
| 871 | |
| 872 | migrationBuilder.CreateIndex( |
| 873 | name: "IX_TripWishlistVotes_WishlistItemId_UserId", |
| 874 | table: "TripWishlistVotes", |
| 875 | columns: new[] { "WishlistItemId", "UserId" }, |
| 876 | unique: true); |
| 877 | } |
| 878 | |
| 879 | /// <inheritdoc /> |
| 880 | protected override void Down(MigrationBuilder migrationBuilder) |
| 881 | { |
| 882 | migrationBuilder.DropTable( |
| 883 | name: "AspNetRoleClaims"); |
| 884 | |
| 885 | migrationBuilder.DropTable( |
| 886 | name: "AspNetUserClaims"); |
| 887 | |
| 888 | migrationBuilder.DropTable( |
| 889 | name: "AspNetUserLogins"); |
| 890 | |
| 891 | migrationBuilder.DropTable( |
| 892 | name: "AspNetUserRoles"); |
| 893 | |
| 894 | migrationBuilder.DropTable( |
| 895 | name: "AspNetUserTokens"); |
| 896 | |
| 897 | migrationBuilder.DropTable( |
| 898 | name: "BudgetCategoryTranslations"); |
| 899 | |
| 900 | migrationBuilder.DropTable( |
| 901 | name: "DataProtectionKeys"); |
| 902 | |
| 903 | migrationBuilder.DropTable( |
| 904 | name: "ExpenseSplits"); |
| 905 | |
| 906 | migrationBuilder.DropTable( |
| 907 | name: "RefreshTokens"); |
| 908 | |
| 909 | migrationBuilder.DropTable( |
| 910 | name: "SettlementPayments"); |
| 911 | |
| 912 | migrationBuilder.DropTable( |
| 913 | name: "SplitPresetMembers"); |
| 914 | |
| 915 | migrationBuilder.DropTable( |
| 916 | name: "TripInvitations"); |
| 917 | |
| 918 | migrationBuilder.DropTable( |
| 919 | name: "TripParticipants"); |
| 920 | |
| 921 | migrationBuilder.DropTable( |
| 922 | name: "TripPollVotes"); |
| 923 | |
| 924 | migrationBuilder.DropTable( |
| 925 | name: "TripWishlistVotes"); |
| 926 | |
| 927 | migrationBuilder.DropTable( |
| 928 | name: "AspNetRoles"); |
| 929 | |
| 930 | migrationBuilder.DropTable( |
| 931 | name: "Expenses"); |
| 932 | |
| 933 | migrationBuilder.DropTable( |
| 934 | name: "SettlementPlans"); |
| 935 | |
| 936 | migrationBuilder.DropTable( |
| 937 | name: "SplitPresets"); |
| 938 | |
| 939 | migrationBuilder.DropTable( |
| 940 | name: "TripPollOptions"); |
| 941 | |
| 942 | migrationBuilder.DropTable( |
| 943 | name: "TripWishlistItems"); |
| 944 | |
| 945 | migrationBuilder.DropTable( |
| 946 | name: "BudgetCategories"); |
| 947 | |
| 948 | migrationBuilder.DropTable( |
| 949 | name: "TripPolls"); |
| 950 | |
| 951 | migrationBuilder.DropTable( |
| 952 | name: "Trips"); |
| 953 | |
| 954 | migrationBuilder.DropTable( |
| 955 | name: "AspNetUsers"); |
| 956 | |
| 957 | migrationBuilder.DropTable( |
| 958 | name: "Currencies"); |
| 959 | } |
| 960 | } |
| 961 | } |
| 962 | |