78 lines
3.2 KiB
C#
78 lines
3.2 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
namespace NugetTest.AspCore.Migrations
|
|
{
|
|
public partial class init : Migration
|
|
{
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "People",
|
|
columns: table => new
|
|
{
|
|
PersonId = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
IsRemoved = table.Column<bool>(type: "bit", nullable: false),
|
|
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
RemoveTime = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
FirstName = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
FamilyName = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
PersonId1 = table.Column<int>(type: "int", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_People", x => x.PersonId);
|
|
table.ForeignKey(
|
|
name: "FK_People_People_PersonId1",
|
|
column: x => x.PersonId1,
|
|
principalTable: "People",
|
|
principalColumn: "PersonId",
|
|
onDelete: ReferentialAction.Restrict);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Articles",
|
|
columns: table => new
|
|
{
|
|
ArticleId = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
IsRemoved = table.Column<bool>(type: "bit", nullable: false),
|
|
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
RemoveTime = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
Content = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
PersonId = table.Column<int>(type: "int", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Articles", x => x.ArticleId);
|
|
table.ForeignKey(
|
|
name: "FK_Articles_People_PersonId",
|
|
column: x => x.PersonId,
|
|
principalTable: "People",
|
|
principalColumn: "PersonId",
|
|
onDelete: ReferentialAction.Restrict);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Articles_PersonId",
|
|
table: "Articles",
|
|
column: "PersonId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_People_PersonId1",
|
|
table: "People",
|
|
column: "PersonId1");
|
|
}
|
|
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "Articles");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "People");
|
|
}
|
|
}
|
|
}
|