feat: 使用 PostgreSQL xmin 系统列作为并发控制
All checks were successful
Build and Deploy AdminApi / build-and-deploy (push) Successful in 38s
All checks were successful
Build and Deploy AdminApi / build-and-deploy (push) Successful in 38s
This commit is contained in:
@@ -79,7 +79,7 @@ public sealed class IdentityUser : AuditableEntityBase
|
||||
public string? Avatar { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 并发控制字段(映射到 PostgreSQL xmin)。
|
||||
/// 并发控制字段(映射到 PostgreSQL xmin 系统列)。
|
||||
/// </summary>
|
||||
public uint RowVersion { get; set; }
|
||||
}
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace TakeoutSaaS.Infrastructure.Migrations.IdentityDb
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class SyncIdentityModel : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "RowVersion",
|
||||
table: "identity_users",
|
||||
newName: "xmin");
|
||||
|
||||
migrationBuilder.AlterColumn<uint>(
|
||||
name: "xmin",
|
||||
table: "identity_users",
|
||||
type: "xid",
|
||||
rowVersion: true,
|
||||
nullable: false,
|
||||
comment: "并发控制字段(映射到 PostgreSQL xmin)。",
|
||||
oldClrType: typeof(byte[]),
|
||||
oldType: "bytea",
|
||||
oldRowVersion: true,
|
||||
oldComment: "并发控制字段。");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "xmin",
|
||||
table: "identity_users",
|
||||
newName: "RowVersion");
|
||||
|
||||
migrationBuilder.AlterColumn<byte[]>(
|
||||
name: "RowVersion",
|
||||
table: "identity_users",
|
||||
type: "bytea",
|
||||
rowVersion: true,
|
||||
nullable: false,
|
||||
comment: "并发控制字段。",
|
||||
oldClrType: typeof(uint),
|
||||
oldType: "xid",
|
||||
oldRowVersion: true,
|
||||
oldComment: "并发控制字段(映射到 PostgreSQL xmin)。");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,8 +12,8 @@ using TakeoutSaaS.Infrastructure.Identity.Persistence;
|
||||
namespace TakeoutSaaS.Infrastructure.Migrations.IdentityDb
|
||||
{
|
||||
[DbContext(typeof(IdentityDbContext))]
|
||||
[Migration("20260205131209_SyncIdentityModel")]
|
||||
partial class SyncIdentityModel
|
||||
[Migration("20260205131953_UseXminConcurrency")]
|
||||
partial class UseXminConcurrency
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
@@ -275,7 +275,7 @@ namespace TakeoutSaaS.Infrastructure.Migrations.IdentityDb
|
||||
.ValueGeneratedOnAddOrUpdate()
|
||||
.HasColumnType("xid")
|
||||
.HasColumnName("xmin")
|
||||
.HasComment("并发控制字段(映射到 PostgreSQL xmin)。");
|
||||
.HasComment("并发控制字段(映射到 PostgreSQL xmin 系统列)。");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("integer")
|
||||
@@ -0,0 +1,32 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace TakeoutSaaS.Infrastructure.Migrations.IdentityDb
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class UseXminConcurrency : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
// 删除旧的 RowVersion 列,改用 PostgreSQL 原生 xmin 系统列
|
||||
migrationBuilder.DropColumn(
|
||||
name: "RowVersion",
|
||||
table: "identity_users");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
// 恢复 RowVersion 列
|
||||
migrationBuilder.AddColumn<byte[]>(
|
||||
name: "RowVersion",
|
||||
table: "identity_users",
|
||||
type: "bytea",
|
||||
rowVersion: true,
|
||||
nullable: false,
|
||||
defaultValue: new byte[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -272,7 +272,7 @@ namespace TakeoutSaaS.Infrastructure.Migrations.IdentityDb
|
||||
.ValueGeneratedOnAddOrUpdate()
|
||||
.HasColumnType("xid")
|
||||
.HasColumnName("xmin")
|
||||
.HasComment("并发控制字段(映射到 PostgreSQL xmin)。");
|
||||
.HasComment("并发控制字段(映射到 PostgreSQL xmin 系统列)。");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("integer")
|
||||
|
||||
Reference in New Issue
Block a user