[899b19d] | 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 AddReviews : Migration
|
---|
| 10 | {
|
---|
| 11 | protected override void Up(MigrationBuilder migrationBuilder)
|
---|
| 12 | {
|
---|
| 13 | migrationBuilder.AddColumn<bool>(
|
---|
| 14 | name: "IsAdmin",
|
---|
| 15 | table: "Users",
|
---|
| 16 | type: "boolean",
|
---|
| 17 | nullable: false,
|
---|
| 18 | defaultValue: false);
|
---|
| 19 |
|
---|
| 20 | migrationBuilder.CreateTable(
|
---|
| 21 | name: "Reviews",
|
---|
| 22 | columns: table => new
|
---|
| 23 | {
|
---|
| 24 | Id = table.Column<int>(type: "integer", nullable: false)
|
---|
| 25 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
---|
| 26 | Title = table.Column<string>(type: "text", nullable: false),
|
---|
| 27 | Description = table.Column<string>(type: "text", nullable: false),
|
---|
| 28 | Stars = table.Column<int>(type: "integer", nullable: false),
|
---|
| 29 | CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
---|
| 30 | UserId = table.Column<int>(type: "integer", nullable: false),
|
---|
| 31 | RestaurantId = table.Column<int>(type: "integer", nullable: false)
|
---|
| 32 | },
|
---|
| 33 | constraints: table =>
|
---|
| 34 | {
|
---|
| 35 | table.PrimaryKey("PK_Reviews", x => x.Id);
|
---|
| 36 | table.ForeignKey(
|
---|
| 37 | name: "FK_Reviews_Restoraunts_RestaurantId",
|
---|
| 38 | column: x => x.RestaurantId,
|
---|
| 39 | principalTable: "Restoraunts",
|
---|
| 40 | principalColumn: "Id",
|
---|
| 41 | onDelete: ReferentialAction.Cascade);
|
---|
| 42 | table.ForeignKey(
|
---|
| 43 | name: "FK_Reviews_Users_UserId",
|
---|
| 44 | column: x => x.UserId,
|
---|
| 45 | principalTable: "Users",
|
---|
| 46 | principalColumn: "Id",
|
---|
| 47 | onDelete: ReferentialAction.Cascade);
|
---|
| 48 | });
|
---|
| 49 |
|
---|
| 50 | migrationBuilder.CreateIndex(
|
---|
| 51 | name: "IX_Reviews_RestaurantId",
|
---|
| 52 | table: "Reviews",
|
---|
| 53 | column: "RestaurantId");
|
---|
| 54 |
|
---|
| 55 | migrationBuilder.CreateIndex(
|
---|
| 56 | name: "IX_Reviews_UserId",
|
---|
| 57 | table: "Reviews",
|
---|
| 58 | column: "UserId");
|
---|
| 59 | }
|
---|
| 60 |
|
---|
| 61 | protected override void Down(MigrationBuilder migrationBuilder)
|
---|
| 62 | {
|
---|
| 63 | migrationBuilder.DropTable(
|
---|
| 64 | name: "Reviews");
|
---|
| 65 |
|
---|
| 66 | migrationBuilder.DropColumn(
|
---|
| 67 | name: "IsAdmin",
|
---|
| 68 | table: "Users");
|
---|
| 69 | }
|
---|
| 70 | }
|
---|
| 71 | }
|
---|