|
|
|
@ -0,0 +1,236 @@
|
|
|
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
|
|
|
|
|
|
#nullable disable
|
|
|
|
|
|
|
|
|
|
namespace DbConnectionLibrairie.Migrations
|
|
|
|
|
{
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
public partial class m1 : Migration
|
|
|
|
|
{
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
|
|
|
{
|
|
|
|
|
migrationBuilder.CreateTable(
|
|
|
|
|
name: "Administrators",
|
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
Id = table.Column<uint>(type: "INTEGER", nullable: false)
|
|
|
|
|
.Annotation("Sqlite:Autoincrement", true),
|
|
|
|
|
Username = table.Column<string>(type: "TEXT", nullable: false),
|
|
|
|
|
HashedPassword = table.Column<string>(type: "TEXT", nullable: false)
|
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
|
|
|
|
table.PrimaryKey("PK_Administrators", x => x.Id);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable(
|
|
|
|
|
name: "Chapters",
|
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
Id = table.Column<uint>(type: "INTEGER", nullable: false)
|
|
|
|
|
.Annotation("Sqlite:Autoincrement", true),
|
|
|
|
|
Name = table.Column<string>(type: "TEXT", nullable: false)
|
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
|
|
|
|
table.PrimaryKey("PK_Chapters", x => x.Id);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable(
|
|
|
|
|
name: "Players",
|
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
Id = table.Column<uint>(type: "INTEGER", nullable: false)
|
|
|
|
|
.Annotation("Sqlite:Autoincrement", true),
|
|
|
|
|
Nickname = table.Column<string>(type: "TEXT", nullable: false),
|
|
|
|
|
HashedPassword = table.Column<string>(type: "TEXT", nullable: false)
|
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
|
|
|
|
table.PrimaryKey("PK_Players", x => x.Id);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable(
|
|
|
|
|
name: "Lobbies",
|
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
Id = table.Column<uint>(type: "INTEGER", nullable: false)
|
|
|
|
|
.Annotation("Sqlite:Autoincrement", true),
|
|
|
|
|
Name = table.Column<string>(type: "TEXT", nullable: false),
|
|
|
|
|
Password = table.Column<string>(type: "TEXT", nullable: false),
|
|
|
|
|
NbPlayers = table.Column<uint>(type: "INTEGER", nullable: false),
|
|
|
|
|
IdCreator = table.Column<uint>(type: "INTEGER", nullable: true)
|
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
|
|
|
|
table.PrimaryKey("PK_Lobbies", x => x.Id);
|
|
|
|
|
table.ForeignKey(
|
|
|
|
|
name: "FK_Lobbies_Players_IdCreator",
|
|
|
|
|
column: x => x.IdCreator,
|
|
|
|
|
principalTable: "Players",
|
|
|
|
|
principalColumn: "Id");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable(
|
|
|
|
|
name: "Play",
|
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
IdChapter = table.Column<uint>(type: "INTEGER", nullable: false),
|
|
|
|
|
IdPlayer = table.Column<uint>(type: "INTEGER", nullable: false),
|
|
|
|
|
MaxScore = table.Column<uint>(type: "INTEGER", nullable: false)
|
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
|
|
|
|
table.PrimaryKey("PK_Play", x => new { x.IdPlayer, x.IdChapter });
|
|
|
|
|
table.ForeignKey(
|
|
|
|
|
name: "FK_Play_Chapters_IdChapter",
|
|
|
|
|
column: x => x.IdChapter,
|
|
|
|
|
principalTable: "Chapters",
|
|
|
|
|
principalColumn: "Id",
|
|
|
|
|
onDelete: ReferentialAction.Cascade);
|
|
|
|
|
table.ForeignKey(
|
|
|
|
|
name: "FK_Play_Players_IdPlayer",
|
|
|
|
|
column: x => x.IdPlayer,
|
|
|
|
|
principalTable: "Players",
|
|
|
|
|
principalColumn: "Id",
|
|
|
|
|
onDelete: ReferentialAction.Cascade);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable(
|
|
|
|
|
name: "Use",
|
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
IdLobby = table.Column<uint>(type: "INTEGER", nullable: false),
|
|
|
|
|
IdPlayer = table.Column<uint>(type: "INTEGER", nullable: false),
|
|
|
|
|
MaxScore = table.Column<uint>(type: "INTEGER", nullable: false)
|
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
|
|
|
|
table.PrimaryKey("PK_Use", x => new { x.IdLobby, x.IdPlayer });
|
|
|
|
|
table.ForeignKey(
|
|
|
|
|
name: "FK_Use_Lobbies_IdLobby",
|
|
|
|
|
column: x => x.IdLobby,
|
|
|
|
|
principalTable: "Lobbies",
|
|
|
|
|
principalColumn: "Id",
|
|
|
|
|
onDelete: ReferentialAction.Cascade);
|
|
|
|
|
table.ForeignKey(
|
|
|
|
|
name: "FK_Use_Players_IdPlayer",
|
|
|
|
|
column: x => x.IdPlayer,
|
|
|
|
|
principalTable: "Players",
|
|
|
|
|
principalColumn: "Id",
|
|
|
|
|
onDelete: ReferentialAction.Cascade);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable(
|
|
|
|
|
name: "Answers",
|
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
Id = table.Column<uint>(type: "INTEGER", nullable: false)
|
|
|
|
|
.Annotation("Sqlite:Autoincrement", true),
|
|
|
|
|
Content = table.Column<string>(type: "TEXT", nullable: false),
|
|
|
|
|
IdQuestion = table.Column<uint>(type: "INTEGER", nullable: true)
|
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
|
|
|
|
table.PrimaryKey("PK_Answers", x => x.Id);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable(
|
|
|
|
|
name: "Questions",
|
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
Id = table.Column<uint>(type: "INTEGER", nullable: false)
|
|
|
|
|
.Annotation("Sqlite:Autoincrement", true),
|
|
|
|
|
Content = table.Column<string>(type: "TEXT", nullable: false),
|
|
|
|
|
Difficulty = table.Column<byte>(type: "INTEGER", nullable: false),
|
|
|
|
|
NbFalls = table.Column<uint>(type: "INTEGER", nullable: false),
|
|
|
|
|
IdChapter = table.Column<uint>(type: "INTEGER", nullable: true),
|
|
|
|
|
IdAnswerGood = table.Column<uint>(type: "INTEGER", nullable: true)
|
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
|
|
|
|
table.PrimaryKey("PK_Questions", x => x.Id);
|
|
|
|
|
table.ForeignKey(
|
|
|
|
|
name: "FK_Questions_Answers_IdAnswerGood",
|
|
|
|
|
column: x => x.IdAnswerGood,
|
|
|
|
|
principalTable: "Answers",
|
|
|
|
|
principalColumn: "Id");
|
|
|
|
|
table.ForeignKey(
|
|
|
|
|
name: "FK_Questions_Chapters_IdChapter",
|
|
|
|
|
column: x => x.IdChapter,
|
|
|
|
|
principalTable: "Chapters",
|
|
|
|
|
principalColumn: "Id");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_Answers_IdQuestion",
|
|
|
|
|
table: "Answers",
|
|
|
|
|
column: "IdQuestion");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_Lobbies_IdCreator",
|
|
|
|
|
table: "Lobbies",
|
|
|
|
|
column: "IdCreator");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_Play_IdChapter",
|
|
|
|
|
table: "Play",
|
|
|
|
|
column: "IdChapter");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_Questions_IdAnswerGood",
|
|
|
|
|
table: "Questions",
|
|
|
|
|
column: "IdAnswerGood");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_Questions_IdChapter",
|
|
|
|
|
table: "Questions",
|
|
|
|
|
column: "IdChapter");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_Use_IdPlayer",
|
|
|
|
|
table: "Use",
|
|
|
|
|
column: "IdPlayer");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
|
|
|
name: "FK_Answers_Questions_IdQuestion",
|
|
|
|
|
table: "Answers",
|
|
|
|
|
column: "IdQuestion",
|
|
|
|
|
principalTable: "Questions",
|
|
|
|
|
principalColumn: "Id");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
|
|
|
{
|
|
|
|
|
migrationBuilder.DropForeignKey(
|
|
|
|
|
name: "FK_Answers_Questions_IdQuestion",
|
|
|
|
|
table: "Answers");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "Administrators");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "Play");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "Use");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "Lobbies");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "Players");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "Questions");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "Answers");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable(
|
|
|
|
|
name: "Chapters");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|