using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace BudgetApp.Storage.Migrations { /// public partial class AddUpdateStatusSingleton : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "UpdateStatus", columns: table => new { Id = table.Column(type: "int", nullable: false), State = table.Column(type: "int", nullable: false), Created = table.Column(type: "datetime(6)", nullable: false), Updated = table.Column(type: "datetime(6)", nullable: false), Deleted = table.Column(type: "datetime(6)", nullable: true) }, constraints: table => { table.PrimaryKey("PK_UpdateStatus", x => x.Id); table.CheckConstraint("CK_UpdateStatus_SingletonId", "`Id` = 1"); }); migrationBuilder.InsertData( table: "UpdateStatus", columns: new[] { "Id", "Created", "Deleted", "State", "Updated" }, values: new object[] { 1, new DateTime(2026, 1, 1, 0, 0, 0, DateTimeKind.Utc), null, 1, new DateTime(2026, 1, 1, 0, 0, 0, DateTimeKind.Utc) }); migrationBuilder.Sql( "CREATE TRIGGER `TR_UpdateStatus_PreventDelete` BEFORE DELETE ON `UpdateStatus` FOR EACH ROW SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'UpdateStatus row cannot be deleted';"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.Sql("DROP TRIGGER IF EXISTS `TR_UpdateStatus_PreventDelete`;"); migrationBuilder.DropTable( name: "UpdateStatus"); } } }