You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
95 lines
3.3 KiB
95 lines
3.3 KiB
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace Infrastructure.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class TrainingProgram : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.AddColumn<string>(
|
|
name: "SessionId",
|
|
table: "Exercices",
|
|
type: "TEXT",
|
|
nullable: true);
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Programs",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<string>(type: "TEXT", nullable: false),
|
|
Name = table.Column<string>(type: "TEXT", nullable: false),
|
|
WeekDuration = table.Column<int>(type: "INTEGER", nullable: false),
|
|
Description = table.Column<string>(type: "TEXT", nullable: false),
|
|
Difficulty = table.Column<string>(type: "TEXT", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Programs", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Sessions",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<string>(type: "TEXT", nullable: false),
|
|
Name = table.Column<string>(type: "TEXT", nullable: false),
|
|
Description = table.Column<string>(type: "TEXT", nullable: false),
|
|
Duration = table.Column<float>(type: "REAL", nullable: false),
|
|
ProgramId = table.Column<string>(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");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
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");
|
|
}
|
|
}
|
|
}
|