49 lines
2.0 KiB
C#
49 lines
2.0 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace BudgetApp.Storage.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class AddUpdateStatusSingleton : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "UpdateStatus",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false),
|
|
State = table.Column<int>(type: "int", nullable: false),
|
|
Created = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
Updated = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
Deleted = table.Column<DateTime>(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';");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.Sql("DROP TRIGGER IF EXISTS `TR_UpdateStatus_PreventDelete`;");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "UpdateStatus");
|
|
}
|
|
}
|
|
}
|