Skip to content

Commit bc6f1bf

Browse files
committed
fix(pg-enums): honor PgEnum schema in MapEnum
Pass attr.Schema to MapEnum so schema-qualified Postgres enums are mapped in the correct schema instead of the default one, and fully-qualify the cref in PgEnumAttribute. Refresh OpenShockContextModelSnapshot after the enum/namespace changes.
1 parent 204206a commit bc6f1bf

3 files changed

Lines changed: 2 additions & 3 deletions

File tree

Common/Migrations/OpenShockContextModelSnapshot.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using Microsoft.EntityFrameworkCore.Infrastructure;
77
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
88
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
9-
using OpenShock.Common.Models;
109
using OpenShock.Common.OpenShockDb;
1110

1211
#nullable disable

Common/OpenShockDb/Extensions/NpgsqlEnumExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ private static PgEnumInfo BuildInfo<TEnum>() where TEnum : struct, Enum
2828
.ToArray();
2929

3030
return new PgEnumInfo(
31-
Map: b => b.MapEnum<TEnum>(pgTypeName),
31+
Map: b => b.MapEnum<TEnum>(pgTypeName, attr.Schema),
3232
Register: m => m.HasPostgresEnum(attr.Schema, pgTypeName, members));
3333
}
3434

Common/Utils/PgEnumAttribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ namespace OpenShock.Common.Utils;
22

33
/// <summary>
44
/// Marks an enum as a Postgres native enum type so it is automatically registered
5-
/// with the EF Core model via <see cref="OpenShockDb.NpgsqlEnumExtensions.RegisterPgEnums"/>.
5+
/// with the EF Core model via <see cref="OpenShock.Common.OpenShockDb.NpgsqlEnumExtensions.RegisterPgEnums"/>.
66
/// </summary>
77
[AttributeUsage(AttributeTargets.Enum)]
88
public sealed class PgEnumAttribute : Attribute

0 commit comments

Comments
 (0)