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.
Dotnet-WebAPI/AppContext/Migrations/20240218173232_m1.cs

158 lines
6.6 KiB

using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace AppContext.Migrations
{
/// <inheritdoc />
public partial class m1 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Teams",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", nullable: false),
Picture = table.Column<string>(type: "TEXT", nullable: false),
MainColor = table.Column<string>(type: "TEXT", nullable: false),
SecondColor = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Teams", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Users",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Password = table.Column<string>(type: "TEXT", nullable: false),
Salt = table.Column<byte[]>(type: "BLOB", nullable: false),
Name = table.Column<string>(type: "TEXT", nullable: false),
Email = table.Column<string>(type: "TEXT", nullable: false),
ProfilePicture = table.Column<string>(type: "TEXT", nullable: false),
IsAdmin = table.Column<bool>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Users", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Members",
columns: table => new
{
TeamId = table.Column<int>(type: "INTEGER", nullable: false),
UserId = table.Column<int>(type: "INTEGER", nullable: false),
Role = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Members", x => new { x.UserId, x.TeamId });
table.ForeignKey(
name: "FK_Members_Teams_TeamId",
column: x => x.TeamId,
principalTable: "Teams",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Members_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Tactics",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", nullable: false),
CreationDate = table.Column<DateTime>(type: "TEXT", nullable: false),
OwnerId = table.Column<int>(type: "INTEGER", nullable: false),
Type = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Tactics", x => x.Id);
table.ForeignKey(
name: "FK_Tactics_Users_OwnerId",
column: x => x.OwnerId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "TacticSteps",
columns: table => new
{
TacticId = table.Column<int>(type: "INTEGER", nullable: false),
StepId = table.Column<int>(type: "INTEGER", nullable: false),
ParentId = table.Column<int>(type: "INTEGER", nullable: true),
ParentTacticId = table.Column<int>(type: "INTEGER", nullable: true),
ParentStepId = table.Column<int>(type: "INTEGER", nullable: true),
JsonContent = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_TacticSteps", x => new { x.TacticId, x.StepId });
table.ForeignKey(
name: "FK_TacticSteps_TacticSteps_ParentTacticId_ParentStepId",
columns: x => new { x.ParentTacticId, x.ParentStepId },
principalTable: "TacticSteps",
principalColumns: new[] { "TacticId", "StepId" });
table.ForeignKey(
name: "FK_TacticSteps_Tactics_TacticId",
column: x => x.TacticId,
principalTable: "Tactics",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Members_TeamId",
table: "Members",
column: "TeamId");
migrationBuilder.CreateIndex(
name: "IX_Tactics_OwnerId",
table: "Tactics",
column: "OwnerId");
migrationBuilder.CreateIndex(
name: "IX_TacticSteps_ParentTacticId_ParentStepId",
table: "TacticSteps",
columns: new[] { "ParentTacticId", "ParentStepId" });
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Members");
migrationBuilder.DropTable(
name: "TacticSteps");
migrationBuilder.DropTable(
name: "Teams");
migrationBuilder.DropTable(
name: "Tactics");
migrationBuilder.DropTable(
name: "Users");
}
}
}