using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace AppContext.Migrations { /// public partial class m1 : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Teams", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Name = table.Column(type: "TEXT", nullable: false), Picture = table.Column(type: "TEXT", nullable: false), MainColor = table.Column(type: "TEXT", nullable: false), SecondColor = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Teams", x => x.Id); }); migrationBuilder.CreateTable( name: "Users", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Password = table.Column(type: "TEXT", nullable: false), Salt = table.Column(type: "BLOB", nullable: false), Name = table.Column(type: "TEXT", nullable: false), Email = table.Column(type: "TEXT", nullable: false), ProfilePicture = table.Column(type: "TEXT", nullable: false), IsAdmin = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Users", x => x.Id); }); migrationBuilder.CreateTable( name: "Members", columns: table => new { TeamId = table.Column(type: "INTEGER", nullable: false), UserId = table.Column(type: "INTEGER", nullable: false), Role = table.Column(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(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Name = table.Column(type: "TEXT", nullable: false), CreationDate = table.Column(type: "TEXT", nullable: false), OwnerId = table.Column(type: "INTEGER", nullable: false), Type = table.Column(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(type: "INTEGER", nullable: false), StepId = table.Column(type: "INTEGER", nullable: false), ParentId = table.Column(type: "INTEGER", nullable: true), ParentTacticId = table.Column(type: "INTEGER", nullable: true), ParentStepId = table.Column(type: "INTEGER", nullable: true), JsonContent = table.Column(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" }); } /// 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"); } } }