1 | using System;
|
---|
2 | using Microsoft.EntityFrameworkCore.Migrations;
|
---|
3 | using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
---|
4 |
|
---|
5 | #nullable disable
|
---|
6 |
|
---|
7 | namespace backend.Migrations
|
---|
8 | {
|
---|
9 | public partial class InitialArchitecture : Migration
|
---|
10 | {
|
---|
11 | protected override void Up(MigrationBuilder migrationBuilder)
|
---|
12 | {
|
---|
13 | migrationBuilder.CreateTable(
|
---|
14 | name: "Users",
|
---|
15 | columns: table => new
|
---|
16 | {
|
---|
17 | Id = table.Column<int>(type: "integer", nullable: false)
|
---|
18 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
---|
19 | Username = table.Column<string>(type: "text", nullable: false),
|
---|
20 | Password = table.Column<string>(type: "text", nullable: false)
|
---|
21 | },
|
---|
22 | constraints: table =>
|
---|
23 | {
|
---|
24 | table.PrimaryKey("PK_Users", x => x.Id);
|
---|
25 | });
|
---|
26 |
|
---|
27 | migrationBuilder.CreateTable(
|
---|
28 | name: "Restoraunts",
|
---|
29 | columns: table => new
|
---|
30 | {
|
---|
31 | Id = table.Column<int>(type: "integer", nullable: false)
|
---|
32 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
---|
33 | OwnerFk = table.Column<int>(type: "integer", nullable: true),
|
---|
34 | Name = table.Column<string>(type: "text", nullable: false)
|
---|
35 | },
|
---|
36 | constraints: table =>
|
---|
37 | {
|
---|
38 | table.PrimaryKey("PK_Restoraunts", x => x.Id);
|
---|
39 | table.ForeignKey(
|
---|
40 | name: "FK_Restoraunts_Users_OwnerFk",
|
---|
41 | column: x => x.OwnerFk,
|
---|
42 | principalTable: "Users",
|
---|
43 | principalColumn: "Id");
|
---|
44 | });
|
---|
45 |
|
---|
46 | migrationBuilder.CreateTable(
|
---|
47 | name: "Reservations",
|
---|
48 | columns: table => new
|
---|
49 | {
|
---|
50 | Id = table.Column<int>(type: "integer", nullable: false)
|
---|
51 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
---|
52 | StartDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
---|
53 | RestaurantId = table.Column<int>(type: "integer", nullable: false),
|
---|
54 | ReservationPlace = table.Column<int>(type: "integer", nullable: false),
|
---|
55 | ReservationStatus = table.Column<int>(type: "integer", nullable: false),
|
---|
56 | ReservationType = table.Column<int>(type: "integer", nullable: false),
|
---|
57 | ContactName = table.Column<string>(type: "text", nullable: false),
|
---|
58 | ContactNumber = table.Column<string>(type: "text", nullable: false)
|
---|
59 | },
|
---|
60 | constraints: table =>
|
---|
61 | {
|
---|
62 | table.PrimaryKey("PK_Reservations", x => x.Id);
|
---|
63 | table.ForeignKey(
|
---|
64 | name: "FK_Reservations_Restoraunts_RestaurantId",
|
---|
65 | column: x => x.RestaurantId,
|
---|
66 | principalTable: "Restoraunts",
|
---|
67 | principalColumn: "Id",
|
---|
68 | onDelete: ReferentialAction.Cascade);
|
---|
69 | });
|
---|
70 |
|
---|
71 | migrationBuilder.CreateIndex(
|
---|
72 | name: "IX_Reservations_RestaurantId",
|
---|
73 | table: "Reservations",
|
---|
74 | column: "RestaurantId");
|
---|
75 |
|
---|
76 | migrationBuilder.CreateIndex(
|
---|
77 | name: "IX_Restoraunts_OwnerFk",
|
---|
78 | table: "Restoraunts",
|
---|
79 | column: "OwnerFk",
|
---|
80 | unique: true);
|
---|
81 | }
|
---|
82 |
|
---|
83 | protected override void Down(MigrationBuilder migrationBuilder)
|
---|
84 | {
|
---|
85 | migrationBuilder.DropTable(
|
---|
86 | name: "Reservations");
|
---|
87 |
|
---|
88 | migrationBuilder.DropTable(
|
---|
89 | name: "Restoraunts");
|
---|
90 |
|
---|
91 | migrationBuilder.DropTable(
|
---|
92 | name: "Users");
|
---|
93 | }
|
---|
94 | }
|
---|
95 | }
|
---|