using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace CalendarReminder.Api.Migrations { /// public partial class AddFamilyAndAdminFields : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AddColumn( name: "FamilyId", table: "Users", type: "int", nullable: true); migrationBuilder.AddColumn( name: "IsAdmin", table: "Users", type: "tinyint(1)", nullable: false, defaultValue: false); migrationBuilder.AddColumn( name: "MustChangePassword", table: "Users", type: "tinyint(1)", nullable: false, defaultValue: false); migrationBuilder.CreateTable( name: "Families", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), Name = table.Column(type: "varchar(100)", maxLength: 100, nullable: false) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { table.PrimaryKey("PK_Families", x => x.Id); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateIndex( name: "IX_Users_FamilyId", table: "Users", column: "FamilyId"); migrationBuilder.CreateIndex( name: "IX_Families_Name", table: "Families", column: "Name", unique: true); migrationBuilder.AddForeignKey( name: "FK_Users_Families_FamilyId", table: "Users", column: "FamilyId", principalTable: "Families", principalColumn: "Id", onDelete: ReferentialAction.SetNull); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_Users_Families_FamilyId", table: "Users"); migrationBuilder.DropTable( name: "Families"); migrationBuilder.DropIndex( name: "IX_Users_FamilyId", table: "Users"); migrationBuilder.DropColumn( name: "FamilyId", table: "Users"); migrationBuilder.DropColumn( name: "IsAdmin", table: "Users"); migrationBuilder.DropColumn( name: "MustChangePassword", table: "Users"); } } }