feat(dashboard): add owner-scoped layouts with atomic revisions

This commit is contained in:
cesnimda
2026-10-21 20:59:58 +02:00
parent 421f902d21
commit 5edbe59692
11 changed files with 539 additions and 0 deletions
@@ -0,0 +1,32 @@
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");
}
}
@@ -485,6 +485,16 @@ namespace JobTrackerApi.Migrations
.HasMaxLength(16)
.HasColumnType("TEXT");
b.Property<string>("DashboardLayoutJson")
.HasColumnType("TEXT")
.Metadata.SetAfterSaveBehavior(Microsoft.EntityFrameworkCore.Metadata.PropertySaveBehavior.Ignore);
b.Property<long>("DashboardLayoutRevision")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasDefaultValue(0L)
.Metadata.SetAfterSaveBehavior(Microsoft.EntityFrameworkCore.Metadata.PropertySaveBehavior.Ignore);
b.Property<DateTimeOffset?>("TotpEnabledAtUtc")
.HasColumnType("TEXT");