You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
197 lines
7.8 KiB
197 lines
7.8 KiB
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace EntityFrameWorkLib.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class MyMigration : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "Grille",
|
|
columns: table => new
|
|
{
|
|
GrilleId = table.Column<int>(type: "INTEGER", nullable: false)
|
|
.Annotation("Sqlite:Autoincrement", true),
|
|
NbChains = table.Column<int>(type: "INTEGER", nullable: false),
|
|
NbZones = table.Column<int>(type: "INTEGER", nullable: false),
|
|
MaxChain = table.Column<int>(type: "INTEGER", nullable: false),
|
|
MaxZone = table.Column<int>(type: "INTEGER", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Grille", x => x.GrilleId);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Players",
|
|
columns: table => new
|
|
{
|
|
PlayerId = table.Column<int>(type: "INTEGER", nullable: false)
|
|
.Annotation("Sqlite:Autoincrement", true),
|
|
Pseudo = table.Column<string>(type: "TEXT", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Players", x => x.PlayerId);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Turn",
|
|
columns: table => new
|
|
{
|
|
TurnId = table.Column<int>(type: "INTEGER", nullable: false)
|
|
.Annotation("Sqlite:Autoincrement", true),
|
|
DiceValue1 = table.Column<int>(type: "INTEGER", nullable: false),
|
|
DiceValue2 = table.Column<int>(type: "INTEGER", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Turn", x => x.TurnId);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Case",
|
|
columns: table => new
|
|
{
|
|
CaseId = table.Column<int>(type: "INTEGER", nullable: false)
|
|
.Annotation("Sqlite:Autoincrement", true),
|
|
GrilleId = table.Column<int>(type: "INTEGER", nullable: false),
|
|
Value = table.Column<int>(type: "INTEGER", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Case", x => x.CaseId);
|
|
table.ForeignKey(
|
|
name: "FK_Case_Grille_GrilleId",
|
|
column: x => x.GrilleId,
|
|
principalTable: "Grille",
|
|
principalColumn: "GrilleId",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Game",
|
|
columns: table => new
|
|
{
|
|
GameId = table.Column<int>(type: "INTEGER", nullable: false)
|
|
.Annotation("Sqlite:Autoincrement", true),
|
|
Duration = table.Column<TimeSpan>(type: "TEXT", nullable: false),
|
|
Date = table.Column<DateOnly>(type: "TEXT", nullable: false),
|
|
NbPlayers = table.Column<int>(type: "INTEGER", nullable: false),
|
|
PlayerId = table.Column<int>(type: "INTEGER", nullable: false),
|
|
Name = table.Column<string>(type: "TEXT", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Game", x => x.GameId);
|
|
table.ForeignKey(
|
|
name: "FK_Game_Players_PlayerId",
|
|
column: x => x.PlayerId,
|
|
principalTable: "Players",
|
|
principalColumn: "PlayerId",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Stats",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
|
.Annotation("Sqlite:Autoincrement", true),
|
|
NbWin = table.Column<int>(type: "INTEGER", nullable: false),
|
|
NbPlayed = table.Column<int>(type: "INTEGER", nullable: false),
|
|
MaxChain = table.Column<int>(type: "INTEGER", nullable: false),
|
|
MaxZone = table.Column<int>(type: "INTEGER", nullable: false),
|
|
MaxPoints = table.Column<int>(type: "INTEGER", nullable: false),
|
|
PlayerId = table.Column<int>(type: "INTEGER", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Stats", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Stats_Players_PlayerId",
|
|
column: x => x.PlayerId,
|
|
principalTable: "Players",
|
|
principalColumn: "PlayerId",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Score",
|
|
columns: table => new
|
|
{
|
|
GameId = table.Column<int>(type: "INTEGER", nullable: false),
|
|
PlayerId = table.Column<int>(type: "INTEGER", nullable: false),
|
|
NbPointsTotal = table.Column<int>(type: "INTEGER", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Score", x => new { x.GameId, x.PlayerId });
|
|
table.ForeignKey(
|
|
name: "FK_Score_Game_GameId",
|
|
column: x => x.GameId,
|
|
principalTable: "Game",
|
|
principalColumn: "GameId",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_Score_Players_PlayerId",
|
|
column: x => x.PlayerId,
|
|
principalTable: "Players",
|
|
principalColumn: "PlayerId",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Case_GrilleId",
|
|
table: "Case",
|
|
column: "GrilleId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Game_PlayerId",
|
|
table: "Game",
|
|
column: "PlayerId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Score_PlayerId",
|
|
table: "Score",
|
|
column: "PlayerId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Stats_PlayerId",
|
|
table: "Stats",
|
|
column: "PlayerId",
|
|
unique: true);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "Case");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Score");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Stats");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Turn");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Grille");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Game");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Players");
|
|
}
|
|
}
|
|
}
|