using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CityInfo.API.Migrations
{
///
public partial class CityInfoDBInitialMigration : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Cities",
columns: table => new
{
Id = table.Column(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column(type: "TEXT", maxLength: 50, nullable: false),
Description = table.Column(type: "TEXT", maxLength: 200, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Cities", x => x.Id);
});
migrationBuilder.CreateTable(
name: "PointsOfInterest",
columns: table => new
{
Id = table.Column(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column(type: "TEXT", maxLength: 50, nullable: false),
CityId = table.Column(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_PointsOfInterest", x => x.Id);
table.ForeignKey(
name: "FK_PointsOfInterest_Cities_CityId",
column: x => x.CityId,
principalTable: "Cities",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_PointsOfInterest_CityId",
table: "PointsOfInterest",
column: "CityId");
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "PointsOfInterest");
migrationBuilder.DropTable(
name: "Cities");
}
}
}