using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Infrastructure.Migrations { /// public partial class TrainingProgram : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AddColumn( name: "SessionId", table: "Exercices", type: "TEXT", nullable: true); migrationBuilder.CreateTable( name: "Programs", columns: table => new { Id = table.Column(type: "TEXT", nullable: false), Name = table.Column(type: "TEXT", nullable: false), WeekDuration = table.Column(type: "INTEGER", nullable: false), Description = table.Column(type: "TEXT", nullable: false), Difficulty = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Programs", x => x.Id); }); migrationBuilder.CreateTable( name: "Sessions", columns: table => new { Id = table.Column(type: "TEXT", nullable: false), Name = table.Column(type: "TEXT", nullable: false), Description = table.Column(type: "TEXT", nullable: false), Duration = table.Column(type: "REAL", nullable: false), ProgramId = table.Column(type: "TEXT", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Sessions", x => x.Id); table.ForeignKey( name: "FK_Sessions_Programs_ProgramId", column: x => x.ProgramId, principalTable: "Programs", principalColumn: "Id"); }); migrationBuilder.CreateIndex( name: "IX_Exercices_SessionId", table: "Exercices", column: "SessionId"); migrationBuilder.CreateIndex( name: "IX_Sessions_ProgramId", table: "Sessions", column: "ProgramId"); migrationBuilder.AddForeignKey( name: "FK_Exercices_Sessions_SessionId", table: "Exercices", column: "SessionId", principalTable: "Sessions", principalColumn: "Id"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_Exercices_Sessions_SessionId", table: "Exercices"); migrationBuilder.DropTable( name: "Sessions"); migrationBuilder.DropTable( name: "Programs"); migrationBuilder.DropIndex( name: "IX_Exercices_SessionId", table: "Exercices"); migrationBuilder.DropColumn( name: "SessionId", table: "Exercices"); } } }