Files
jobtrackingapp/JobTrackerApi/Migrations/20261021090000_AddDashboardLayoutPreference.cs
T

33 lines
1.5 KiB
C#

using JobTrackerApi.Data;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace JobTrackerApi.Migrations;
[DbContext(typeof(JobTrackerContext))]
[Migration("20261021090000_AddDashboardLayoutPreference")]
public partial class AddDashboardLayoutPreference : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
var mysql = ActiveProvider.Contains("MySql", StringComparison.OrdinalIgnoreCase);
migrationBuilder.AddColumn<string>(name: "DashboardLayoutJson", table: "AspNetUsers", type: mysql ? "longtext" : "TEXT", nullable: true);
migrationBuilder.AddColumn<long>(name: "DashboardLayoutRevision", table: "AspNetUsers", type: mysql ? "bigint" : "INTEGER", nullable: false, defaultValue: 0L);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
if (ActiveProvider.Contains("Sqlite", StringComparison.OrdinalIgnoreCase))
{
// These independent columns need no table rebuild (SQLite 3.35+ supports DROP COLUMN).
migrationBuilder.Sql("ALTER TABLE \"AspNetUsers\" DROP COLUMN \"DashboardLayoutJson\";");
migrationBuilder.Sql("ALTER TABLE \"AspNetUsers\" DROP COLUMN \"DashboardLayoutRevision\";");
return;
}
migrationBuilder.DropColumn(name: "DashboardLayoutJson", table: "AspNetUsers");
migrationBuilder.DropColumn(name: "DashboardLayoutRevision", table: "AspNetUsers");
}
}