using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Entity_Framework.Migrations { /// public partial class test : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Circuits", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Name = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Circuits", x => x.Id); }); migrationBuilder.CreateTable( name: "Ecuries", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Name = table.Column(type: "TEXT", nullable: false), IdPiloteProprietaire = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Ecuries", x => x.Id); }); migrationBuilder.CreateTable( name: "Pilotes", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Pseudo = table.Column(type: "TEXT", nullable: false), Email = table.Column(type: "TEXT", nullable: false), Password = table.Column(type: "TEXT", nullable: false), IdEcurie = table.Column(type: "INTEGER", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Pilotes", x => x.Id); table.ForeignKey( name: "FK_Pilotes_Ecuries_IdEcurie", column: x => x.IdEcurie, principalTable: "Ecuries", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "Images", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Base64 = table.Column(type: "TEXT", nullable: false), IdPilote = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Images", x => x.Id); table.ForeignKey( name: "FK_Images_Pilotes_IdPilote", column: x => x.IdPilote, principalTable: "Pilotes", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Sessions", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Name = table.Column(type: "TEXT", nullable: false), Type = table.Column(type: "TEXT", nullable: false), Date = table.Column(type: "TEXT", nullable: false), IdCircuit = table.Column(type: "INTEGER", nullable: false), IdPilote = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Sessions", x => x.Id); table.ForeignKey( name: "FK_Sessions_Circuits_IdCircuit", column: x => x.IdCircuit, principalTable: "Circuits", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Sessions_Pilotes_IdPilote", column: x => x.IdPilote, principalTable: "Pilotes", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Tours", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Temps = table.Column(type: "TEXT", nullable: false), Numero = table.Column(type: "INTEGER", nullable: false), IdSession = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Tours", x => x.Id); table.ForeignKey( name: "FK_Tours_Sessions_IdSession", column: x => x.IdSession, principalTable: "Sessions", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Points", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Timer = table.Column(type: "REAL", nullable: false), Latitude = table.Column(type: "REAL", nullable: false), Longitude = table.Column(type: "REAL", nullable: false), Distance = table.Column(type: "REAL", nullable: false), P_BreakF = table.Column(type: "REAL", nullable: false), NGearASCII = table.Column(type: "REAL", nullable: false), A_Steer = table.Column(type: "REAL", nullable: false), R_Pedal = table.Column(type: "REAL", nullable: false), G_Lon = table.Column(type: "REAL", nullable: false), G_Lat = table.Column(type: "REAL", nullable: false), V_Car = table.Column(type: "REAL", nullable: false), IdTours = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Points", x => x.Id); table.ForeignKey( name: "FK_Points_Tours_IdTours", column: x => x.IdTours, principalTable: "Tours", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.InsertData( table: "Circuits", columns: new[] { "Id", "Name" }, values: new object[] { 1, "test_CIRCUIT" }); migrationBuilder.InsertData( table: "Pilotes", columns: new[] { "Id", "Email", "IdEcurie", "Password", "Pseudo" }, values: new object[] { 1, "test@gmail.com", null, "7NcYcNGWMxapfjrDQIyYNa2M8PPBvHA1J8MCZVNPda4=", "test_PILOTE" }); migrationBuilder.CreateIndex( name: "IX_Circuits_Name", table: "Circuits", column: "Name", unique: true); migrationBuilder.CreateIndex( name: "IX_Ecuries_IdPiloteProprietaire", table: "Ecuries", column: "IdPiloteProprietaire", unique: true); migrationBuilder.CreateIndex( name: "IX_Ecuries_Name", table: "Ecuries", column: "Name", unique: true); migrationBuilder.CreateIndex( name: "IX_Images_IdPilote", table: "Images", column: "IdPilote", unique: true); migrationBuilder.CreateIndex( name: "IX_Pilotes_Email", table: "Pilotes", column: "Email", unique: true); migrationBuilder.CreateIndex( name: "IX_Pilotes_IdEcurie", table: "Pilotes", column: "IdEcurie"); migrationBuilder.CreateIndex( name: "IX_Pilotes_Pseudo", table: "Pilotes", column: "Pseudo", unique: true); migrationBuilder.CreateIndex( name: "IX_Points_IdTours", table: "Points", column: "IdTours"); migrationBuilder.CreateIndex( name: "IX_Sessions_IdCircuit", table: "Sessions", column: "IdCircuit"); migrationBuilder.CreateIndex( name: "IX_Sessions_IdPilote", table: "Sessions", column: "IdPilote"); migrationBuilder.CreateIndex( name: "IX_Tours_IdSession", table: "Tours", column: "IdSession"); migrationBuilder.AddForeignKey( name: "FK_Ecuries_Pilotes_IdPiloteProprietaire", table: "Ecuries", column: "IdPiloteProprietaire", principalTable: "Pilotes", principalColumn: "Id", onDelete: ReferentialAction.Cascade); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_Ecuries_Pilotes_IdPiloteProprietaire", table: "Ecuries"); migrationBuilder.DropTable( name: "Images"); migrationBuilder.DropTable( name: "Points"); migrationBuilder.DropTable( name: "Tours"); migrationBuilder.DropTable( name: "Sessions"); migrationBuilder.DropTable( name: "Circuits"); migrationBuilder.DropTable( name: "Pilotes"); migrationBuilder.DropTable( name: "Ecuries"); } } }