using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace EntityFrameWorkLib.Migrations { /// public partial class MyMigration : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Grille", columns: table => new { GrilleId = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), NbChains = table.Column(type: "INTEGER", nullable: false), NbZones = table.Column(type: "INTEGER", nullable: false), MaxChain = table.Column(type: "INTEGER", nullable: false), MaxZone = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Grille", x => x.GrilleId); }); migrationBuilder.CreateTable( name: "Players", columns: table => new { PlayerId = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Pseudo = table.Column(type: "TEXT", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Players", x => x.PlayerId); }); migrationBuilder.CreateTable( name: "Turn", columns: table => new { TurnId = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), DiceValue1 = table.Column(type: "INTEGER", nullable: false), DiceValue2 = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Turn", x => x.TurnId); }); migrationBuilder.CreateTable( name: "Case", columns: table => new { CaseId = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), GrilleId = table.Column(type: "INTEGER", nullable: false), Value = table.Column(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(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Duration = table.Column(type: "TEXT", nullable: false), Date = table.Column(type: "TEXT", nullable: false), NbPlayers = table.Column(type: "INTEGER", nullable: false), PlayerId = table.Column(type: "INTEGER", nullable: false), Name = table.Column(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(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), NbWin = table.Column(type: "INTEGER", nullable: false), NbPlayed = table.Column(type: "INTEGER", nullable: false), MaxChain = table.Column(type: "INTEGER", nullable: false), MaxZone = table.Column(type: "INTEGER", nullable: false), MaxPoints = table.Column(type: "INTEGER", nullable: false), PlayerId = table.Column(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(type: "INTEGER", nullable: false), PlayerId = table.Column(type: "INTEGER", nullable: false), NbPointsTotal = table.Column(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); } /// 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"); } } }