Files
FichaBackend/FichaBackend/Migrations/20230825132916_new.cs
Sergey Karmanov 7a6acd24ac
All checks were successful
Create and publish a Docker image / Publish image (push) Successful in 18s
Create and publish a Docker image / Deploy image (push) Successful in 2s
Загрузил миграции
2023-08-26 13:38:30 +03:00

100 lines
3.7 KiB
C#

using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace FichaBackend.Migrations
{
/// <inheritdoc />
public partial class @new : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<long>(
name: "GuideId",
table: "Cities",
type: "bigint",
nullable: true);
migrationBuilder.CreateTable(
name: "Guides",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
FullName = table.Column<string>(type: "text", nullable: false),
PhoneNumber = table.Column<string>(type: "text", nullable: false),
ContactUrl = table.Column<string>(type: "text", nullable: true),
Rating = table.Column<float>(type: "real", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Guides", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Museums",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
CityId = table.Column<long>(type: "bigint", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
Longtitude = table.Column<double>(type: "double precision", nullable: false),
Latitude = table.Column<double>(type: "double precision", nullable: false),
Price = table.Column<float>(type: "real", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Museums", x => x.Id);
table.ForeignKey(
name: "FK_Museums_Cities_CityId",
column: x => x.CityId,
principalTable: "Cities",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Cities_GuideId",
table: "Cities",
column: "GuideId");
migrationBuilder.CreateIndex(
name: "IX_Museums_CityId",
table: "Museums",
column: "CityId");
migrationBuilder.AddForeignKey(
name: "FK_Cities_Guides_GuideId",
table: "Cities",
column: "GuideId",
principalTable: "Guides",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Cities_Guides_GuideId",
table: "Cities");
migrationBuilder.DropTable(
name: "Guides");
migrationBuilder.DropTable(
name: "Museums");
migrationBuilder.DropIndex(
name: "IX_Cities_GuideId",
table: "Cities");
migrationBuilder.DropColumn(
name: "GuideId",
table: "Cities");
}
}
}