session-companion/SessionCompanion/SessionCompanion.Database/Migrations/20201203161115_Base-Tables.cs

249 lines
10 KiB
C#
Raw Normal View History

2020-12-03 17:13:17 +01:00
using Microsoft.EntityFrameworkCore.Migrations;
namespace SessionCompanion.Database.Migrations
{
public partial class BaseTables : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Alignments",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1")
},
constraints: table =>
{
table.PrimaryKey("PK_Alignments", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Backgrounds",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1")
},
constraints: table =>
{
table.PrimaryKey("PK_Backgrounds", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Classes",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Classes", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Races",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Races", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Users",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Nickname = table.Column<string>(type: "nvarchar(max)", nullable: true),
Password = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Users", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Characters",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
UserId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Characters", x => x.Id);
table.ForeignKey(
name: "FK_Characters_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Biographies",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
CharacterId = table.Column<int>(type: "int", nullable: false),
Name = table.Column<string>(type: "nvarchar(max)", nullable: true),
ClassId = table.Column<int>(type: "int", nullable: false),
RaceId = table.Column<int>(type: "int", nullable: false),
AlignmentId = table.Column<int>(type: "int", nullable: false),
BackgroundId = table.Column<int>(type: "int", nullable: false),
Sex = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Biographies", x => x.Id);
table.ForeignKey(
name: "FK_Biographies_Alignments_AlignmentId",
column: x => x.AlignmentId,
principalTable: "Alignments",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Biographies_Backgrounds_BackgroundId",
column: x => x.BackgroundId,
principalTable: "Backgrounds",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Biographies_Characters_CharacterId",
column: x => x.CharacterId,
principalTable: "Characters",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Biographies_Classes_ClassId",
column: x => x.ClassId,
principalTable: "Classes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Biographies_Races_RaceId",
column: x => x.RaceId,
principalTable: "Races",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Statistics",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
CharacterId = table.Column<int>(type: "int", nullable: false),
ExperiencePoints = table.Column<int>(type: "int", nullable: false),
Level = table.Column<int>(type: "int", nullable: false),
Speed = table.Column<int>(type: "int", nullable: false),
Initiative = table.Column<int>(type: "int", nullable: false),
HealthPoints = table.Column<int>(type: "int", nullable: false),
CurrentHealthPoints = table.Column<int>(type: "int", nullable: false),
ArmorClass = table.Column<int>(type: "int", nullable: false),
Proficiency = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Statistics", x => x.Id);
table.ForeignKey(
name: "FK_Statistics_Characters_CharacterId",
column: x => x.CharacterId,
principalTable: "Characters",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.InsertData(
table: "Users",
columns: new[] { "Id", "Nickname", "Password" },
values: new object[] { 1, "Morwiec", "123" });
migrationBuilder.InsertData(
table: "Users",
columns: new[] { "Id", "Nickname", "Password" },
values: new object[] { 2, "Cichoklepiec", "123" });
migrationBuilder.InsertData(
table: "Users",
columns: new[] { "Id", "Nickname", "Password" },
values: new object[] { 3, "Ruletka", "123" });
migrationBuilder.CreateIndex(
name: "IX_Biographies_AlignmentId",
table: "Biographies",
column: "AlignmentId");
migrationBuilder.CreateIndex(
name: "IX_Biographies_BackgroundId",
table: "Biographies",
column: "BackgroundId");
migrationBuilder.CreateIndex(
name: "IX_Biographies_CharacterId",
table: "Biographies",
column: "CharacterId",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Biographies_ClassId",
table: "Biographies",
column: "ClassId");
migrationBuilder.CreateIndex(
name: "IX_Biographies_RaceId",
table: "Biographies",
column: "RaceId");
migrationBuilder.CreateIndex(
name: "IX_Characters_UserId",
table: "Characters",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_Statistics_CharacterId",
table: "Statistics",
column: "CharacterId",
unique: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Biographies");
migrationBuilder.DropTable(
name: "Statistics");
migrationBuilder.DropTable(
name: "Alignments");
migrationBuilder.DropTable(
name: "Backgrounds");
migrationBuilder.DropTable(
name: "Classes");
migrationBuilder.DropTable(
name: "Races");
migrationBuilder.DropTable(
name: "Characters");
migrationBuilder.DropTable(
name: "Users");
}
}
}