using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Infrastructure.Migrations { /// public partial class TESTTrainingProgMig : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_Exercices_Sessions_SessionId", table: "Exercices"); migrationBuilder.DropForeignKey( name: "FK_Sessions_Programs_TrainingProgramId", table: "Sessions"); migrationBuilder.DropColumn( name: "Duration", table: "Sessions"); migrationBuilder.DropColumn( name: "Description", table: "Exercices"); migrationBuilder.DropColumn( name: "Duration", table: "Exercices"); migrationBuilder.DropColumn( name: "Image", table: "Exercices"); migrationBuilder.DropColumn( name: "Name", table: "Exercices"); migrationBuilder.RenameColumn( name: "Description", table: "Programs", newName: "OwnerId"); migrationBuilder.RenameColumn( name: "Video", table: "Exercices", newName: "TemplateId"); migrationBuilder.RenameColumn( name: "NbSeries", table: "Exercices", newName: "RestingTime"); migrationBuilder.RenameColumn( name: "NbRepetitions", table: "Exercices", newName: "NbSets"); migrationBuilder.AlterColumn( name: "TrainingProgramId", table: "Sessions", type: "TEXT", nullable: false, defaultValue: "", oldClrType: typeof(string), oldType: "TEXT", oldNullable: true); migrationBuilder.AddColumn( name: "Day", table: "Sessions", type: "INTEGER", nullable: false, defaultValue: 0); migrationBuilder.AddColumn( name: "Target", table: "Sessions", type: "INTEGER", nullable: false, defaultValue: 0); migrationBuilder.AlterColumn( name: "Difficulty", table: "Programs", type: "INTEGER", nullable: false, oldClrType: typeof(string), oldType: "TEXT"); migrationBuilder.AddColumn( name: "Goal", table: "Programs", type: "INTEGER", nullable: false, defaultValue: 0); migrationBuilder.AddColumn( name: "Lang", table: "Programs", type: "INTEGER", nullable: false, defaultValue: 0); migrationBuilder.AlterColumn( name: "SessionId", table: "Exercices", type: "TEXT", nullable: false, defaultValue: "", oldClrType: typeof(string), oldType: "TEXT", oldNullable: true); migrationBuilder.AddColumn( name: "Category", table: "Exercices", type: "INTEGER", nullable: false, defaultValue: 0); migrationBuilder.AddColumn( name: "NbReps", table: "Exercices", type: "INTEGER", nullable: false, defaultValue: 0); migrationBuilder.CreateTable( name: "Exercice_template", columns: table => new { Id = table.Column(type: "TEXT", nullable: false), Name = table.Column(type: "TEXT", nullable: false), Equipment = table.Column(type: "TEXT", nullable: false), Instructions = table.Column(type: "TEXT", nullable: false), Duration = table.Column(type: "REAL", nullable: false), ImageId = table.Column(type: "TEXT", nullable: true), VideoId = table.Column(type: "TEXT", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Exercice_template", x => x.Id); }); migrationBuilder.CreateIndex( name: "IX_Exercices_TemplateId", table: "Exercices", column: "TemplateId"); migrationBuilder.AddForeignKey( name: "FK_Exercices_Exercice_template_TemplateId", table: "Exercices", column: "TemplateId", principalTable: "Exercice_template", principalColumn: "Id", onDelete: ReferentialAction.Cascade); migrationBuilder.AddForeignKey( name: "FK_Exercices_Sessions_SessionId", table: "Exercices", column: "SessionId", principalTable: "Sessions", principalColumn: "Id", onDelete: ReferentialAction.Cascade); migrationBuilder.AddForeignKey( name: "FK_Sessions_Programs_TrainingProgramId", table: "Sessions", column: "TrainingProgramId", principalTable: "Programs", principalColumn: "Id", onDelete: ReferentialAction.Cascade); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_Exercices_Exercice_template_TemplateId", table: "Exercices"); migrationBuilder.DropForeignKey( name: "FK_Exercices_Sessions_SessionId", table: "Exercices"); migrationBuilder.DropForeignKey( name: "FK_Sessions_Programs_TrainingProgramId", table: "Sessions"); migrationBuilder.DropTable( name: "Exercice_template"); migrationBuilder.DropIndex( name: "IX_Exercices_TemplateId", table: "Exercices"); migrationBuilder.DropColumn( name: "Day", table: "Sessions"); migrationBuilder.DropColumn( name: "Target", table: "Sessions"); migrationBuilder.DropColumn( name: "Goal", table: "Programs"); migrationBuilder.DropColumn( name: "Lang", table: "Programs"); migrationBuilder.DropColumn( name: "Category", table: "Exercices"); migrationBuilder.DropColumn( name: "NbReps", table: "Exercices"); migrationBuilder.RenameColumn( name: "OwnerId", table: "Programs", newName: "Description"); migrationBuilder.RenameColumn( name: "TemplateId", table: "Exercices", newName: "Video"); migrationBuilder.RenameColumn( name: "RestingTime", table: "Exercices", newName: "NbSeries"); migrationBuilder.RenameColumn( name: "NbSets", table: "Exercices", newName: "NbRepetitions"); migrationBuilder.AlterColumn( name: "TrainingProgramId", table: "Sessions", type: "TEXT", nullable: true, oldClrType: typeof(string), oldType: "TEXT"); migrationBuilder.AddColumn( name: "Duration", table: "Sessions", type: "REAL", nullable: false, defaultValue: 0f); migrationBuilder.AlterColumn( name: "Difficulty", table: "Programs", type: "TEXT", nullable: false, oldClrType: typeof(int), oldType: "INTEGER"); migrationBuilder.AlterColumn( name: "SessionId", table: "Exercices", type: "TEXT", nullable: true, oldClrType: typeof(string), oldType: "TEXT"); migrationBuilder.AddColumn( name: "Description", table: "Exercices", type: "TEXT", nullable: false, defaultValue: ""); migrationBuilder.AddColumn( name: "Duration", table: "Exercices", type: "REAL", nullable: false, defaultValue: 0f); migrationBuilder.AddColumn( name: "Image", table: "Exercices", type: "TEXT", nullable: false, defaultValue: ""); migrationBuilder.AddColumn( name: "Name", table: "Exercices", type: "TEXT", nullable: false, defaultValue: ""); migrationBuilder.AddForeignKey( name: "FK_Exercices_Sessions_SessionId", table: "Exercices", column: "SessionId", principalTable: "Sessions", principalColumn: "Id"); migrationBuilder.AddForeignKey( name: "FK_Sessions_Programs_TrainingProgramId", table: "Sessions", column: "TrainingProgramId", principalTable: "Programs", principalColumn: "Id"); } } }