From 857b7daffd39278880a128943a7fc9800834207a Mon Sep 17 00:00:00 2001
From: Thanakarn Klangkasame <77600906+Simulationable@users.noreply.github.com>
Date: Wed, 26 Nov 2025 10:30:13 +0700
Subject: [PATCH] [Add] Location Code.
---
...20251118054031_AddLocationCode.Designer.cs | 6285 +++++++++++++++++
.../20251118054031_AddLocationCode.cs | 363 +
2 files changed, 6648 insertions(+)
create mode 100644 AMREZ.EOP.Infrastructures/Migrations/20251118054031_AddLocationCode.Designer.cs
create mode 100644 AMREZ.EOP.Infrastructures/Migrations/20251118054031_AddLocationCode.cs
diff --git a/AMREZ.EOP.Infrastructures/Migrations/20251118054031_AddLocationCode.Designer.cs b/AMREZ.EOP.Infrastructures/Migrations/20251118054031_AddLocationCode.Designer.cs
new file mode 100644
index 0000000..8d3c461
--- /dev/null
+++ b/AMREZ.EOP.Infrastructures/Migrations/20251118054031_AddLocationCode.Designer.cs
@@ -0,0 +1,6285 @@
+//
+using System;
+using AMREZ.EOP.Infrastructures.Data;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+
+#nullable disable
+
+namespace AMREZ.EOP.Infrastructures.Migrations
+{
+ [DbContext(typeof(AppDbContext))]
+ [Migration("20251118054031_AddLocationCode")]
+ partial class AddLocationCode
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "9.0.9")
+ .HasAnnotation("Relational:MaxIdentifierLength", 63);
+
+ NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
+
+ modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Authentications.Permission", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("Code")
+ .IsRequired()
+ .HasMaxLength(256)
+ .HasColumnType("character varying(256)");
+
+ b.Property("CreatedAt")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("created_at")
+ .HasDefaultValueSql("now() at time zone 'utc'");
+
+ b.Property("CreatedBy")
+ .HasColumnType("text")
+ .HasColumnName("created_by");
+
+ b.Property("IsDeleted")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("boolean")
+ .HasDefaultValue(false)
+ .HasColumnName("is_deleted");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(256)
+ .HasColumnType("character varying(256)");
+
+ b.Property("TenantId")
+ .HasColumnType("uuid")
+ .HasColumnName("tenant_id");
+
+ b.Property("UpdatedAt")
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("updated_at");
+
+ b.Property("UpdatedBy")
+ .HasColumnType("text")
+ .HasColumnName("updated_by");
+
+ b.HasKey("Id");
+
+ b.HasIndex("TenantId");
+
+ b.HasIndex("TenantId", "Code")
+ .IsUnique();
+
+ b.ToTable("permissions", null, t =>
+ {
+ t.HasCheckConstraint("ck_permissions_tenant_not_null", "tenant_id is not null");
+
+ t.HasCheckConstraint("ck_permissions_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'");
+ });
+ });
+
+ modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Authentications.Role", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("Code")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property("CreatedAt")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("created_at")
+ .HasDefaultValueSql("now() at time zone 'utc'");
+
+ b.Property("CreatedBy")
+ .HasColumnType("text")
+ .HasColumnName("created_by");
+
+ b.Property("IsDeleted")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("boolean")
+ .HasDefaultValue(false)
+ .HasColumnName("is_deleted");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(256)
+ .HasColumnType("character varying(256)");
+
+ b.Property("TenantId")
+ .HasColumnType("uuid")
+ .HasColumnName("tenant_id");
+
+ b.Property("UpdatedAt")
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("updated_at");
+
+ b.Property("UpdatedBy")
+ .HasColumnType("text")
+ .HasColumnName("updated_by");
+
+ b.HasKey("Id");
+
+ b.HasIndex("TenantId");
+
+ b.HasIndex("TenantId", "Code")
+ .IsUnique();
+
+ b.ToTable("roles", null, t =>
+ {
+ t.HasCheckConstraint("ck_roles_tenant_not_null", "tenant_id is not null");
+
+ t.HasCheckConstraint("ck_roles_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'");
+ });
+ });
+
+ modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Authentications.RolePermission", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("CreatedAt")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("created_at")
+ .HasDefaultValueSql("now() at time zone 'utc'");
+
+ b.Property("CreatedBy")
+ .HasColumnType("text")
+ .HasColumnName("created_by");
+
+ b.Property("IsDeleted")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("boolean")
+ .HasDefaultValue(false)
+ .HasColumnName("is_deleted");
+
+ b.Property("PermissionId")
+ .HasColumnType("uuid");
+
+ b.Property("RoleId")
+ .HasColumnType("uuid");
+
+ b.Property("TenantId")
+ .HasColumnType("uuid")
+ .HasColumnName("tenant_id");
+
+ b.Property("UpdatedAt")
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("updated_at");
+
+ b.Property("UpdatedBy")
+ .HasColumnType("text")
+ .HasColumnName("updated_by");
+
+ b.HasKey("Id");
+
+ b.HasIndex("PermissionId");
+
+ b.HasIndex("RoleId");
+
+ b.HasIndex("TenantId");
+
+ b.HasIndex("TenantId", "PermissionId");
+
+ b.HasIndex("TenantId", "RoleId", "PermissionId")
+ .IsUnique();
+
+ b.ToTable("role_permissions", null, t =>
+ {
+ t.HasCheckConstraint("ck_role_permissions_tenant_not_null", "tenant_id is not null");
+
+ t.HasCheckConstraint("ck_role_permissions_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'");
+ });
+ });
+
+ modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Authentications.User", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("AccessFailedCount")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer")
+ .HasDefaultValue(0);
+
+ b.Property("CreatedAt")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("created_at")
+ .HasDefaultValueSql("now() at time zone 'utc'");
+
+ b.Property("CreatedBy")
+ .HasColumnType("text")
+ .HasColumnName("created_by");
+
+ b.Property("IsActive")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("boolean")
+ .HasDefaultValue(true);
+
+ b.Property("IsDeleted")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("boolean")
+ .HasDefaultValue(false)
+ .HasColumnName("is_deleted");
+
+ b.Property("LockoutEndUtc")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("MfaEnabled")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("boolean")
+ .HasDefaultValue(false);
+
+ b.Property("PasswordHash")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("SecurityStamp")
+ .HasColumnType("text");
+
+ b.Property("TenantId")
+ .HasColumnType("uuid")
+ .HasColumnName("tenant_id");
+
+ b.Property("UpdatedAt")
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("updated_at");
+
+ b.Property("UpdatedBy")
+ .HasColumnType("text")
+ .HasColumnName("updated_by");
+
+ b.HasKey("Id");
+
+ b.HasIndex("TenantId");
+
+ b.ToTable("users", null, t =>
+ {
+ t.HasCheckConstraint("ck_users_tenant_not_null", "tenant_id is not null");
+
+ t.HasCheckConstraint("ck_users_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'");
+ });
+ });
+
+ modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Authentications.UserExternalAccount", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("CreatedAt")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("created_at")
+ .HasDefaultValueSql("now() at time zone 'utc'");
+
+ b.Property("CreatedBy")
+ .HasColumnType("text")
+ .HasColumnName("created_by");
+
+ b.Property("Email")
+ .HasColumnType("text");
+
+ b.Property("IsDeleted")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("boolean")
+ .HasDefaultValue(false)
+ .HasColumnName("is_deleted");
+
+ b.Property("LinkedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("Provider")
+ .HasColumnType("integer");
+
+ b.Property("Subject")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("TenantId")
+ .HasColumnType("uuid")
+ .HasColumnName("tenant_id");
+
+ b.Property("UpdatedAt")
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("updated_at");
+
+ b.Property("UpdatedBy")
+ .HasColumnType("text")
+ .HasColumnName("updated_by");
+
+ b.Property("UserId")
+ .HasColumnType("uuid");
+
+ b.HasKey("Id");
+
+ b.HasIndex("TenantId");
+
+ b.HasIndex("TenantId", "UserId");
+
+ b.HasIndex("TenantId", "Provider", "Subject")
+ .IsUnique();
+
+ b.ToTable("user_external_accounts", null, t =>
+ {
+ t.HasCheckConstraint("ck_user_external_accounts_tenant_not_null", "tenant_id is not null");
+
+ t.HasCheckConstraint("ck_user_external_accounts_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'");
+ });
+ });
+
+ modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Authentications.UserIdentity", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("CreatedAt")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("created_at")
+ .HasDefaultValueSql("now() at time zone 'utc'");
+
+ b.Property("CreatedBy")
+ .HasColumnType("text")
+ .HasColumnName("created_by");
+
+ b.Property("Identifier")
+ .IsRequired()
+ .HasMaxLength(256)
+ .HasColumnType("character varying(256)");
+
+ b.Property("IsDeleted")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("boolean")
+ .HasDefaultValue(false)
+ .HasColumnName("is_deleted");
+
+ b.Property("IsPrimary")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("boolean")
+ .HasDefaultValue(false);
+
+ b.Property("TenantId")
+ .HasColumnType("uuid")
+ .HasColumnName("tenant_id");
+
+ b.Property("Type")
+ .HasColumnType("integer");
+
+ b.Property("UpdatedAt")
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("updated_at");
+
+ b.Property("UpdatedBy")
+ .HasColumnType("text")
+ .HasColumnName("updated_by");
+
+ b.Property("UserId")
+ .HasColumnType("uuid");
+
+ b.Property("VerifiedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.HasKey("Id");
+
+ b.HasIndex("TenantId");
+
+ b.HasIndex("TenantId", "Type", "Identifier")
+ .IsUnique();
+
+ b.HasIndex("TenantId", "UserId", "Type", "IsPrimary")
+ .HasDatabaseName("ix_user_identity_primary_per_type");
+
+ b.ToTable("user_identities", null, t =>
+ {
+ t.HasCheckConstraint("ck_user_identities_tenant_not_null", "tenant_id is not null");
+
+ t.HasCheckConstraint("ck_user_identities_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'");
+ });
+ });
+
+ modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Authentications.UserMfaFactor", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("AddedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("CreatedAt")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("created_at")
+ .HasDefaultValueSql("now() at time zone 'utc'");
+
+ b.Property("CreatedBy")
+ .HasColumnType("text")
+ .HasColumnName("created_by");
+
+ b.Property("CredentialId")
+ .HasColumnType("text");
+
+ b.Property("Email")
+ .HasColumnType("text");
+
+ b.Property("Enabled")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("boolean")
+ .HasDefaultValue(true);
+
+ b.Property("IsDeleted")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("boolean")
+ .HasDefaultValue(false)
+ .HasColumnName("is_deleted");
+
+ b.Property("Label")
+ .HasColumnType("text");
+
+ b.Property("LastUsedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("PhoneE164")
+ .HasColumnType("text");
+
+ b.Property("PublicKey")
+ .HasColumnType("text");
+
+ b.Property("Secret")
+ .HasColumnType("text");
+
+ b.Property("TenantId")
+ .HasColumnType("uuid")
+ .HasColumnName("tenant_id");
+
+ b.Property("Type")
+ .HasColumnType("integer");
+
+ b.Property("UpdatedAt")
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("updated_at");
+
+ b.Property("UpdatedBy")
+ .HasColumnType("text")
+ .HasColumnName("updated_by");
+
+ b.Property("UserId")
+ .HasColumnType("uuid");
+
+ b.HasKey("Id");
+
+ b.HasIndex("TenantId");
+
+ b.HasIndex("TenantId", "UserId");
+
+ b.ToTable("user_mfa_factors", null, t =>
+ {
+ t.HasCheckConstraint("ck_user_mfa_factors_tenant_not_null", "tenant_id is not null");
+
+ t.HasCheckConstraint("ck_user_mfa_factors_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'");
+ });
+ });
+
+ modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Authentications.UserPasswordHistory", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("ChangedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("CreatedAt")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("created_at")
+ .HasDefaultValueSql("now() at time zone 'utc'");
+
+ b.Property("CreatedBy")
+ .HasColumnType("text")
+ .HasColumnName("created_by");
+
+ b.Property("IsDeleted")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("boolean")
+ .HasDefaultValue(false)
+ .HasColumnName("is_deleted");
+
+ b.Property("PasswordHash")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("TenantId")
+ .HasColumnType("uuid")
+ .HasColumnName("tenant_id");
+
+ b.Property("UpdatedAt")
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("updated_at");
+
+ b.Property("UpdatedBy")
+ .HasColumnType("text")
+ .HasColumnName("updated_by");
+
+ b.Property("UserId")
+ .HasColumnType("uuid");
+
+ b.HasKey("Id");
+
+ b.HasIndex("TenantId");
+
+ b.HasIndex("TenantId", "UserId", "ChangedAt");
+
+ b.ToTable("user_password_histories", null, t =>
+ {
+ t.HasCheckConstraint("ck_user_password_histories_tenant_not_null", "tenant_id is not null");
+
+ t.HasCheckConstraint("ck_user_password_histories_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'");
+ });
+ });
+
+ modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Authentications.UserRole", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("CreatedAt")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("created_at")
+ .HasDefaultValueSql("now() at time zone 'utc'");
+
+ b.Property("CreatedBy")
+ .HasColumnType("text")
+ .HasColumnName("created_by");
+
+ b.Property("IsDeleted")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("boolean")
+ .HasDefaultValue(false)
+ .HasColumnName("is_deleted");
+
+ b.Property("RoleId")
+ .HasColumnType("uuid");
+
+ b.Property("TenantId")
+ .HasColumnType("uuid")
+ .HasColumnName("tenant_id");
+
+ b.Property("UpdatedAt")
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("updated_at");
+
+ b.Property("UpdatedBy")
+ .HasColumnType("text")
+ .HasColumnName("updated_by");
+
+ b.Property("UserId")
+ .HasColumnType("uuid");
+
+ b.HasKey("Id");
+
+ b.HasIndex("RoleId");
+
+ b.HasIndex("TenantId");
+
+ b.HasIndex("UserId");
+
+ b.HasIndex("TenantId", "RoleId");
+
+ b.HasIndex("TenantId", "UserId", "RoleId")
+ .IsUnique();
+
+ b.ToTable("user_roles", null, t =>
+ {
+ t.HasCheckConstraint("ck_user_roles_tenant_not_null", "tenant_id is not null");
+
+ t.HasCheckConstraint("ck_user_roles_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'");
+ });
+ });
+
+ modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Authentications.UserSession", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("CreatedAt")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("created_at")
+ .HasDefaultValueSql("now() at time zone 'utc'");
+
+ b.Property("CreatedBy")
+ .HasColumnType("text")
+ .HasColumnName("created_by");
+
+ b.Property("DeviceId")
+ .HasColumnType("text");
+
+ b.Property("ExpiresAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("IpAddress")
+ .HasColumnType("text");
+
+ b.Property("IsDeleted")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("boolean")
+ .HasDefaultValue(false)
+ .HasColumnName("is_deleted");
+
+ b.Property("IssuedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("RefreshTokenHash")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("RevokedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("TenantId")
+ .HasColumnType("uuid")
+ .HasColumnName("tenant_id");
+
+ b.Property("UpdatedAt")
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("updated_at");
+
+ b.Property("UpdatedBy")
+ .HasColumnType("text")
+ .HasColumnName("updated_by");
+
+ b.Property("UserAgent")
+ .HasColumnType("text");
+
+ b.Property("UserId")
+ .HasColumnType("uuid");
+
+ b.HasKey("Id");
+
+ b.HasIndex("TenantId");
+
+ b.HasIndex("TenantId", "DeviceId");
+
+ b.HasIndex("TenantId", "UserId");
+
+ b.ToTable("user_sessions", null, t =>
+ {
+ t.HasCheckConstraint("ck_user_sessions_tenant_not_null", "tenant_id is not null");
+
+ t.HasCheckConstraint("ck_user_sessions_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'");
+ });
+ });
+
+ modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Customers.Address", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("CountryCode")
+ .IsRequired()
+ .HasMaxLength(2)
+ .HasColumnType("character varying(2)");
+
+ b.Property("CreatedAt")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("created_at")
+ .HasDefaultValueSql("now() at time zone 'utc'");
+
+ b.Property("CreatedBy")
+ .HasColumnType("text")
+ .HasColumnName("created_by");
+
+ b.Property("District")
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property("GeoLat")
+ .HasColumnType("double precision");
+
+ b.Property("GeoLng")
+ .HasColumnType("double precision");
+
+ b.Property("IsDeleted")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("boolean")
+ .HasDefaultValue(false)
+ .HasColumnName("is_deleted");
+
+ b.Property("Line1")
+ .HasMaxLength(256)
+ .HasColumnType("character varying(256)");
+
+ b.Property("Line2")
+ .HasMaxLength(256)
+ .HasColumnType("character varying(256)");
+
+ b.Property("PostalCode")
+ .HasMaxLength(10)
+ .HasColumnType("character varying(10)");
+
+ b.Property("Province")
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property("Road")
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property("Soi")
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property("Subdistrict")
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property("TenantId")
+ .HasColumnType("uuid")
+ .HasColumnName("tenant_id");
+
+ b.Property("UpdatedAt")
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("updated_at");
+
+ b.Property("UpdatedBy")
+ .HasColumnType("text")
+ .HasColumnName("updated_by");
+
+ b.Property("Verified")
+ .HasColumnType("boolean");
+
+ b.Property("Village")
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("TenantId");
+
+ b.ToTable("addresses", null, t =>
+ {
+ t.HasCheckConstraint("ck_addresses_tenant_not_null", "tenant_id is not null");
+
+ t.HasCheckConstraint("ck_addresses_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'");
+ });
+ });
+
+ modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Customers.CustomerAddress", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("AddressId")
+ .HasColumnType("uuid");
+
+ b.Property("CreatedAt")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("created_at")
+ .HasDefaultValueSql("now() at time zone 'utc'");
+
+ b.Property("CreatedBy")
+ .HasColumnType("text")
+ .HasColumnName("created_by");
+
+ b.Property("CustomerProfileId")
+ .HasColumnType("uuid");
+
+ b.Property("IsDefault")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("boolean")
+ .HasDefaultValue(false);
+
+ b.Property("IsDeleted")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("boolean")
+ .HasDefaultValue(false)
+ .HasColumnName("is_deleted");
+
+ b.Property("Label")
+ .HasColumnType("integer");
+
+ b.Property("TenantId")
+ .HasColumnType("uuid")
+ .HasColumnName("tenant_id");
+
+ b.Property("UpdatedAt")
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("updated_at");
+
+ b.Property("UpdatedBy")
+ .HasColumnType("text")
+ .HasColumnName("updated_by");
+
+ b.HasKey("Id");
+
+ b.HasIndex("TenantId");
+
+ b.HasIndex("TenantId", "AddressId");
+
+ b.HasIndex("TenantId", "CustomerProfileId", "Label");
+
+ b.HasIndex("TenantId", "CustomerProfileId", "Label", "IsDefault")
+ .IsUnique()
+ .HasDatabaseName("ux_default_customer_address_per_label")
+ .HasFilter("\"IsDefault\" = TRUE");
+
+ b.ToTable("customer_addresses", null, t =>
+ {
+ t.HasCheckConstraint("ck_customer_addresses_tenant_not_null", "tenant_id is not null");
+
+ t.HasCheckConstraint("ck_customer_addresses_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'");
+ });
+ });
+
+ modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Customers.CustomerContact", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("CreatedAt")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("created_at")
+ .HasDefaultValueSql("now() at time zone 'utc'");
+
+ b.Property("CreatedBy")
+ .HasColumnType("text")
+ .HasColumnName("created_by");
+
+ b.Property("CustomerProfileId")
+ .HasColumnType("uuid");
+
+ b.Property("IsDeleted")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("boolean")
+ .HasDefaultValue(false)
+ .HasColumnName("is_deleted");
+
+ b.Property("IsPrimary")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("boolean")
+ .HasDefaultValue(false);
+
+ b.Property("IsVerified")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("boolean")
+ .HasDefaultValue(false);
+
+ b.Property("TenantId")
+ .HasColumnType("uuid")
+ .HasColumnName("tenant_id");
+
+ b.Property("Type")
+ .HasColumnType("integer");
+
+ b.Property("UpdatedAt")
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("updated_at");
+
+ b.Property("UpdatedBy")
+ .HasColumnType("text")
+ .HasColumnName("updated_by");
+
+ b.Property("Value")
+ .IsRequired()
+ .HasMaxLength(256)
+ .HasColumnType("character varying(256)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("TenantId");
+
+ b.HasIndex("TenantId", "CustomerProfileId", "Type");
+
+ b.HasIndex("TenantId", "CustomerProfileId", "Type", "IsPrimary")
+ .IsUnique()
+ .HasDatabaseName("ux_customer_contact_primary_per_type")
+ .HasFilter("\"IsPrimary\" = TRUE");
+
+ b.ToTable("customer_contacts", null, t =>
+ {
+ t.HasCheckConstraint("ck_customer_contacts_tenant_not_null", "tenant_id is not null");
+
+ t.HasCheckConstraint("ck_customer_contacts_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'");
+ });
+ });
+
+ modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Customers.CustomerProfile", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("CreatedAt")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("created_at")
+ .HasDefaultValueSql("now() at time zone 'utc'");
+
+ b.Property("CreatedBy")
+ .HasColumnType("text")
+ .HasColumnName("created_by");
+
+ b.Property("DisplayName")
+ .IsRequired()
+ .HasMaxLength(256)
+ .HasColumnType("character varying(256)");
+
+ b.Property("IsDeleted")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("boolean")
+ .HasDefaultValue(false)
+ .HasColumnName("is_deleted");
+
+ b.Property("Status")
+ .HasColumnType("integer");
+
+ b.Property("TenantId")
+ .HasColumnType("uuid")
+ .HasColumnName("tenant_id");
+
+ b.Property("Type")
+ .HasColumnType("integer");
+
+ b.Property("UpdatedAt")
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("updated_at");
+
+ b.Property("UpdatedBy")
+ .HasColumnType("text")
+ .HasColumnName("updated_by");
+
+ b.HasKey("Id");
+
+ b.HasIndex("TenantId");
+
+ b.HasIndex("TenantId", "DisplayName");
+
+ b.ToTable("customer_profiles", null, t =>
+ {
+ t.HasCheckConstraint("ck_customer_profiles_tenant_not_null", "tenant_id is not null");
+
+ t.HasCheckConstraint("ck_customer_profiles_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'");
+ });
+ });
+
+ modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Customers.CustomerTag", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("CreatedAt")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("created_at")
+ .HasDefaultValueSql("now() at time zone 'utc'");
+
+ b.Property("CreatedBy")
+ .HasColumnType("text")
+ .HasColumnName("created_by");
+
+ b.Property("CustomerProfileId")
+ .HasColumnType("uuid");
+
+ b.Property("IsDeleted")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("boolean")
+ .HasDefaultValue(false)
+ .HasColumnName("is_deleted");
+
+ b.Property("Tag")
+ .IsRequired()
+ .HasMaxLength(64)
+ .HasColumnType("character varying(64)");
+
+ b.Property("TenantId")
+ .HasColumnType("uuid")
+ .HasColumnName("tenant_id");
+
+ b.Property("UpdatedAt")
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("updated_at");
+
+ b.Property("UpdatedBy")
+ .HasColumnType("text")
+ .HasColumnName("updated_by");
+
+ b.HasKey("Id");
+
+ b.HasIndex("TenantId");
+
+ b.HasIndex("TenantId", "CustomerProfileId", "Tag")
+ .IsUnique();
+
+ b.ToTable("customer_tags", null, t =>
+ {
+ t.HasCheckConstraint("ck_customer_tags_tenant_not_null", "tenant_id is not null");
+
+ t.HasCheckConstraint("ck_customer_tags_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'");
+ });
+ });
+
+ modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Customers.OrganizationProfile", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("BranchCode")
+ .HasMaxLength(5)
+ .HasColumnType("character varying(5)");
+
+ b.Property("CompanyType")
+ .HasMaxLength(64)
+ .HasColumnType("character varying(64)");
+
+ b.Property("CreatedAt")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("created_at")
+ .HasDefaultValueSql("now() at time zone 'utc'");
+
+ b.Property("CreatedBy")
+ .HasColumnType("text")
+ .HasColumnName("created_by");
+
+ b.Property("CustomerProfileId")
+ .HasColumnType("uuid");
+
+ b.Property("IsDeleted")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("boolean")
+ .HasDefaultValue(false)
+ .HasColumnName("is_deleted");
+
+ b.Property("LegalNameEn")
+ .HasMaxLength(256)
+ .HasColumnType("character varying(256)");
+
+ b.Property("LegalNameTh")
+ .IsRequired()
+ .HasMaxLength(256)
+ .HasColumnType("character varying(256)");
+
+ b.Property("RegistrationNo")
+ .HasMaxLength(64)
+ .HasColumnType("character varying(64)");
+
+ b.Property("TaxId13")
+ .HasMaxLength(13)
+ .HasColumnType("character varying(13)");
+
+ b.Property("TenantId")
+ .HasColumnType("uuid")
+ .HasColumnName("tenant_id");
+
+ b.Property("UpdatedAt")
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("updated_at");
+
+ b.Property("UpdatedBy")
+ .HasColumnType("text")
+ .HasColumnName("updated_by");
+
+ b.HasKey("Id");
+
+ b.HasIndex("TenantId");
+
+ b.HasIndex("TenantId", "CustomerProfileId")
+ .IsUnique();
+
+ b.HasIndex("TenantId", "TaxId13", "BranchCode")
+ .IsUnique()
+ .HasFilter("\"TaxId13\" IS NOT NULL");
+
+ b.ToTable("organization_profiles", null, t =>
+ {
+ t.HasCheckConstraint("ck_organization_profiles_tenant_not_null", "tenant_id is not null");
+
+ t.HasCheckConstraint("ck_organization_profiles_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'");
+ });
+ });
+
+ modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Customers.PersonProfile", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("BirthDate")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("CreatedAt")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("created_at")
+ .HasDefaultValueSql("now() at time zone 'utc'");
+
+ b.Property("CreatedBy")
+ .HasColumnType("text")
+ .HasColumnName("created_by");
+
+ b.Property("CustomerProfileId")
+ .HasColumnType("uuid");
+
+ b.Property("FirstNameEn")
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property("FirstNameTh")
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property("IsDeleted")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("boolean")
+ .HasDefaultValue(false)
+ .HasColumnName("is_deleted");
+
+ b.Property("LastNameEn")
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property("LastNameTh")
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property("NationalId")
+ .HasMaxLength(13)
+ .HasColumnType("character varying(13)");
+
+ b.Property("PassportNo")
+ .HasMaxLength(32)
+ .HasColumnType("character varying(32)");
+
+ b.Property("Prefix")
+ .HasMaxLength(32)
+ .HasColumnType("character varying(32)");
+
+ b.Property("TenantId")
+ .HasColumnType("uuid")
+ .HasColumnName("tenant_id");
+
+ b.Property("UpdatedAt")
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("updated_at");
+
+ b.Property("UpdatedBy")
+ .HasColumnType("text")
+ .HasColumnName("updated_by");
+
+ b.HasKey("Id");
+
+ b.HasIndex("TenantId");
+
+ b.HasIndex("TenantId", "CustomerProfileId")
+ .IsUnique();
+
+ b.ToTable("person_profiles", null, t =>
+ {
+ t.HasCheckConstraint("ck_person_profiles_tenant_not_null", "tenant_id is not null");
+
+ t.HasCheckConstraint("ck_person_profiles_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'");
+ });
+ });
+
+ modelBuilder.Entity("AMREZ.EOP.Domain.Entities.HumanResources.Department", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("Code")
+ .IsRequired()
+ .HasMaxLength(64)
+ .HasColumnType("character varying(64)");
+
+ b.Property("CreatedAt")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("created_at")
+ .HasDefaultValueSql("now() at time zone 'utc'");
+
+ b.Property("CreatedBy")
+ .HasColumnType("text")
+ .HasColumnName("created_by");
+
+ b.Property("IsDeleted")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("boolean")
+ .HasDefaultValue(false)
+ .HasColumnName("is_deleted");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(256)
+ .HasColumnType("character varying(256)");
+
+ b.Property("ParentDepartmentId")
+ .HasColumnType("uuid");
+
+ b.Property("TenantId")
+ .HasColumnType("uuid")
+ .HasColumnName("tenant_id");
+
+ b.Property("UpdatedAt")
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("updated_at");
+
+ b.Property("UpdatedBy")
+ .HasColumnType("text")
+ .HasColumnName("updated_by");
+
+ b.HasKey("Id");
+
+ b.HasIndex("TenantId");
+
+ b.HasIndex("TenantId", "Code")
+ .IsUnique();
+
+ b.HasIndex("TenantId", "ParentDepartmentId");
+
+ b.ToTable("departments", null, t =>
+ {
+ t.HasCheckConstraint("ck_departments_tenant_not_null", "tenant_id is not null");
+
+ t.HasCheckConstraint("ck_departments_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'");
+ });
+ });
+
+ modelBuilder.Entity("AMREZ.EOP.Domain.Entities.HumanResources.EmergencyContact", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("CreatedAt")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("created_at")
+ .HasDefaultValueSql("now() at time zone 'utc'");
+
+ b.Property("CreatedBy")
+ .HasColumnType("text")
+ .HasColumnName("created_by");
+
+ b.Property("Email")
+ .HasColumnType("text");
+
+ b.Property("IsDeleted")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("boolean")
+ .HasDefaultValue(false)
+ .HasColumnName("is_deleted");
+
+ b.Property("IsPrimary")
+ .HasColumnType("boolean");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property("Phone")
+ .HasColumnType("text");
+
+ b.Property("Relationship")
+ .IsRequired()
+ .HasMaxLength(64)
+ .HasColumnType("character varying(64)");
+
+ b.Property("TenantId")
+ .HasColumnType("uuid")
+ .HasColumnName("tenant_id");
+
+ b.Property("UpdatedAt")
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("updated_at");
+
+ b.Property("UpdatedBy")
+ .HasColumnType("text")
+ .HasColumnName("updated_by");
+
+ b.Property("UserProfileId")
+ .HasColumnType("uuid");
+
+ b.HasKey("Id");
+
+ b.HasIndex("TenantId");
+
+ b.HasIndex("TenantId", "UserProfileId", "IsPrimary");
+
+ b.ToTable("emergency_contacts", null, t =>
+ {
+ t.HasCheckConstraint("ck_emergency_contacts_tenant_not_null", "tenant_id is not null");
+
+ t.HasCheckConstraint("ck_emergency_contacts_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'");
+ });
+ });
+
+ modelBuilder.Entity("AMREZ.EOP.Domain.Entities.HumanResources.EmployeeAddress", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("City")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property("Country")
+ .IsRequired()
+ .HasMaxLength(64)
+ .HasColumnType("character varying(64)");
+
+ b.Property("CreatedAt")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("created_at")
+ .HasDefaultValueSql("now() at time zone 'utc'");
+
+ b.Property("CreatedBy")
+ .HasColumnType("text")
+ .HasColumnName("created_by");
+
+ b.Property("IsDeleted")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("boolean")
+ .HasDefaultValue(false)
+ .HasColumnName("is_deleted");
+
+ b.Property("IsPrimary")
+ .HasColumnType("boolean");
+
+ b.Property("Line1")
+ .IsRequired()
+ .HasMaxLength(256)
+ .HasColumnType("character varying(256)");
+
+ b.Property("Line2")
+ .HasColumnType("text");
+
+ b.Property("PostalCode")
+ .IsRequired()
+ .HasMaxLength(32)
+ .HasColumnType("character varying(32)");
+
+ b.Property("State")
+ .HasColumnType("text");
+
+ b.Property("TenantId")
+ .HasColumnType("uuid")
+ .HasColumnName("tenant_id");
+
+ b.Property("Type")
+ .HasColumnType("integer");
+
+ b.Property("UpdatedAt")
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("updated_at");
+
+ b.Property("UpdatedBy")
+ .HasColumnType("text")
+ .HasColumnName("updated_by");
+
+ b.Property("UserProfileId")
+ .HasColumnType("uuid");
+
+ b.HasKey("Id");
+
+ b.HasIndex("TenantId");
+
+ b.HasIndex("TenantId", "UserProfileId", "IsPrimary");
+
+ b.ToTable("employee_addresses", null, t =>
+ {
+ t.HasCheckConstraint("ck_employee_addresses_tenant_not_null", "tenant_id is not null");
+
+ t.HasCheckConstraint("ck_employee_addresses_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'");
+ });
+ });
+
+ modelBuilder.Entity("AMREZ.EOP.Domain.Entities.HumanResources.EmployeeBankAccount", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("AccountHolder")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property("AccountNumber")
+ .IsRequired()
+ .HasMaxLength(64)
+ .HasColumnType("character varying(64)");
+
+ b.Property("BankName")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property("Branch")
+ .HasColumnType("text");
+
+ b.Property("CreatedAt")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("created_at")
+ .HasDefaultValueSql("now() at time zone 'utc'");
+
+ b.Property("CreatedBy")
+ .HasColumnType("text")
+ .HasColumnName("created_by");
+
+ b.Property