diff --git a/AMREZ.EOP.API/Controllers/AuthenticationController.cs b/AMREZ.EOP.API/Controllers/AuthenticationController.cs index 1c29e0f..796fb09 100644 --- a/AMREZ.EOP.API/Controllers/AuthenticationController.cs +++ b/AMREZ.EOP.API/Controllers/AuthenticationController.cs @@ -1,6 +1,8 @@ using System.Security.Claims; using AMREZ.EOP.Abstractions.Applications.UseCases.Authentications; +using AMREZ.EOP.Application.UseCases.Authentications; using AMREZ.EOP.Contracts.DTOs.Authentications.AddEmailIdentity; +using AMREZ.EOP.Contracts.DTOs.Authentications.AssignRole; using AMREZ.EOP.Contracts.DTOs.Authentications.ChangePassword; using AMREZ.EOP.Contracts.DTOs.Authentications.DisableMfa; using AMREZ.EOP.Contracts.DTOs.Authentications.EnableTotp; @@ -10,6 +12,8 @@ using AMREZ.EOP.Contracts.DTOs.Authentications.Logout; using AMREZ.EOP.Contracts.DTOs.Authentications.LogoutAll; using AMREZ.EOP.Contracts.DTOs.Authentications.Refresh; using AMREZ.EOP.Contracts.DTOs.Authentications.Register; +using AMREZ.EOP.Contracts.DTOs.Authentications.Role; +using AMREZ.EOP.Contracts.DTOs.Authentications.UnassignRole; using AMREZ.EOP.Contracts.DTOs.Authentications.VerifyEmail; using AMREZ.EOP.Domain.Shared.Contracts; using Microsoft.AspNetCore.Authentication; @@ -24,18 +28,19 @@ public class AuthenticationController : ControllerBase private readonly ILoginUseCase _login; private readonly IRegisterUseCase _register; private readonly IChangePasswordUseCase _changePassword; - + private readonly IAddEmailIdentityUseCase _addEmail; private readonly IVerifyEmailUseCase _verifyEmail; private readonly IEnableTotpUseCase _enableTotp; private readonly IDisableMfaUseCase _disableMfa; - + private readonly ILogoutUseCase _logout; private readonly ILogoutAllUseCase _logoutAll; - + private readonly IIssueTokenPairUseCase _issueTokens; private readonly IRefreshUseCase _refresh; + public AuthenticationController( ILoginUseCase login, @@ -74,9 +79,21 @@ public class AuthenticationController : ControllerBase new(ClaimTypes.NameIdentifier, res.UserId.ToString()), new(ClaimTypes.Name, res.Email), new(ClaimTypes.Email, res.Email), - new("tenant", res.TenantKey) + new("tenant", res.TenantKey), + new("tenantId", res.TenantId.ToString()) }; + var roles = (res.Roles ?? Array.Empty()) + .Where(r => !string.IsNullOrWhiteSpace(r)) + .Distinct(StringComparer.OrdinalIgnoreCase) + .ToArray(); + + foreach (var r in roles) + claims.Add(new Claim(ClaimTypes.Role, r)); + + if (roles.Length > 0) + claims.Add(new Claim("roles_csv", string.Join(",", roles))); + var principal = new ClaimsPrincipal(new ClaimsIdentity(claims, AuthPolicies.Scheme)); await HttpContext.SignInAsync(AuthPolicies.Scheme, principal); @@ -85,7 +102,8 @@ public class AuthenticationController : ControllerBase UserId = res.UserId, TenantId = res.TenantId, Tenant = res.TenantKey, - Email = res.Email + Email = res.Email, + Roles = roles }, ct); if (!string.IsNullOrWhiteSpace(tokenPair.RefreshToken)) @@ -105,6 +123,7 @@ public class AuthenticationController : ControllerBase return Ok(new { user = res, + roles, access_token = tokenPair.AccessToken, token_type = "Bearer", expires_at = tokenPair.AccessExpiresAt @@ -132,7 +151,7 @@ public class AuthenticationController : ControllerBase new CookieOptions { HttpOnly = true, - Secure = false, + Secure = false, SameSite = SameSiteMode.None, Expires = res.RefreshExpiresAt?.UtcDateTime }); @@ -145,7 +164,7 @@ public class AuthenticationController : ControllerBase expires_at = res.AccessExpiresAt }); } - + [HttpPost("register")] public async Task Register([FromBody] RegisterRequest body, CancellationToken ct) { @@ -164,13 +183,15 @@ public class AuthenticationController : ControllerBase return NoContent(); } + + [HttpPost("logout")] public async Task Logout() { await HttpContext.SignOutAsync(AuthPolicies.Scheme); return NoContent(); } - + [HttpPost("email")] public async Task AddEmail([FromBody] AddEmailIdentityRequest body, CancellationToken ct) { @@ -186,7 +207,7 @@ public class AuthenticationController : ControllerBase if (!ok) return BadRequest(new { message = "Verify email failed" }); return NoContent(); } - + [HttpPost("totp/enable")] public async Task EnableTotp([FromBody] EnableTotpRequest body, CancellationToken ct) { @@ -202,7 +223,7 @@ public class AuthenticationController : ControllerBase if (!ok) return BadRequest(new { message = "Disable MFA failed" }); return NoContent(); } - + [HttpPost("revoke")] public async Task Revoke([FromBody] LogoutRequest body, CancellationToken ct) { diff --git a/AMREZ.EOP.Abstractions/Infrastructures/Repositories/IUserRepository.cs b/AMREZ.EOP.Abstractions/Infrastructures/Repositories/IUserRepository.cs index 35598c5..08902c2 100644 --- a/AMREZ.EOP.Abstractions/Infrastructures/Repositories/IUserRepository.cs +++ b/AMREZ.EOP.Abstractions/Infrastructures/Repositories/IUserRepository.cs @@ -10,7 +10,8 @@ public interface IUserRepository Task FindActiveByEmailAsync(string email, CancellationToken ct = default); Task EmailExistsAsync(string email, CancellationToken ct = default); Task AddAsync(User user, CancellationToken ct = default); - + Task GetRoleCodesByUserIdAsync(Guid userId, Guid tenantId, CancellationToken ct = default); + Task AddIdentityAsync(Guid userId, IdentityType type, string identifier, bool isPrimary, CancellationToken ct = default); Task VerifyIdentityAsync(Guid userId, IdentityType type, string identifier, DateTimeOffset verifiedAt, CancellationToken ct = default); Task GetPrimaryIdentityAsync(Guid userId, IdentityType type, CancellationToken ct = default); diff --git a/AMREZ.EOP.Application/UseCases/Authentications/IssueTokenPairUseCase.cs b/AMREZ.EOP.Application/UseCases/Authentications/IssueTokenPairUseCase.cs index 16566b9..0497627 100644 --- a/AMREZ.EOP.Application/UseCases/Authentications/IssueTokenPairUseCase.cs +++ b/AMREZ.EOP.Application/UseCases/Authentications/IssueTokenPairUseCase.cs @@ -32,52 +32,71 @@ public sealed class IssueTokenPairUseCase : IIssueTokenPairUseCase } public async Task ExecuteAsync(IssueTokenPairRequest request, CancellationToken ct = default) +{ + var http = _http.HttpContext ?? throw new InvalidOperationException("No HttpContext"); + + var tenantId = request.TenantId; + + // ---- สร้าง/บันทึก refresh session ---- + var refreshRaw = Convert.ToBase64String(RandomNumberGenerator.GetBytes(64)); + var refreshHash = Sha256(refreshRaw); + var now = DateTimeOffset.UtcNow; + + var session = await _users.CreateSessionAsync(new UserSession { - var http = _http.HttpContext ?? throw new InvalidOperationException("No HttpContext"); + Id = Guid.NewGuid(), + TenantId = tenantId, + UserId = request.UserId, + RefreshTokenHash = refreshHash, + IssuedAt = now, + ExpiresAt = now.AddDays(RefreshDays), + DeviceId = http.Request.Headers["X-Device-Id"].FirstOrDefault(), + UserAgent = http.Request.Headers["User-Agent"].FirstOrDefault(), + IpAddress = http.Connection.RemoteIpAddress?.ToString() + }, ct); - var tenantId = request.TenantId; + // ---- เวอร์ชัน/สแตมป์ความปลอดภัย ---- + var tv = await _users.GetTenantTokenVersionAsync(tenantId, ct); + var sstamp = await _users.GetUserSecurityStampAsync(request.UserId, ct) ?? string.Empty; - var refreshRaw = Convert.ToBase64String(RandomNumberGenerator.GetBytes(64)); - var refreshHash = Sha256(refreshRaw); - var now = DateTimeOffset.UtcNow; + // ---- เตรียม claims พื้นฐาน ---- + var claims = new List + { + new("sub", request.UserId.ToString()), + new("email", request.Email), + new("tenant", request.Tenant), // tenantKey ที่ FE ใช้ + new("tenant_id", tenantId.ToString()), + new("sid", session.Id.ToString()), + new("jti", Guid.NewGuid().ToString("N")), + new("tv", tv), + new("sstamp", sstamp), + new("iat", now.ToUnixTimeSeconds().ToString(), ClaimValueTypes.Integer64) + }; - var session = await _users.CreateSessionAsync(new UserSession - { - Id = Guid.NewGuid(), - TenantId = tenantId, - UserId = request.UserId, - RefreshTokenHash = refreshHash, - IssuedAt = now, - ExpiresAt = now.AddDays(RefreshDays), - DeviceId = http.Request.Headers["X-Device-Id"].FirstOrDefault(), - UserAgent = http.Request.Headers["User-Agent"].FirstOrDefault(), - IpAddress = http.Connection.RemoteIpAddress?.ToString() - }, ct); - - var tv = await _users.GetTenantTokenVersionAsync(tenantId, ct); - var sstamp = await _users.GetUserSecurityStampAsync(request.UserId, ct) ?? string.Empty; - - var claims = new List - { - new("sub", request.UserId.ToString()), - new("tenant_id", tenantId.ToString()), - new("sid", session.Id.ToString()), - new("jti", Guid.NewGuid().ToString("N")), - new("tv", tv), - new("sstamp", sstamp) - }; - - var (access, accessExp) = _jwt.CreateAccessToken(claims); - - return new IssueTokenPairResponse - { - AccessToken = access, - AccessExpiresAt = accessExp, - RefreshToken = refreshRaw, // ส่ง raw กลับให้ client - RefreshExpiresAt = session.ExpiresAt - }; + string[] roles = request.Roles ?? Array.Empty(); + if (roles.Length == 0) + { + roles = await _users.GetRoleCodesByUserIdAsync(request.UserId, tenantId, ct); } + foreach (var r in roles.Where(s => !string.IsNullOrWhiteSpace(s)).Distinct(StringComparer.OrdinalIgnoreCase)) + { + claims.Add(new Claim("role", r)); + claims.Add(new Claim(ClaimTypes.Role, r)); + } + + // ---- ออก access token ---- + var (access, accessExp) = _jwt.CreateAccessToken(claims); + + return new IssueTokenPairResponse + { + AccessToken = access, + AccessExpiresAt = accessExp, + RefreshToken = refreshRaw, + RefreshExpiresAt = session.ExpiresAt + }; +} + private static string Sha256(string raw) { var bytes = SHA256.HashData(Encoding.UTF8.GetBytes(raw)); diff --git a/AMREZ.EOP.Application/UseCases/Authentications/LoginUseCase.cs b/AMREZ.EOP.Application/UseCases/Authentications/LoginUseCase.cs index 135cea3..1b08357 100644 --- a/AMREZ.EOP.Application/UseCases/Authentications/LoginUseCase.cs +++ b/AMREZ.EOP.Application/UseCases/Authentications/LoginUseCase.cs @@ -5,6 +5,7 @@ using AMREZ.EOP.Abstractions.Infrastructures.Common; using AMREZ.EOP.Abstractions.Infrastructures.Repositories; using AMREZ.EOP.Abstractions.Security; using AMREZ.EOP.Contracts.DTOs.Authentications.Login; +using AMREZ.EOP.Domain.Entities.Authentications; using Microsoft.AspNetCore.Http; namespace AMREZ.EOP.Application.UseCases.Authentications @@ -60,9 +61,15 @@ namespace AMREZ.EOP.Application.UseCases.Authentications return null; } + var roles = (user.UserRoles ?? Enumerable.Empty()) + .Where(ur => ur.Role != null /*&& ur.Role.TenantId == user.TenantId*/) // ถ้า Role เป็น per-tenant ค่อยกรอง + .Select(ur => ur.Role!.Code) + .Distinct(StringComparer.OrdinalIgnoreCase) + .ToArray(); + await _uow.CommitAsync(ct); - return new LoginResponse(user.Id, user.TenantId, email, tenantKey); + return new LoginResponse(user.Id, user.TenantId, email, tenantKey, roles); } catch { diff --git a/AMREZ.EOP.Contracts/DTOs/Authentications/AssignRole/AssignRoleRequest.cs b/AMREZ.EOP.Contracts/DTOs/Authentications/AssignRole/AssignRoleRequest.cs new file mode 100644 index 0000000..efa8370 --- /dev/null +++ b/AMREZ.EOP.Contracts/DTOs/Authentications/AssignRole/AssignRoleRequest.cs @@ -0,0 +1,3 @@ +namespace AMREZ.EOP.Contracts.DTOs.Authentications.AssignRole; + +public sealed class AssignRoleRequest(Guid UserId, Guid TenantId, string RoleCode); \ No newline at end of file diff --git a/AMREZ.EOP.Contracts/DTOs/Authentications/AssignRole/AssignRoleResponse.cs b/AMREZ.EOP.Contracts/DTOs/Authentications/AssignRole/AssignRoleResponse.cs new file mode 100644 index 0000000..94397ac --- /dev/null +++ b/AMREZ.EOP.Contracts/DTOs/Authentications/AssignRole/AssignRoleResponse.cs @@ -0,0 +1,3 @@ +namespace AMREZ.EOP.Contracts.DTOs.Authentications.AssignRole; + +public sealed class AssignRoleResponse(string[] Roles); \ No newline at end of file diff --git a/AMREZ.EOP.Contracts/DTOs/Authentications/IssueTokenPair/IssueTokenPairRequest.cs b/AMREZ.EOP.Contracts/DTOs/Authentications/IssueTokenPair/IssueTokenPairRequest.cs index 9aaeb62..9951c01 100644 --- a/AMREZ.EOP.Contracts/DTOs/Authentications/IssueTokenPair/IssueTokenPairRequest.cs +++ b/AMREZ.EOP.Contracts/DTOs/Authentications/IssueTokenPair/IssueTokenPairRequest.cs @@ -6,4 +6,5 @@ public sealed class IssueTokenPairRequest public Guid TenantId { get; init; } = default!; public string Tenant { get; init; } = default!; public string Email { get; init; } = default!; + public string[]? Roles { get; init; } = default; } \ No newline at end of file diff --git a/AMREZ.EOP.Contracts/DTOs/Authentications/Login/LoginResponse.cs b/AMREZ.EOP.Contracts/DTOs/Authentications/Login/LoginResponse.cs index 8b0bf6a..54cc0a9 100644 --- a/AMREZ.EOP.Contracts/DTOs/Authentications/Login/LoginResponse.cs +++ b/AMREZ.EOP.Contracts/DTOs/Authentications/Login/LoginResponse.cs @@ -4,5 +4,6 @@ public sealed record LoginResponse( Guid UserId, Guid TenantId, string Email, - string TenantKey + string TenantKey, + string[] Roles ); \ No newline at end of file diff --git a/AMREZ.EOP.Contracts/DTOs/Authentications/Role/RoleChange.cs b/AMREZ.EOP.Contracts/DTOs/Authentications/Role/RoleChange.cs new file mode 100644 index 0000000..7e834d2 --- /dev/null +++ b/AMREZ.EOP.Contracts/DTOs/Authentications/Role/RoleChange.cs @@ -0,0 +1,3 @@ +namespace AMREZ.EOP.Contracts.DTOs.Authentications.Role; + +public sealed record RoleChange(string RoleCode); \ No newline at end of file diff --git a/AMREZ.EOP.Contracts/DTOs/Authentications/UnassignRole/UnassignRoleRequest.cs b/AMREZ.EOP.Contracts/DTOs/Authentications/UnassignRole/UnassignRoleRequest.cs new file mode 100644 index 0000000..1733095 --- /dev/null +++ b/AMREZ.EOP.Contracts/DTOs/Authentications/UnassignRole/UnassignRoleRequest.cs @@ -0,0 +1,3 @@ +namespace AMREZ.EOP.Contracts.DTOs.Authentications.UnassignRole; + +public sealed class UnassignRoleRequest(Guid UserId, Guid TenantId, string RoleCode); \ No newline at end of file diff --git a/AMREZ.EOP.Contracts/DTOs/Authentications/UnassignRole/UnassignRoleResponse.cs b/AMREZ.EOP.Contracts/DTOs/Authentications/UnassignRole/UnassignRoleResponse.cs new file mode 100644 index 0000000..6a26793 --- /dev/null +++ b/AMREZ.EOP.Contracts/DTOs/Authentications/UnassignRole/UnassignRoleResponse.cs @@ -0,0 +1,3 @@ +namespace AMREZ.EOP.Contracts.DTOs.Authentications.UnassignRole; + +public sealed class UnassignRoleResponse(string[] Roles); \ No newline at end of file diff --git a/AMREZ.EOP.Domain/Entities/Authentications/Role.cs b/AMREZ.EOP.Domain/Entities/Authentications/Role.cs index 123534d..b03210e 100644 --- a/AMREZ.EOP.Domain/Entities/Authentications/Role.cs +++ b/AMREZ.EOP.Domain/Entities/Authentications/Role.cs @@ -4,7 +4,7 @@ namespace AMREZ.EOP.Domain.Entities.Authentications; public sealed class Role : BaseEntity { - public string Code { get; set; } = default!; // system code, unique per tenant + public string Code { get; set; } = default!; public string Name { get; set; } = default!; public ICollection UserRoles { get; set; } = new List(); diff --git a/AMREZ.EOP.Domain/Entities/Common/MasterBase.cs b/AMREZ.EOP.Domain/Entities/Common/MasterBase.cs new file mode 100644 index 0000000..09eaf72 --- /dev/null +++ b/AMREZ.EOP.Domain/Entities/Common/MasterBase.cs @@ -0,0 +1,25 @@ +using AMREZ.EOP.Domain.Entities.Common; + +namespace AMREZ.EOP.Domain.Entities.MasterData; + +public abstract class MasterBase : BaseEntity +{ + + public string Scope { get; set; } = "global"; + + public string Code { get; set; } = null!; + public string Name { get; set; } = null!; + public Dictionary? NameI18n { get; set; } + + public Guid? OverridesGlobalId { get; set; } + + public bool IsActive { get; set; } = true; + public bool IsSystem { get; set; } = false; + + public Dictionary? Meta { get; set; } +} + +public abstract class MasterBlockBase : BaseEntity +{ + public Guid GlobalId { get; set; } +} \ No newline at end of file diff --git a/AMREZ.EOP.Domain/Entities/Customers/Address.cs b/AMREZ.EOP.Domain/Entities/Customers/Address.cs new file mode 100644 index 0000000..ef47420 --- /dev/null +++ b/AMREZ.EOP.Domain/Entities/Customers/Address.cs @@ -0,0 +1,22 @@ +using AMREZ.EOP.Domain.Entities.Common; + +namespace AMREZ.EOP.Domain.Entities.Customers; + +public sealed class Address : BaseEntity +{ + public string? Line1 { get; set; } + public string? Line2 { get; set; } + public string? Village { get; set; } + public string? Soi { get; set; } + public string? Road { get; set; } + public string? Subdistrict { get; set; } + public string? District { get; set; } + public string? Province { get; set; } + public string? PostalCode { get; set; } + public string CountryCode { get; set; } = "TH"; + public bool Verified { get; set; } + public double? GeoLat { get; set; } + public double? GeoLng { get; set; } + + public ICollection CustomerLinks { get; set; } = new List(); +} \ No newline at end of file diff --git a/AMREZ.EOP.Domain/Entities/Customers/CustomerAddress.cs b/AMREZ.EOP.Domain/Entities/Customers/CustomerAddress.cs new file mode 100644 index 0000000..e479488 --- /dev/null +++ b/AMREZ.EOP.Domain/Entities/Customers/CustomerAddress.cs @@ -0,0 +1,15 @@ +using AMREZ.EOP.Domain.Entities.Common; +using AMREZ.EOP.Domain.Shared.Customer; + +namespace AMREZ.EOP.Domain.Entities.Customers; + +public sealed class CustomerAddress : BaseEntity +{ + public Guid CustomerProfileId { get; set; } + public Guid AddressId { get; set; } + public AddressLabel Label { get; set; } + public bool IsDefault { get; set; } + + public CustomerProfile Customer { get; set; } = default!; + public Address Address { get; set; } = default!; +} \ No newline at end of file diff --git a/AMREZ.EOP.Domain/Entities/Customers/CustomerContact.cs b/AMREZ.EOP.Domain/Entities/Customers/CustomerContact.cs new file mode 100644 index 0000000..a298465 --- /dev/null +++ b/AMREZ.EOP.Domain/Entities/Customers/CustomerContact.cs @@ -0,0 +1,15 @@ +using AMREZ.EOP.Domain.Entities.Common; +using AMREZ.EOP.Domain.Shared.Customer; + +namespace AMREZ.EOP.Domain.Entities.Customers; + +public sealed class CustomerContact : BaseEntity +{ + public Guid CustomerProfileId { get; set; } + public ContactType Type { get; set; } + public string Value { get; set; } = default!; + public bool IsPrimary { get; set; } + public bool IsVerified { get; set; } + + public CustomerProfile Customer { get; set; } = default!; +} \ No newline at end of file diff --git a/AMREZ.EOP.Domain/Entities/Customers/CustomerProfile.cs b/AMREZ.EOP.Domain/Entities/Customers/CustomerProfile.cs new file mode 100644 index 0000000..870c3d9 --- /dev/null +++ b/AMREZ.EOP.Domain/Entities/Customers/CustomerProfile.cs @@ -0,0 +1,18 @@ +using AMREZ.EOP.Domain.Entities.Common; +using AMREZ.EOP.Domain.Shared.Customer; + +namespace AMREZ.EOP.Domain.Entities.Customers; + +public sealed class CustomerProfile : BaseEntity +{ + public PartyType Type { get; set; } + public string DisplayName { get; set; } = default!; + public CustomerStatus Status { get; set; } = CustomerStatus.Active; + + public PersonProfile? Person { get; set; } + public OrganizationProfile? Organization { get; set; } + + public ICollection Contacts { get; set; } = new List(); + public ICollection Addresses { get; set; } = new List(); + public ICollection Tags { get; set; } = new List(); +} \ No newline at end of file diff --git a/AMREZ.EOP.Domain/Entities/Customers/CustomerTag.cs b/AMREZ.EOP.Domain/Entities/Customers/CustomerTag.cs new file mode 100644 index 0000000..55ee1f0 --- /dev/null +++ b/AMREZ.EOP.Domain/Entities/Customers/CustomerTag.cs @@ -0,0 +1,11 @@ +using AMREZ.EOP.Domain.Entities.Common; + +namespace AMREZ.EOP.Domain.Entities.Customers; + +public sealed class CustomerTag : BaseEntity +{ + public Guid CustomerProfileId { get; set; } + public string Tag { get; set; } = default!; + + public CustomerProfile Customer { get; set; } = default!; +} \ No newline at end of file diff --git a/AMREZ.EOP.Domain/Entities/Customers/OrganizationProfile.cs b/AMREZ.EOP.Domain/Entities/Customers/OrganizationProfile.cs new file mode 100644 index 0000000..42272a2 --- /dev/null +++ b/AMREZ.EOP.Domain/Entities/Customers/OrganizationProfile.cs @@ -0,0 +1,17 @@ +using AMREZ.EOP.Domain.Entities.Common; + +namespace AMREZ.EOP.Domain.Entities.Customers; + +public sealed class OrganizationProfile : BaseEntity +{ + public Guid CustomerProfileId { get; set; } + + public string LegalNameTh { get; set; } = default!; + public string? LegalNameEn { get; set; } + public string? RegistrationNo { get; set; } + public string? TaxId13 { get; set; } + public string? BranchCode { get; set; } + public string? CompanyType { get; set; } + + public CustomerProfile Customer { get; set; } = default!; +} \ No newline at end of file diff --git a/AMREZ.EOP.Domain/Entities/Customers/PersonProfile.cs b/AMREZ.EOP.Domain/Entities/Customers/PersonProfile.cs new file mode 100644 index 0000000..37a7dc8 --- /dev/null +++ b/AMREZ.EOP.Domain/Entities/Customers/PersonProfile.cs @@ -0,0 +1,19 @@ +using AMREZ.EOP.Domain.Entities.Common; + +namespace AMREZ.EOP.Domain.Entities.Customers; + +public sealed class PersonProfile : BaseEntity +{ + public Guid CustomerProfileId { get; set; } + + public string? Prefix { get; set; } + public string? FirstNameTh { get; set; } + public string? LastNameTh { get; set; } + public string? FirstNameEn { get; set; } + public string? LastNameEn { get; set; } + public DateTime? BirthDate { get; set; } + public string? NationalId { get; set; } + public string? PassportNo { get; set; } + + public CustomerProfile Customer { get; set; } = default!; +} \ No newline at end of file diff --git a/AMREZ.EOP.Domain/Entities/MasterData/Allergen.cs b/AMREZ.EOP.Domain/Entities/MasterData/Allergen.cs new file mode 100644 index 0000000..7a9d52c --- /dev/null +++ b/AMREZ.EOP.Domain/Entities/MasterData/Allergen.cs @@ -0,0 +1,9 @@ +namespace AMREZ.EOP.Domain.Entities.MasterData; + +public class Allergen : MasterBase +{ +} + +public class AllergenBlock : MasterBlockBase +{ +} \ No newline at end of file diff --git a/AMREZ.EOP.Domain/Entities/MasterData/Brand.cs b/AMREZ.EOP.Domain/Entities/MasterData/Brand.cs new file mode 100644 index 0000000..4918e98 --- /dev/null +++ b/AMREZ.EOP.Domain/Entities/MasterData/Brand.cs @@ -0,0 +1,10 @@ +namespace AMREZ.EOP.Domain.Entities.MasterData; + +public class Brand : MasterBase +{ + public string? ExternalRef { get; set; } +} + +public class BrandBlock : MasterBlockBase +{ +} \ No newline at end of file diff --git a/AMREZ.EOP.Domain/Entities/MasterData/Category.cs b/AMREZ.EOP.Domain/Entities/MasterData/Category.cs new file mode 100644 index 0000000..8e18eaf --- /dev/null +++ b/AMREZ.EOP.Domain/Entities/MasterData/Category.cs @@ -0,0 +1,26 @@ +namespace AMREZ.EOP.Domain.Entities.MasterData; + +public class Category : MasterBase +{ + public Guid? ParentId { get; set; } + public Category? Parent { get; set; } + public ICollection Children { get; set; } = new List(); + public string? Path { get; set; } + public int SortOrder { get; set; } = 0; +} + +public class CategoryBlock : MasterBlockBase +{ +} + +public class CategoryExt +{ + public Guid CategoryId { get; set; } + public Category Category { get; set; } = null!; + public string? Slug { get; set; } + public string? SeoTitle { get; set; } + public string? SeoDescription { get; set; } + public string? ImageUrl { get; set; } + public Dictionary? ChannelVisibility { get; set; } + public Dictionary? FacetSchema { get; set; } +} \ No newline at end of file diff --git a/AMREZ.EOP.Domain/Entities/MasterData/ComplianceStatus.cs b/AMREZ.EOP.Domain/Entities/MasterData/ComplianceStatus.cs new file mode 100644 index 0000000..1140bcf --- /dev/null +++ b/AMREZ.EOP.Domain/Entities/MasterData/ComplianceStatus.cs @@ -0,0 +1,9 @@ +namespace AMREZ.EOP.Domain.Entities.MasterData; + +public class ComplianceStatus : MasterBase +{ +} + +public class ComplianceStatusBlock : MasterBlockBase +{ +} \ No newline at end of file diff --git a/AMREZ.EOP.Domain/Entities/MasterData/Country.cs b/AMREZ.EOP.Domain/Entities/MasterData/Country.cs new file mode 100644 index 0000000..b6472b6 --- /dev/null +++ b/AMREZ.EOP.Domain/Entities/MasterData/Country.cs @@ -0,0 +1,9 @@ +namespace AMREZ.EOP.Domain.Entities.MasterData; + +public class Country : MasterBase +{ +} + +public class CountryBlock : MasterBlockBase +{ +} \ No newline at end of file diff --git a/AMREZ.EOP.Domain/Entities/MasterData/Currency.cs b/AMREZ.EOP.Domain/Entities/MasterData/Currency.cs new file mode 100644 index 0000000..b986d25 --- /dev/null +++ b/AMREZ.EOP.Domain/Entities/MasterData/Currency.cs @@ -0,0 +1,10 @@ +namespace AMREZ.EOP.Domain.Entities.MasterData; + +public class Currency : MasterBase +{ + public byte Exponent { get; set; } = 2; +} + +public class CurrencyBlock : MasterBlockBase +{ +} \ No newline at end of file diff --git a/AMREZ.EOP.Domain/Entities/MasterData/DocControlStatus.cs b/AMREZ.EOP.Domain/Entities/MasterData/DocControlStatus.cs new file mode 100644 index 0000000..ddfe240 --- /dev/null +++ b/AMREZ.EOP.Domain/Entities/MasterData/DocControlStatus.cs @@ -0,0 +1,9 @@ +namespace AMREZ.EOP.Domain.Entities.MasterData; + +public class DocControlStatus : MasterBase +{ +} + +public class DocControlStatusBlock : MasterBlockBase +{ +} \ No newline at end of file diff --git a/AMREZ.EOP.Domain/Entities/MasterData/FuncTest.cs b/AMREZ.EOP.Domain/Entities/MasterData/FuncTest.cs new file mode 100644 index 0000000..d56e1ac --- /dev/null +++ b/AMREZ.EOP.Domain/Entities/MasterData/FuncTest.cs @@ -0,0 +1,9 @@ +namespace AMREZ.EOP.Domain.Entities.MasterData; + +public class FuncTest : MasterBase +{ +} + +public class FuncTestBlock : MasterBlockBase +{ +} \ No newline at end of file diff --git a/AMREZ.EOP.Domain/Entities/MasterData/HazardClass.cs b/AMREZ.EOP.Domain/Entities/MasterData/HazardClass.cs new file mode 100644 index 0000000..47c6be6 --- /dev/null +++ b/AMREZ.EOP.Domain/Entities/MasterData/HazardClass.cs @@ -0,0 +1,9 @@ +namespace AMREZ.EOP.Domain.Entities.MasterData; + +public class HazardClass : MasterBase +{ +} + +public class HazardClassBlock : MasterBlockBase +{ +} \ No newline at end of file diff --git a/AMREZ.EOP.Domain/Entities/MasterData/Language.cs b/AMREZ.EOP.Domain/Entities/MasterData/Language.cs new file mode 100644 index 0000000..581d6cc --- /dev/null +++ b/AMREZ.EOP.Domain/Entities/MasterData/Language.cs @@ -0,0 +1,9 @@ +namespace AMREZ.EOP.Domain.Entities.MasterData; + +public class Language : MasterBase +{ +} + +public class LanguageBlock : MasterBlockBase +{ +} \ No newline at end of file diff --git a/AMREZ.EOP.Domain/Entities/MasterData/Manufacturer.cs b/AMREZ.EOP.Domain/Entities/MasterData/Manufacturer.cs new file mode 100644 index 0000000..2e313d8 --- /dev/null +++ b/AMREZ.EOP.Domain/Entities/MasterData/Manufacturer.cs @@ -0,0 +1,10 @@ +namespace AMREZ.EOP.Domain.Entities.MasterData; + +public class Manufacturer : MasterBase +{ + public string? CountryCode { get; set; } +} + +public class ManufacturerBlock : MasterBlockBase +{ +} \ No newline at end of file diff --git a/AMREZ.EOP.Domain/Entities/MasterData/Market.cs b/AMREZ.EOP.Domain/Entities/MasterData/Market.cs new file mode 100644 index 0000000..fbbdb1a --- /dev/null +++ b/AMREZ.EOP.Domain/Entities/MasterData/Market.cs @@ -0,0 +1,9 @@ +namespace AMREZ.EOP.Domain.Entities.MasterData; + +public class Market : MasterBase +{ +} + +public class MarketBlock : MasterBlockBase +{ +} \ No newline at end of file diff --git a/AMREZ.EOP.Domain/Entities/MasterData/PackingGroup.cs b/AMREZ.EOP.Domain/Entities/MasterData/PackingGroup.cs new file mode 100644 index 0000000..66457ce --- /dev/null +++ b/AMREZ.EOP.Domain/Entities/MasterData/PackingGroup.cs @@ -0,0 +1,9 @@ +namespace AMREZ.EOP.Domain.Entities.MasterData; + +public class PackingGroup : MasterBase +{ +} + +public class PackingGroupBlock : MasterBlockBase +{ +} \ No newline at end of file diff --git a/AMREZ.EOP.Domain/Entities/MasterData/QaStage.cs b/AMREZ.EOP.Domain/Entities/MasterData/QaStage.cs new file mode 100644 index 0000000..eacba68 --- /dev/null +++ b/AMREZ.EOP.Domain/Entities/MasterData/QaStage.cs @@ -0,0 +1,9 @@ +namespace AMREZ.EOP.Domain.Entities.MasterData; + +public class QaStage : MasterBase +{ +} + +public class QaStageBlock : MasterBlockBase +{ +} \ No newline at end of file diff --git a/AMREZ.EOP.Domain/Entities/MasterData/QcStatus.cs b/AMREZ.EOP.Domain/Entities/MasterData/QcStatus.cs new file mode 100644 index 0000000..6c90827 --- /dev/null +++ b/AMREZ.EOP.Domain/Entities/MasterData/QcStatus.cs @@ -0,0 +1,9 @@ +namespace AMREZ.EOP.Domain.Entities.MasterData; + +public class QcStatus : MasterBase +{ +} + +public class QcStatusBlock : MasterBlockBase +{ +} \ No newline at end of file diff --git a/AMREZ.EOP.Domain/Entities/MasterData/RecallClass.cs b/AMREZ.EOP.Domain/Entities/MasterData/RecallClass.cs new file mode 100644 index 0000000..968b043 --- /dev/null +++ b/AMREZ.EOP.Domain/Entities/MasterData/RecallClass.cs @@ -0,0 +1,9 @@ +namespace AMREZ.EOP.Domain.Entities.MasterData; + +public class RecallClass : MasterBase +{ +} + +public class RecallClassBlock : MasterBlockBase +{ +} \ No newline at end of file diff --git a/AMREZ.EOP.Domain/Entities/MasterData/RiskClass.cs b/AMREZ.EOP.Domain/Entities/MasterData/RiskClass.cs new file mode 100644 index 0000000..51f6627 --- /dev/null +++ b/AMREZ.EOP.Domain/Entities/MasterData/RiskClass.cs @@ -0,0 +1,9 @@ +namespace AMREZ.EOP.Domain.Entities.MasterData; + +public class RiskClass : MasterBase +{ +} + +public class RiskClassBlock : MasterBlockBase +{ +} \ No newline at end of file diff --git a/AMREZ.EOP.Domain/Entities/MasterData/Route.cs b/AMREZ.EOP.Domain/Entities/MasterData/Route.cs new file mode 100644 index 0000000..fe506b5 --- /dev/null +++ b/AMREZ.EOP.Domain/Entities/MasterData/Route.cs @@ -0,0 +1,9 @@ +namespace AMREZ.EOP.Domain.Entities.MasterData; + +public class Route : MasterBase +{ +} + +public class RouteBlock : MasterBlockBase +{ +} \ No newline at end of file diff --git a/AMREZ.EOP.Domain/Entities/MasterData/RxSchedule.cs b/AMREZ.EOP.Domain/Entities/MasterData/RxSchedule.cs new file mode 100644 index 0000000..b6966aa --- /dev/null +++ b/AMREZ.EOP.Domain/Entities/MasterData/RxSchedule.cs @@ -0,0 +1,9 @@ +namespace AMREZ.EOP.Domain.Entities.MasterData; + +public class RxSchedule : MasterBase +{ +} + +public class RxScheduleBlock : MasterBlockBase +{ +} \ No newline at end of file diff --git a/AMREZ.EOP.Domain/Entities/MasterData/Species.cs b/AMREZ.EOP.Domain/Entities/MasterData/Species.cs new file mode 100644 index 0000000..f0e77f1 --- /dev/null +++ b/AMREZ.EOP.Domain/Entities/MasterData/Species.cs @@ -0,0 +1,9 @@ +namespace AMREZ.EOP.Domain.Entities.MasterData; + +public class Species : MasterBase +{ +} + +public class SpeciesBlock : MasterBlockBase +{ +} \ No newline at end of file diff --git a/AMREZ.EOP.Domain/Entities/MasterData/StabilityStatus.cs b/AMREZ.EOP.Domain/Entities/MasterData/StabilityStatus.cs new file mode 100644 index 0000000..08d927e --- /dev/null +++ b/AMREZ.EOP.Domain/Entities/MasterData/StabilityStatus.cs @@ -0,0 +1,9 @@ +namespace AMREZ.EOP.Domain.Entities.MasterData; + +public class StabilityStatus : MasterBase +{ +} + +public class StabilityStatusBlock : MasterBlockBase +{ +} \ No newline at end of file diff --git a/AMREZ.EOP.Domain/Entities/MasterData/SterilizationMethod.cs b/AMREZ.EOP.Domain/Entities/MasterData/SterilizationMethod.cs new file mode 100644 index 0000000..319fcbf --- /dev/null +++ b/AMREZ.EOP.Domain/Entities/MasterData/SterilizationMethod.cs @@ -0,0 +1,9 @@ +namespace AMREZ.EOP.Domain.Entities.MasterData; + +public class SterilizationMethod : MasterBase +{ +} + +public class SterilizationMethodBlock : MasterBlockBase +{ +} \ No newline at end of file diff --git a/AMREZ.EOP.Domain/Entities/MasterData/Uom.cs b/AMREZ.EOP.Domain/Entities/MasterData/Uom.cs new file mode 100644 index 0000000..241c20a --- /dev/null +++ b/AMREZ.EOP.Domain/Entities/MasterData/Uom.cs @@ -0,0 +1,11 @@ +namespace AMREZ.EOP.Domain.Entities.MasterData; + +public class Uom : MasterBase +{ + public string? BaseCode { get; set; } + public decimal? SiFactor { get; set; } +} + +public class UomBlock : MasterBlockBase +{ +} \ No newline at end of file diff --git a/AMREZ.EOP.Domain/Entities/MasterData/Vvm.cs b/AMREZ.EOP.Domain/Entities/MasterData/Vvm.cs new file mode 100644 index 0000000..aaf9d6c --- /dev/null +++ b/AMREZ.EOP.Domain/Entities/MasterData/Vvm.cs @@ -0,0 +1,9 @@ +namespace AMREZ.EOP.Domain.Entities.MasterData; + +public class Vvm : MasterBase +{ +} + +public class VvmBlock : MasterBlockBase +{ +} \ No newline at end of file diff --git a/AMREZ.EOP.Domain/Shared/Customer/AddressLabel.cs b/AMREZ.EOP.Domain/Shared/Customer/AddressLabel.cs new file mode 100644 index 0000000..b476bab --- /dev/null +++ b/AMREZ.EOP.Domain/Shared/Customer/AddressLabel.cs @@ -0,0 +1,9 @@ +namespace AMREZ.EOP.Domain.Shared.Customer; + +public enum AddressLabel +{ + Billing, + Shipping, + Registered, + Other +} \ No newline at end of file diff --git a/AMREZ.EOP.Domain/Shared/Customer/ContactType.cs b/AMREZ.EOP.Domain/Shared/Customer/ContactType.cs new file mode 100644 index 0000000..0030d55 --- /dev/null +++ b/AMREZ.EOP.Domain/Shared/Customer/ContactType.cs @@ -0,0 +1,11 @@ +namespace AMREZ.EOP.Domain.Shared.Customer; + +public enum ContactType +{ + Email, + Phone, + Line, + Whatsapp, + WeChat, + Other +} \ No newline at end of file diff --git a/AMREZ.EOP.Domain/Shared/Customer/CustomerStatus.cs b/AMREZ.EOP.Domain/Shared/Customer/CustomerStatus.cs new file mode 100644 index 0000000..16e524b --- /dev/null +++ b/AMREZ.EOP.Domain/Shared/Customer/CustomerStatus.cs @@ -0,0 +1,8 @@ +namespace AMREZ.EOP.Domain.Shared.Customer; + +public enum CustomerStatus +{ + Active, + Inactive, + Blacklisted +} \ No newline at end of file diff --git a/AMREZ.EOP.Domain/Shared/Customer/PartyType.cs b/AMREZ.EOP.Domain/Shared/Customer/PartyType.cs new file mode 100644 index 0000000..8616033 --- /dev/null +++ b/AMREZ.EOP.Domain/Shared/Customer/PartyType.cs @@ -0,0 +1,7 @@ +namespace AMREZ.EOP.Domain.Shared.Customer; + +public enum PartyType +{ + Person, + Organization +} \ No newline at end of file diff --git a/AMREZ.EOP.Infrastructures/Data/AppDbContext.cs b/AMREZ.EOP.Infrastructures/Data/AppDbContext.cs index 0ca8286..a8df3cb 100644 --- a/AMREZ.EOP.Infrastructures/Data/AppDbContext.cs +++ b/AMREZ.EOP.Infrastructures/Data/AppDbContext.cs @@ -1,15 +1,22 @@ +using System.Text.Json; using AMREZ.EOP.Domain.Entities.Authentications; using AMREZ.EOP.Domain.Entities.Common; +using AMREZ.EOP.Domain.Entities.Customers; using AMREZ.EOP.Domain.Entities.HumanResources; +using AMREZ.EOP.Domain.Entities.MasterData; using AMREZ.EOP.Domain.Entities.Tenancy; using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.ChangeTracking; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Route = AMREZ.EOP.Domain.Entities.MasterData.Route; namespace AMREZ.EOP.Infrastructures.Data; public class AppDbContext : DbContext { - public AppDbContext(DbContextOptions options) : base(options) { } + public AppDbContext(DbContextOptions options) : base(options) + { + } // ===== Auth ===== public DbSet Users => Set(); @@ -36,14 +43,170 @@ public class AppDbContext : DbContext public DbSet Tenants => Set(); public DbSet TenantDomains => Set(); + // ===== Customers ===== + public DbSet CustomerProfiles => Set(); + public DbSet PersonProfiles => Set(); + public DbSet OrganizationProfiles => Set(); + public DbSet
Addresses => Set
(); + public DbSet CustomerAddresses => Set(); + public DbSet CustomerContacts => Set(); + public DbSet CustomerTags => Set(); + + // ===== Master Data ===== + public DbSet Brands => Set(); + public DbSet BrandBlocks => Set(); + + public DbSet Categories => Set(); + public DbSet CategoryBlocks => Set(); + public DbSet CategoryExts => Set(); + + public DbSet Uoms => Set(); + public DbSet UomBlocks => Set(); + + public DbSet Currencies => Set(); + public DbSet CurrencyBlocks => Set(); + + public DbSet Countries => Set(); + public DbSet CountryBlocks => Set(); + + public DbSet Manufacturers => Set(); + public DbSet ManufacturerBlocks => Set(); + + public DbSet Markets => Set(); + public DbSet MarketBlocks => Set(); + + public DbSet Languages => Set(); + public DbSet LanguageBlocks => Set(); + + public DbSet ComplianceStatuses => Set(); + public DbSet ComplianceStatusBlocks => Set(); + + public DbSet QaStages => Set(); + public DbSet QaStageBlocks => Set(); + + public DbSet Routes => Set(); + public DbSet RouteBlocks => Set(); + + public DbSet RxSchedules => Set(); + public DbSet RxScheduleBlocks => Set(); + + public DbSet StabilityStatuses => Set(); + public DbSet StabilityStatusBlocks => Set(); + + public DbSet RiskClasses => Set(); + public DbSet RiskClassBlocks => Set(); + + public DbSet SterilizationMethods => Set(); + public DbSet SterilizationMethodBlocks => Set(); + + public DbSet QcStatuses => Set(); + public DbSet QcStatusBlocks => Set(); + + public DbSet DocControlStatuses => Set(); + public DbSet DocControlStatusBlocks => Set(); + + public DbSet RecallClasses => Set(); + public DbSet RecallClassBlocks => Set(); + + public DbSet PackingGroups => Set(); + public DbSet PackingGroupBlocks => Set(); + + public DbSet Vvms => Set(); + public DbSet VvmBlocks => Set(); + + public DbSet FuncTests => Set(); + public DbSet FuncTestBlocks => Set(); + + public DbSet HazardClasses => Set(); + public DbSet HazardClassBlocks => Set(); + + public DbSet Species => Set(); + public DbSet SpeciesBlocks => Set(); + + public DbSet Allergens => Set(); + public DbSet AllergenBlocks => Set(); + protected override void OnModelCreating(ModelBuilder model) { + // JSON converters/comparers + var jsonOpts = new JsonSerializerOptions(JsonSerializerDefaults.Web); + + var dictStrConverter = new ValueConverter?, string?>( + v => v == null ? null : JsonSerializer.Serialize(v, jsonOpts), + v => string.IsNullOrWhiteSpace(v) + ? null + : JsonSerializer.Deserialize>(v!, jsonOpts)!); + + var dictStrComparer = new ValueComparer?>( + (l, r) => JsonSerializer.Serialize(l, jsonOpts) == JsonSerializer.Serialize(r, jsonOpts), + v => v == null ? 0 : JsonSerializer.Serialize(v, jsonOpts).GetHashCode(), + v => v == null + ? null + : JsonSerializer.Deserialize>(JsonSerializer.Serialize(v, jsonOpts), + jsonOpts)); + + var dictObjConverter = new ValueConverter?, string?>( + v => v == null ? null : JsonSerializer.Serialize(v, jsonOpts), + v => string.IsNullOrWhiteSpace(v) + ? null + : JsonSerializer.Deserialize>(v!, jsonOpts)!); + + var dictObjComparer = new ValueComparer?>( + (l, r) => JsonSerializer.Serialize(l, jsonOpts) == JsonSerializer.Serialize(r, jsonOpts), + v => v == null ? 0 : JsonSerializer.Serialize(v, jsonOpts).GetHashCode(), + v => v == null + ? null + : JsonSerializer.Deserialize>(JsonSerializer.Serialize(v, jsonOpts), + jsonOpts)); + + void ConfigureMasterBase(string table, string schema = "master") + where TEntity : MasterBase + { + var b = model.Entity(); + b.ToTable(table, schema); + b.HasKey(x => x.Id); + b.HasAlternateKey(x => new { x.TenantId, x.Id }); + + b.Property(x => x.Scope).IsRequired().HasDefaultValue("global"); + b.Property(x => x.Code).IsRequired(); + b.Property(x => x.Name).IsRequired(); + b.Property(x => x.IsActive).HasDefaultValue(true); + b.Property(x => x.IsSystem).HasDefaultValue(false); + + var nameI18nProp = b.Property(x => x.NameI18n).HasConversion(dictStrConverter); + nameI18nProp.Metadata.SetValueComparer(dictStrComparer); + nameI18nProp.HasColumnType("jsonb"); + + var metaProp = b.Property(x => x.Meta).HasConversion(dictObjConverter); + metaProp.Metadata.SetValueComparer(dictObjComparer); + metaProp.HasColumnType("jsonb"); + + b.HasIndex(x => new { x.Scope, x.TenantId, x.Code }).IsUnique(); + // b.HasIndex(x => new { x.TenantId, x.OverridesGlobalId }).IsUnique().HasFilter("\"OverridesGlobalId\" IS NOT NULL"); + } + + void ConfigureBlockBase(string table, string schema = "master") + where TBlock : MasterBlockBase + where TMaster : MasterBase + { + var b = model.Entity(); + b.ToTable(table, schema); + b.HasKey(x => x.Id); + b.HasIndex(x => new { x.TenantId, x.GlobalId }).IsUnique(); + b.HasIndex(x => x.GlobalId); + + b.HasOne() + .WithMany() + .HasForeignKey(x => x.GlobalId) + .OnDelete(DeleteBehavior.Cascade); + } + // ====== Tenancy (meta) ====== model.Entity(b => { b.ToTable("tenants", schema: "meta"); - b.HasKey(x => x.TenantKey); // PK = key (slug) - b.HasAlternateKey(x => x.TenantId); // AK = GUID + b.HasKey(x => x.TenantKey); + b.HasAlternateKey(x => x.TenantId); b.HasIndex(x => x.TenantId).IsUnique(); b.Property(x => x.TenantKey).HasMaxLength(128).IsRequired(); @@ -51,8 +214,7 @@ public class AppDbContext : DbContext b.Property(x => x.ConnectionString); b.Property(x => x.Mode).IsRequired(); b.Property(x => x.IsActive).HasDefaultValue(true); - b.Property(x => x.UpdatedAtUtc) - .HasColumnName("updated_at_utc") + b.Property(x => x.UpdatedAtUtc).HasColumnName("updated_at_utc") .HasDefaultValueSql("now() at time zone 'utc'"); b.HasIndex(x => x.IsActive); }); @@ -62,11 +224,10 @@ public class AppDbContext : DbContext b.ToTable("tenant_domains", schema: "meta"); b.HasKey(x => x.Domain); b.Property(x => x.Domain).HasMaxLength(253).IsRequired(); - b.Property(x => x.TenantKey).HasMaxLength(128); // optional + b.Property(x => x.TenantKey).HasMaxLength(128); b.Property(x => x.IsPlatformBaseDomain).HasDefaultValue(false); b.Property(x => x.IsActive).HasDefaultValue(true); - b.Property(x => x.UpdatedAtUtc) - .HasColumnName("updated_at_utc") + b.Property(x => x.UpdatedAtUtc).HasColumnName("updated_at_utc") .HasDefaultValueSql("now() at time zone 'utc'"); b.HasIndex(x => x.TenantKey); @@ -84,8 +245,6 @@ public class AppDbContext : DbContext { b.ToTable("users"); b.HasKey(x => x.Id); - - // principal key สำหรับ composite FK จากลูก ๆ b.HasAlternateKey(u => new { u.TenantId, u.Id }); b.Property(x => x.PasswordHash).IsRequired(); @@ -105,14 +264,13 @@ public class AppDbContext : DbContext b.HasIndex(x => new { x.TenantId, x.Type, x.Identifier }).IsUnique(); b.HasIndex(x => new { x.TenantId, x.UserId, x.Type, x.IsPrimary }) - .HasDatabaseName("ix_user_identity_primary_per_type"); + .HasDatabaseName("ix_user_identity_primary_per_type"); - // (TenantId, UserId) -> User.(TenantId, Id) b.HasOne(i => i.User) - .WithMany(u => u.Identities) - .HasForeignKey(i => new { i.TenantId, i.UserId }) - .HasPrincipalKey(nameof(User.TenantId), nameof(User.Id)) - .OnDelete(DeleteBehavior.Cascade); + .WithMany(u => u.Identities) + .HasForeignKey(i => new { i.TenantId, i.UserId }) + .HasPrincipalKey(nameof(User.TenantId), nameof(User.Id)) + .OnDelete(DeleteBehavior.Cascade); }); model.Entity(b => @@ -125,10 +283,10 @@ public class AppDbContext : DbContext b.HasIndex(x => new { x.TenantId, x.UserId }); b.HasOne(x => x.User) - .WithMany(u => u.MfaFactors) - .HasForeignKey(x => new { x.TenantId, x.UserId }) - .HasPrincipalKey(nameof(User.TenantId), nameof(User.Id)) - .OnDelete(DeleteBehavior.Cascade); + .WithMany(u => u.MfaFactors) + .HasForeignKey(x => new { x.TenantId, x.UserId }) + .HasPrincipalKey(nameof(User.TenantId), nameof(User.Id)) + .OnDelete(DeleteBehavior.Cascade); }); model.Entity(b => @@ -141,10 +299,10 @@ public class AppDbContext : DbContext b.HasIndex(x => new { x.TenantId, x.DeviceId }); b.HasOne(x => x.User) - .WithMany(u => u.Sessions) - .HasForeignKey(x => new { x.TenantId, x.UserId }) - .HasPrincipalKey(nameof(User.TenantId), nameof(User.Id)) - .OnDelete(DeleteBehavior.Cascade); + .WithMany(u => u.Sessions) + .HasForeignKey(x => new { x.TenantId, x.UserId }) + .HasPrincipalKey(nameof(User.TenantId), nameof(User.Id)) + .OnDelete(DeleteBehavior.Cascade); }); model.Entity(b => @@ -155,10 +313,10 @@ public class AppDbContext : DbContext b.HasIndex(x => new { x.TenantId, x.UserId, x.ChangedAt }); b.HasOne(x => x.User) - .WithMany(u => u.PasswordHistories) - .HasForeignKey(x => new { x.TenantId, x.UserId }) - .HasPrincipalKey(nameof(User.TenantId), nameof(User.Id)) - .OnDelete(DeleteBehavior.Cascade); + .WithMany(u => u.PasswordHistories) + .HasForeignKey(x => new { x.TenantId, x.UserId }) + .HasPrincipalKey(nameof(User.TenantId), nameof(User.Id)) + .OnDelete(DeleteBehavior.Cascade); }); model.Entity(b => @@ -171,10 +329,10 @@ public class AppDbContext : DbContext b.HasIndex(x => new { x.TenantId, x.Provider, x.Subject }).IsUnique(); b.HasOne(x => x.User) - .WithMany(u => u.ExternalAccounts) - .HasForeignKey(x => new { x.TenantId, x.UserId }) - .HasPrincipalKey(nameof(User.TenantId), nameof(User.Id)) - .OnDelete(DeleteBehavior.Cascade); + .WithMany(u => u.ExternalAccounts) + .HasForeignKey(x => new { x.TenantId, x.UserId }) + .HasPrincipalKey(nameof(User.TenantId), nameof(User.Id)) + .OnDelete(DeleteBehavior.Cascade); }); model.Entity(b => @@ -209,16 +367,16 @@ public class AppDbContext : DbContext b.HasIndex(x => new { x.TenantId, x.UserId, x.RoleId }).IsUnique(); b.HasOne() - .WithMany() - .HasForeignKey(x => new { x.TenantId, x.UserId }) - .HasPrincipalKey(nameof(User.TenantId), nameof(User.Id)) - .OnDelete(DeleteBehavior.Cascade); + .WithMany() + .HasForeignKey(x => new { x.TenantId, x.UserId }) + .HasPrincipalKey(nameof(User.TenantId), nameof(User.Id)) + .OnDelete(DeleteBehavior.Cascade); b.HasOne() - .WithMany() - .HasForeignKey(x => new { x.TenantId, x.RoleId }) - .HasPrincipalKey(nameof(Role.TenantId), nameof(Role.Id)) - .OnDelete(DeleteBehavior.Cascade); + .WithMany() + .HasForeignKey(x => new { x.TenantId, x.RoleId }) + .HasPrincipalKey(nameof(Role.TenantId), nameof(Role.Id)) + .OnDelete(DeleteBehavior.Cascade); }); model.Entity(b => @@ -229,16 +387,16 @@ public class AppDbContext : DbContext b.HasIndex(x => new { x.TenantId, x.RoleId, x.PermissionId }).IsUnique(); b.HasOne() - .WithMany() - .HasForeignKey(x => new { x.TenantId, x.RoleId }) - .HasPrincipalKey(nameof(Role.TenantId), nameof(Role.Id)) - .OnDelete(DeleteBehavior.Cascade); + .WithMany() + .HasForeignKey(x => new { x.TenantId, x.RoleId }) + .HasPrincipalKey(nameof(Role.TenantId), nameof(Role.Id)) + .OnDelete(DeleteBehavior.Cascade); b.HasOne() - .WithMany() - .HasForeignKey(x => new { x.TenantId, x.PermissionId }) - .HasPrincipalKey(nameof(Permission.TenantId), nameof(Permission.Id)) - .OnDelete(DeleteBehavior.Cascade); + .WithMany() + .HasForeignKey(x => new { x.TenantId, x.PermissionId }) + .HasPrincipalKey(nameof(Permission.TenantId), nameof(Permission.Id)) + .OnDelete(DeleteBehavior.Cascade); }); // ====== HR ====== @@ -256,7 +414,7 @@ public class AppDbContext : DbContext b.HasOne(x => x.User) .WithOne() .HasForeignKey(x => new { x.TenantId, x.UserId }) - .HasPrincipalKey(u => new { u.TenantId, u.Id }) // <-- เปลี่ยนตรงนี้ + .HasPrincipalKey(u => new { u.TenantId, u.Id }) .OnDelete(DeleteBehavior.Cascade); }); @@ -272,10 +430,10 @@ public class AppDbContext : DbContext b.HasIndex(x => new { x.TenantId, x.Code }).IsUnique(); b.HasOne(x => x.Parent) - .WithMany(x => x.Children) - .HasForeignKey(x => new { x.TenantId, x.ParentDepartmentId }) - .HasPrincipalKey(nameof(Department.TenantId), nameof(Department.Id)) - .OnDelete(DeleteBehavior.Restrict); + .WithMany(x => x.Children) + .HasForeignKey(x => new { x.TenantId, x.ParentDepartmentId }) + .HasPrincipalKey(nameof(Department.TenantId), nameof(Department.Id)) + .OnDelete(DeleteBehavior.Restrict); }); model.Entity(b => @@ -301,22 +459,22 @@ public class AppDbContext : DbContext b.HasIndex(x => new { x.TenantId, x.UserProfileId, x.StartDate }); b.HasOne(x => x.UserProfile) - .WithMany(p => p.Employments) - .HasForeignKey(x => new { x.TenantId, x.UserProfileId }) - .HasPrincipalKey(nameof(UserProfile.TenantId), nameof(UserProfile.Id)) - .OnDelete(DeleteBehavior.Cascade); + .WithMany(p => p.Employments) + .HasForeignKey(x => new { x.TenantId, x.UserProfileId }) + .HasPrincipalKey(nameof(UserProfile.TenantId), nameof(UserProfile.Id)) + .OnDelete(DeleteBehavior.Cascade); b.HasOne(x => x.Department) - .WithMany() - .HasForeignKey(x => new { x.TenantId, x.DepartmentId }) - .HasPrincipalKey(nameof(Department.TenantId), nameof(Department.Id)) - .OnDelete(DeleteBehavior.Restrict); + .WithMany() + .HasForeignKey(x => new { x.TenantId, x.DepartmentId }) + .HasPrincipalKey(nameof(Department.TenantId), nameof(Department.Id)) + .OnDelete(DeleteBehavior.Restrict); b.HasOne(x => x.Position) - .WithMany() - .HasForeignKey(x => new { x.TenantId, x.PositionId }) - .HasPrincipalKey(nameof(Position.TenantId), nameof(Position.Id)) - .OnDelete(DeleteBehavior.Restrict); + .WithMany() + .HasForeignKey(x => new { x.TenantId, x.PositionId }) + .HasPrincipalKey(nameof(Position.TenantId), nameof(Position.Id)) + .OnDelete(DeleteBehavior.Restrict); }); model.Entity(b => @@ -330,10 +488,10 @@ public class AppDbContext : DbContext b.Property(x => x.Country).IsRequired().HasMaxLength(64); b.HasOne(x => x.UserProfile) - .WithMany(p => p.Addresses) - .HasForeignKey(x => new { x.TenantId, x.UserProfileId }) - .HasPrincipalKey(nameof(UserProfile.TenantId), nameof(UserProfile.Id)) - .OnDelete(DeleteBehavior.Cascade); + .WithMany(p => p.Addresses) + .HasForeignKey(x => new { x.TenantId, x.UserProfileId }) + .HasPrincipalKey(nameof(UserProfile.TenantId), nameof(UserProfile.Id)) + .OnDelete(DeleteBehavior.Cascade); b.HasIndex(x => new { x.TenantId, x.UserProfileId, x.IsPrimary }); }); @@ -347,10 +505,10 @@ public class AppDbContext : DbContext b.Property(x => x.Relationship).IsRequired().HasMaxLength(64); b.HasOne(x => x.UserProfile) - .WithMany(p => p.EmergencyContacts) - .HasForeignKey(x => new { x.TenantId, x.UserProfileId }) - .HasPrincipalKey(nameof(UserProfile.TenantId), nameof(UserProfile.Id)) - .OnDelete(DeleteBehavior.Cascade); + .WithMany(p => p.EmergencyContacts) + .HasForeignKey(x => new { x.TenantId, x.UserProfileId }) + .HasPrincipalKey(nameof(UserProfile.TenantId), nameof(UserProfile.Id)) + .OnDelete(DeleteBehavior.Cascade); b.HasIndex(x => new { x.TenantId, x.UserProfileId, x.IsPrimary }); }); @@ -365,28 +523,280 @@ public class AppDbContext : DbContext b.Property(x => x.AccountHolder).IsRequired().HasMaxLength(128); b.HasOne(x => x.UserProfile) - .WithMany(p => p.BankAccounts) - .HasForeignKey(x => new { x.TenantId, x.UserProfileId }) - .HasPrincipalKey(nameof(UserProfile.TenantId), nameof(UserProfile.Id)) - .OnDelete(DeleteBehavior.Cascade); + .WithMany(p => p.BankAccounts) + .HasForeignKey(x => new { x.TenantId, x.UserProfileId }) + .HasPrincipalKey(nameof(UserProfile.TenantId), nameof(UserProfile.Id)) + .OnDelete(DeleteBehavior.Cascade); b.HasIndex(x => new { x.TenantId, x.UserProfileId, x.IsPrimary }); }); - // ====== Enums as ints ====== + // ====== Customers ====== + model.Entity(b => + { + b.ToTable("customer_profiles"); + b.HasKey(x => x.Id); + b.HasAlternateKey(x => new { x.TenantId, x.Id }); + + b.Property(x => x.DisplayName).HasMaxLength(256).IsRequired(); + b.Property(x => x.Type).IsRequired(); + b.Property(x => x.Status).IsRequired(); + + b.HasIndex(x => new { x.TenantId, x.DisplayName }); + + b.HasMany(x => x.Contacts) + .WithOne(x => x.Customer) + .HasForeignKey(x => new { x.TenantId, x.CustomerProfileId }) + .HasPrincipalKey(x => new { x.TenantId, x.Id }) + .OnDelete(DeleteBehavior.Cascade); + + b.HasMany(x => x.Addresses) + .WithOne(x => x.Customer) + .HasForeignKey(x => new { x.TenantId, x.CustomerProfileId }) + .HasPrincipalKey(x => new { x.TenantId, x.Id }) + .OnDelete(DeleteBehavior.Cascade); + + b.HasMany(x => x.Tags) + .WithOne(x => x.Customer) + .HasForeignKey(x => new { x.TenantId, x.CustomerProfileId }) + .HasPrincipalKey(x => new { x.TenantId, x.Id }) + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne(x => x.Person) + .WithOne(x => x.Customer) + .HasForeignKey(x => new { x.TenantId, x.CustomerProfileId }) + .HasPrincipalKey(x => new { x.TenantId, x.Id }) + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne(x => x.Organization) + .WithOne(x => x.Customer) + .HasForeignKey(x => new { x.TenantId, x.CustomerProfileId }) + .HasPrincipalKey(x => new { x.TenantId, x.Id }) + .OnDelete(DeleteBehavior.Cascade); + }); + + model.Entity(b => + { + b.ToTable("person_profiles"); + b.HasKey(x => x.Id); + + b.Property(x => x.Prefix).HasMaxLength(32); + b.Property(x => x.FirstNameTh).HasMaxLength(128); + b.Property(x => x.LastNameTh).HasMaxLength(128); + b.Property(x => x.FirstNameEn).HasMaxLength(128); + b.Property(x => x.LastNameEn).HasMaxLength(128); + b.Property(x => x.NationalId).HasMaxLength(13); + b.Property(x => x.PassportNo).HasMaxLength(32); + + b.HasIndex(x => new { x.TenantId, x.CustomerProfileId }).IsUnique(); + }); + + model.Entity(b => + { + b.ToTable("organization_profiles"); + b.HasKey(x => x.Id); + + b.Property(x => x.LegalNameTh).HasMaxLength(256).IsRequired(); + b.Property(x => x.LegalNameEn).HasMaxLength(256); + b.Property(x => x.RegistrationNo).HasMaxLength(64); + b.Property(x => x.TaxId13).HasMaxLength(13); + b.Property(x => x.BranchCode).HasMaxLength(5); + b.Property(x => x.CompanyType).HasMaxLength(64); + + b.HasIndex(x => new { x.TenantId, x.CustomerProfileId }).IsUnique(); + b.HasIndex(x => new { x.TenantId, x.TaxId13, x.BranchCode }).IsUnique() + .HasFilter("\"TaxId13\" IS NOT NULL"); + }); + + model.Entity(b => + { + b.ToTable("customer_contacts"); + b.HasKey(x => x.Id); + + b.Property(x => x.Type).IsRequired(); + b.Property(x => x.Value).HasMaxLength(256).IsRequired(); + b.Property(x => x.IsPrimary).HasDefaultValue(false); + b.Property(x => x.IsVerified).HasDefaultValue(false); + + b.HasIndex(x => new { x.TenantId, x.CustomerProfileId, x.Type }); + b.HasIndex(x => new { x.TenantId, x.CustomerProfileId, x.Type, x.IsPrimary }) + .HasDatabaseName("ux_customer_contact_primary_per_type") + .IsUnique() + .HasFilter("\"IsPrimary\" = TRUE"); + }); + + model.Entity
(b => + { + b.ToTable("addresses"); + b.HasKey(x => x.Id); + b.HasAlternateKey(x => new { x.TenantId, x.Id }); + + b.Property(x => x.Line1).HasMaxLength(256); + b.Property(x => x.Line2).HasMaxLength(256); + b.Property(x => x.Village).HasMaxLength(128); + b.Property(x => x.Soi).HasMaxLength(128); + b.Property(x => x.Road).HasMaxLength(128); + b.Property(x => x.Subdistrict).HasMaxLength(128); + b.Property(x => x.District).HasMaxLength(128); + b.Property(x => x.Province).HasMaxLength(128); + b.Property(x => x.PostalCode).HasMaxLength(10); + b.Property(x => x.CountryCode).HasMaxLength(2).IsRequired(); + }); + + model.Entity(b => + { + b.ToTable("customer_addresses"); + b.HasKey(x => x.Id); + + b.Property(x => x.Label).IsRequired(); + b.Property(x => x.IsDefault).HasDefaultValue(false); + + b.HasIndex(x => new { x.TenantId, x.CustomerProfileId, x.Label }); + + b.HasOne(x => x.Customer) + .WithMany(c => c.Addresses) + .HasForeignKey(x => new { x.TenantId, x.CustomerProfileId }) + .HasPrincipalKey(c => new { c.TenantId, c.Id }) + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne(x => x.Address) + .WithMany(a => a.CustomerLinks) + .HasForeignKey(x => new { x.TenantId, x.AddressId }) + .HasPrincipalKey(a => new { a.TenantId, a.Id }) + .OnDelete(DeleteBehavior.Cascade); + + b.HasIndex(x => new { x.TenantId, x.CustomerProfileId, x.Label, x.IsDefault }) + .HasDatabaseName("ux_default_customer_address_per_label") + .IsUnique() + .HasFilter("\"IsDefault\" = TRUE"); + }); + + model.Entity(b => + { + b.ToTable("customer_tags"); + b.HasKey(x => x.Id); + b.Property(x => x.Tag).HasMaxLength(64).IsRequired(); + b.HasIndex(x => new { x.TenantId, x.CustomerProfileId, x.Tag }).IsUnique(); + }); + + // ===== Master: mapping ===== + ConfigureMasterBase("brands"); + ConfigureBlockBase("brand_blocks"); + + model.Entity(b => + { + ConfigureMasterBase("categories"); + b.HasOne(x => x.Parent) + .WithMany(x => x.Children) + .HasForeignKey(x => new { x.TenantId, x.ParentId }) + .HasPrincipalKey(x => new { x.TenantId, x.Id }) + .OnDelete(DeleteBehavior.Restrict); + + b.HasIndex(x => x.ParentId); + b.HasIndex(x => x.Path); + b.HasIndex(x => new { x.Scope, x.TenantId, x.SortOrder }); + }); + ConfigureBlockBase("category_blocks"); + + model.Entity(b => + { + b.ToTable("category_exts", "master"); + b.HasKey(x => x.CategoryId); + b.HasOne(x => x.Category).WithOne().HasForeignKey(x => x.CategoryId) + .OnDelete(DeleteBehavior.Cascade); + + var chVisProp = b.Property(x => x.ChannelVisibility).HasConversion(dictObjConverter); + chVisProp.Metadata.SetValueComparer(dictObjComparer); + chVisProp.HasColumnType("jsonb"); + + var facetSchemaProp = b.Property(x => x.FacetSchema).HasConversion(dictObjConverter); + facetSchemaProp.Metadata.SetValueComparer(dictObjComparer); + facetSchemaProp.HasColumnType("jsonb"); + }); + + ConfigureMasterBase("uoms"); + ConfigureBlockBase("uom_blocks"); + + ConfigureMasterBase("currencies"); + ConfigureBlockBase("currency_blocks"); + + ConfigureMasterBase("countries"); + ConfigureBlockBase("country_blocks"); + + ConfigureMasterBase("manufacturers"); + ConfigureBlockBase("manufacturer_blocks"); + + ConfigureMasterBase("markets"); + ConfigureBlockBase("market_blocks"); + + ConfigureMasterBase("languages"); + ConfigureBlockBase("language_blocks"); + + ConfigureMasterBase("compliance_statuses"); + ConfigureBlockBase("compliance_status_blocks"); + + ConfigureMasterBase("qa_stages"); + ConfigureBlockBase("qa_stage_blocks"); + + ConfigureMasterBase("routes"); + ConfigureBlockBase("route_blocks"); + + ConfigureMasterBase("rx_schedules"); + ConfigureBlockBase("rx_schedule_blocks"); + + ConfigureMasterBase("stability_statuses"); + ConfigureBlockBase("stability_status_blocks"); + + ConfigureMasterBase("risk_classes"); + ConfigureBlockBase("risk_class_blocks"); + + ConfigureMasterBase("sterilization_methods"); + ConfigureBlockBase("sterilization_method_blocks"); + + ConfigureMasterBase("qc_statuses"); + ConfigureBlockBase("qc_status_blocks"); + + ConfigureMasterBase("doc_control_statuses"); + ConfigureBlockBase("doc_control_status_blocks"); + + ConfigureMasterBase("recall_classes"); + ConfigureBlockBase("recall_class_blocks"); + + ConfigureMasterBase("packing_groups"); + ConfigureBlockBase("packing_group_blocks"); + + ConfigureMasterBase("vvms"); + ConfigureBlockBase("vvm_blocks"); + + ConfigureMasterBase("func_tests"); + ConfigureBlockBase("func_test_blocks"); + + ConfigureMasterBase("hazard_classes"); + ConfigureBlockBase("hazard_class_blocks"); + + ConfigureMasterBase("species"); + ConfigureBlockBase("species_blocks"); + + ConfigureMasterBase("allergens"); + ConfigureBlockBase("allergen_blocks"); + + // ====== Enum conversions ====== model.Entity().Property(x => x.Type).HasConversion(); model.Entity().Property(x => x.Type).HasConversion(); model.Entity().Property(x => x.Provider).HasConversion(); model.Entity().Property(x => x.EmploymentType).HasConversion(); model.Entity().Property(x => x.Gender).HasConversion(); + model.Entity().Property(x => x.Type).HasConversion(); + model.Entity().Property(x => x.Status).HasConversion(); + model.Entity().Property(x => x.Type).HasConversion(); + model.Entity().Property(x => x.Label).HasConversion(); + // ====== BaseEntity common mapping ====== - foreach (var et in model.Model.GetEntityTypes() - .Where(t => typeof(BaseEntity).IsAssignableFrom(t.ClrType))) + foreach (var et in model.Model.GetEntityTypes().Where(t => typeof(BaseEntity).IsAssignableFrom(t.ClrType))) { var b = model.Entity(et.ClrType); - // Tenant b.Property(nameof(BaseEntity.TenantId)) .HasColumnName("tenant_id") .HasColumnType("uuid") @@ -395,23 +805,19 @@ public class AppDbContext : DbContext b.HasIndex(nameof(BaseEntity.TenantId)); - // ชื่อ constraint สร้างแบบ concat แทน string interpolation กัน ambiguous handler var tn = et.GetTableName(); if (!string.IsNullOrEmpty(tn)) { - b.HasCheckConstraint(string.Concat("ck_", tn, "_tenant_not_null"), "tenant_id is not null"); - b.HasCheckConstraint(string.Concat("ck_", tn, "_tenant_not_zero"), - "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + b.HasCheckConstraint($"ck_{tn}_tenant_not_null", "tenant_id is not null"); + b.HasCheckConstraint($"ck_{tn}_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); } - // Audit - b.Property("CreatedAt") - .HasColumnName("created_at") + b.Property(nameof(BaseEntity.CreatedAt)).HasColumnName("created_at") .HasDefaultValueSql("now() at time zone 'utc'"); - b.Property("UpdatedAt").HasColumnName("updated_at"); - b.Property("CreatedBy").HasColumnName("created_by"); - b.Property("UpdatedBy").HasColumnName("updated_by"); - b.Property("IsDeleted").HasColumnName("is_deleted").HasDefaultValue(false); + b.Property(nameof(BaseEntity.UpdatedAt)).HasColumnName("updated_at"); + b.Property(nameof(BaseEntity.CreatedBy)).HasColumnName("created_by"); + b.Property(nameof(BaseEntity.UpdatedBy)).HasColumnName("updated_by"); + b.Property(nameof(BaseEntity.IsDeleted)).HasColumnName("is_deleted").HasDefaultValue(false); } } } \ No newline at end of file diff --git a/AMREZ.EOP.Infrastructures/Migrations/20251009040810_AddCustomer.Designer.cs b/AMREZ.EOP.Infrastructures/Migrations/20251009040810_AddCustomer.Designer.cs new file mode 100644 index 0000000..cbca69e --- /dev/null +++ b/AMREZ.EOP.Infrastructures/Migrations/20251009040810_AddCustomer.Designer.cs @@ -0,0 +1,2176 @@ +// +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("20251009040810_AddCustomer")] + partial class AddCustomer + { + /// + 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("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("IsPrimary") + .HasColumnType("boolean"); + + b.Property("Note") + .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("UserProfileId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "UserProfileId", "IsPrimary"); + + b.ToTable("employee_bank_accounts", null, t => + { + t.HasCheckConstraint("ck_employee_bank_accounts_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_employee_bank_accounts_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.HumanResources.Employment", 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("DepartmentId") + .HasColumnType("uuid"); + + b.Property("EmploymentType") + .HasColumnType("integer"); + + b.Property("EndDate") + .HasColumnType("timestamp with time zone"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("ManagerUserId") + .HasColumnType("uuid"); + + b.Property("PositionId") + .HasColumnType("uuid"); + + b.Property("StartDate") + .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("UserProfileId") + .HasColumnType("uuid"); + + b.Property("WorkEmail") + .HasColumnType("text"); + + b.Property("WorkPhone") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "DepartmentId"); + + b.HasIndex("TenantId", "PositionId"); + + b.HasIndex("TenantId", "UserProfileId", "StartDate"); + + b.ToTable("employments", null, t => + { + t.HasCheckConstraint("ck_employments_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_employments_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.HumanResources.Position", 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("Level") + .HasColumnType("integer"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasColumnName("tenant_id"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + 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("positions", null, t => + { + t.HasCheckConstraint("ck_positions_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_positions_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.HumanResources.UserProfile", 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("DateOfBirth") + .HasColumnType("timestamp with time zone"); + + b.Property("DepartmentId") + .HasColumnType("uuid"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("Gender") + .HasColumnType("integer"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("MiddleName") + .HasColumnType("text"); + + b.Property("Nickname") + .HasColumnType("text"); + + b.Property("PositionId") + .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("DepartmentId"); + + b.HasIndex("PositionId"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "UserId") + .IsUnique(); + + b.ToTable("user_profiles", null, t => + { + t.HasCheckConstraint("ck_user_profiles_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_user_profiles_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Tenancy.TenantConfig", b => + { + b.Property("TenantKey") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("ConnectionString") + .HasColumnType("text"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("Mode") + .HasColumnType("integer"); + + b.Property("Schema") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAtUtc") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_at_utc") + .HasDefaultValueSql("now() at time zone 'utc'"); + + b.HasKey("TenantKey"); + + b.HasAlternateKey("TenantId"); + + b.HasIndex("IsActive"); + + b.HasIndex("TenantId") + .IsUnique(); + + b.ToTable("tenants", "meta"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Tenancy.TenantDomain", b => + { + b.Property("Domain") + .HasMaxLength(253) + .HasColumnType("character varying(253)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsPlatformBaseDomain") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("TenantKey") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("UpdatedAtUtc") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_at_utc") + .HasDefaultValueSql("now() at time zone 'utc'"); + + b.HasKey("Domain"); + + b.HasIndex("IsActive"); + + b.HasIndex("IsPlatformBaseDomain"); + + b.HasIndex("TenantKey"); + + b.ToTable("tenant_domains", "meta"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Authentications.RolePermission", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.Authentications.Permission", "Permission") + .WithMany("RolePermissions") + .HasForeignKey("PermissionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AMREZ.EOP.Domain.Entities.Authentications.Role", "Role") + .WithMany("RolePermissions") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AMREZ.EOP.Domain.Entities.Authentications.Permission", null) + .WithMany() + .HasForeignKey("TenantId", "PermissionId") + .HasPrincipalKey("TenantId", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AMREZ.EOP.Domain.Entities.Authentications.Role", null) + .WithMany() + .HasForeignKey("TenantId", "RoleId") + .HasPrincipalKey("TenantId", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Permission"); + + b.Navigation("Role"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Authentications.UserExternalAccount", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.Authentications.User", "User") + .WithMany("ExternalAccounts") + .HasForeignKey("TenantId", "UserId") + .HasPrincipalKey("TenantId", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Authentications.UserIdentity", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.Authentications.User", "User") + .WithMany("Identities") + .HasForeignKey("TenantId", "UserId") + .HasPrincipalKey("TenantId", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Authentications.UserMfaFactor", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.Authentications.User", "User") + .WithMany("MfaFactors") + .HasForeignKey("TenantId", "UserId") + .HasPrincipalKey("TenantId", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Authentications.UserPasswordHistory", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.Authentications.User", "User") + .WithMany("PasswordHistories") + .HasForeignKey("TenantId", "UserId") + .HasPrincipalKey("TenantId", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Authentications.UserRole", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.Authentications.Role", "Role") + .WithMany("UserRoles") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AMREZ.EOP.Domain.Entities.Authentications.User", "User") + .WithMany("UserRoles") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AMREZ.EOP.Domain.Entities.Authentications.Role", null) + .WithMany() + .HasForeignKey("TenantId", "RoleId") + .HasPrincipalKey("TenantId", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AMREZ.EOP.Domain.Entities.Authentications.User", null) + .WithMany() + .HasForeignKey("TenantId", "UserId") + .HasPrincipalKey("TenantId", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Authentications.UserSession", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.Authentications.User", "User") + .WithMany("Sessions") + .HasForeignKey("TenantId", "UserId") + .HasPrincipalKey("TenantId", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Customers.CustomerAddress", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.Customers.Address", "Address") + .WithMany("CustomerLinks") + .HasForeignKey("TenantId", "AddressId") + .HasPrincipalKey("TenantId", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AMREZ.EOP.Domain.Entities.Customers.CustomerProfile", "Customer") + .WithMany("Addresses") + .HasForeignKey("TenantId", "CustomerProfileId") + .HasPrincipalKey("TenantId", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Address"); + + b.Navigation("Customer"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Customers.CustomerContact", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.Customers.CustomerProfile", "Customer") + .WithMany("Contacts") + .HasForeignKey("TenantId", "CustomerProfileId") + .HasPrincipalKey("TenantId", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Customer"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Customers.CustomerTag", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.Customers.CustomerProfile", "Customer") + .WithMany("Tags") + .HasForeignKey("TenantId", "CustomerProfileId") + .HasPrincipalKey("TenantId", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Customer"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Customers.OrganizationProfile", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.Customers.CustomerProfile", "Customer") + .WithOne("Organization") + .HasForeignKey("AMREZ.EOP.Domain.Entities.Customers.OrganizationProfile", "TenantId", "CustomerProfileId") + .HasPrincipalKey("AMREZ.EOP.Domain.Entities.Customers.CustomerProfile", "TenantId", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Customer"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Customers.PersonProfile", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.Customers.CustomerProfile", "Customer") + .WithOne("Person") + .HasForeignKey("AMREZ.EOP.Domain.Entities.Customers.PersonProfile", "TenantId", "CustomerProfileId") + .HasPrincipalKey("AMREZ.EOP.Domain.Entities.Customers.CustomerProfile", "TenantId", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Customer"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.HumanResources.Department", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.HumanResources.Department", "Parent") + .WithMany("Children") + .HasForeignKey("TenantId", "ParentDepartmentId") + .HasPrincipalKey("TenantId", "Id") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Parent"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.HumanResources.EmergencyContact", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.HumanResources.UserProfile", "UserProfile") + .WithMany("EmergencyContacts") + .HasForeignKey("TenantId", "UserProfileId") + .HasPrincipalKey("TenantId", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("UserProfile"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.HumanResources.EmployeeAddress", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.HumanResources.UserProfile", "UserProfile") + .WithMany("Addresses") + .HasForeignKey("TenantId", "UserProfileId") + .HasPrincipalKey("TenantId", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("UserProfile"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.HumanResources.EmployeeBankAccount", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.HumanResources.UserProfile", "UserProfile") + .WithMany("BankAccounts") + .HasForeignKey("TenantId", "UserProfileId") + .HasPrincipalKey("TenantId", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("UserProfile"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.HumanResources.Employment", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.HumanResources.Department", "Department") + .WithMany() + .HasForeignKey("TenantId", "DepartmentId") + .HasPrincipalKey("TenantId", "Id") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("AMREZ.EOP.Domain.Entities.HumanResources.Position", "Position") + .WithMany() + .HasForeignKey("TenantId", "PositionId") + .HasPrincipalKey("TenantId", "Id") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("AMREZ.EOP.Domain.Entities.HumanResources.UserProfile", "UserProfile") + .WithMany("Employments") + .HasForeignKey("TenantId", "UserProfileId") + .HasPrincipalKey("TenantId", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Department"); + + b.Navigation("Position"); + + b.Navigation("UserProfile"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.HumanResources.UserProfile", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.HumanResources.Department", null) + .WithMany("Profiles") + .HasForeignKey("DepartmentId"); + + b.HasOne("AMREZ.EOP.Domain.Entities.HumanResources.Position", null) + .WithMany("Profiles") + .HasForeignKey("PositionId"); + + b.HasOne("AMREZ.EOP.Domain.Entities.Authentications.User", "User") + .WithOne() + .HasForeignKey("AMREZ.EOP.Domain.Entities.HumanResources.UserProfile", "TenantId", "UserId") + .HasPrincipalKey("AMREZ.EOP.Domain.Entities.Authentications.User", "TenantId", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Tenancy.TenantDomain", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.Tenancy.TenantConfig", null) + .WithMany() + .HasForeignKey("TenantKey") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Authentications.Permission", b => + { + b.Navigation("RolePermissions"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Authentications.Role", b => + { + b.Navigation("RolePermissions"); + + b.Navigation("UserRoles"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Authentications.User", b => + { + b.Navigation("ExternalAccounts"); + + b.Navigation("Identities"); + + b.Navigation("MfaFactors"); + + b.Navigation("PasswordHistories"); + + b.Navigation("Sessions"); + + b.Navigation("UserRoles"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Customers.Address", b => + { + b.Navigation("CustomerLinks"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Customers.CustomerProfile", b => + { + b.Navigation("Addresses"); + + b.Navigation("Contacts"); + + b.Navigation("Organization"); + + b.Navigation("Person"); + + b.Navigation("Tags"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.HumanResources.Department", b => + { + b.Navigation("Children"); + + b.Navigation("Profiles"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.HumanResources.Position", b => + { + b.Navigation("Profiles"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.HumanResources.UserProfile", b => + { + b.Navigation("Addresses"); + + b.Navigation("BankAccounts"); + + b.Navigation("EmergencyContacts"); + + b.Navigation("Employments"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/AMREZ.EOP.Infrastructures/Migrations/20251009040810_AddCustomer.cs b/AMREZ.EOP.Infrastructures/Migrations/20251009040810_AddCustomer.cs new file mode 100644 index 0000000..e5ff417 --- /dev/null +++ b/AMREZ.EOP.Infrastructures/Migrations/20251009040810_AddCustomer.cs @@ -0,0 +1,348 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace AMREZ.EOP.Infrastructures.Migrations +{ + /// + public partial class AddCustomer : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "addresses", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + Line1 = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + Line2 = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + Village = table.Column(type: "character varying(128)", maxLength: 128, nullable: true), + Soi = table.Column(type: "character varying(128)", maxLength: 128, nullable: true), + Road = table.Column(type: "character varying(128)", maxLength: 128, nullable: true), + Subdistrict = table.Column(type: "character varying(128)", maxLength: 128, nullable: true), + District = table.Column(type: "character varying(128)", maxLength: 128, nullable: true), + Province = table.Column(type: "character varying(128)", maxLength: 128, nullable: true), + PostalCode = table.Column(type: "character varying(10)", maxLength: 10, nullable: true), + CountryCode = table.Column(type: "character varying(2)", maxLength: 2, nullable: false), + Verified = table.Column(type: "boolean", nullable: false), + GeoLat = table.Column(type: "double precision", nullable: true), + GeoLng = table.Column(type: "double precision", nullable: true), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false) + }, + constraints: table => + { + table.PrimaryKey("PK_addresses", x => x.Id); + table.UniqueConstraint("AK_addresses_tenant_id_Id", x => new { x.tenant_id, x.Id }); + table.CheckConstraint("ck_addresses_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_addresses_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + + migrationBuilder.CreateTable( + name: "customer_profiles", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + Type = table.Column(type: "integer", nullable: false), + DisplayName = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), + Status = table.Column(type: "integer", nullable: false), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false) + }, + constraints: table => + { + table.PrimaryKey("PK_customer_profiles", x => x.Id); + table.UniqueConstraint("AK_customer_profiles_tenant_id_Id", x => new { x.tenant_id, x.Id }); + table.CheckConstraint("ck_customer_profiles_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_customer_profiles_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + + migrationBuilder.CreateTable( + name: "customer_addresses", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + CustomerProfileId = table.Column(type: "uuid", nullable: false), + AddressId = table.Column(type: "uuid", nullable: false), + Label = table.Column(type: "integer", nullable: false), + IsDefault = table.Column(type: "boolean", nullable: false, defaultValue: false), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false) + }, + constraints: table => + { + table.PrimaryKey("PK_customer_addresses", x => x.Id); + table.CheckConstraint("ck_customer_addresses_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_customer_addresses_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + table.ForeignKey( + name: "FK_customer_addresses_addresses_tenant_id_AddressId", + columns: x => new { x.tenant_id, x.AddressId }, + principalTable: "addresses", + principalColumns: new[] { "tenant_id", "Id" }, + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_customer_addresses_customer_profiles_tenant_id_CustomerProf~", + columns: x => new { x.tenant_id, x.CustomerProfileId }, + principalTable: "customer_profiles", + principalColumns: new[] { "tenant_id", "Id" }, + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "customer_contacts", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + CustomerProfileId = table.Column(type: "uuid", nullable: false), + Type = table.Column(type: "integer", nullable: false), + Value = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), + IsPrimary = table.Column(type: "boolean", nullable: false, defaultValue: false), + IsVerified = table.Column(type: "boolean", nullable: false, defaultValue: false), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false) + }, + constraints: table => + { + table.PrimaryKey("PK_customer_contacts", x => x.Id); + table.CheckConstraint("ck_customer_contacts_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_customer_contacts_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + table.ForeignKey( + name: "FK_customer_contacts_customer_profiles_tenant_id_CustomerProfi~", + columns: x => new { x.tenant_id, x.CustomerProfileId }, + principalTable: "customer_profiles", + principalColumns: new[] { "tenant_id", "Id" }, + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "customer_tags", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + CustomerProfileId = table.Column(type: "uuid", nullable: false), + Tag = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false) + }, + constraints: table => + { + table.PrimaryKey("PK_customer_tags", x => x.Id); + table.CheckConstraint("ck_customer_tags_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_customer_tags_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + table.ForeignKey( + name: "FK_customer_tags_customer_profiles_tenant_id_CustomerProfileId", + columns: x => new { x.tenant_id, x.CustomerProfileId }, + principalTable: "customer_profiles", + principalColumns: new[] { "tenant_id", "Id" }, + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "organization_profiles", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + CustomerProfileId = table.Column(type: "uuid", nullable: false), + LegalNameTh = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), + LegalNameEn = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + RegistrationNo = table.Column(type: "character varying(64)", maxLength: 64, nullable: true), + TaxId13 = table.Column(type: "character varying(13)", maxLength: 13, nullable: true), + BranchCode = table.Column(type: "character varying(5)", maxLength: 5, nullable: true), + CompanyType = table.Column(type: "character varying(64)", maxLength: 64, nullable: true), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false) + }, + constraints: table => + { + table.PrimaryKey("PK_organization_profiles", x => x.Id); + table.CheckConstraint("ck_organization_profiles_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_organization_profiles_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + table.ForeignKey( + name: "FK_organization_profiles_customer_profiles_tenant_id_CustomerP~", + columns: x => new { x.tenant_id, x.CustomerProfileId }, + principalTable: "customer_profiles", + principalColumns: new[] { "tenant_id", "Id" }, + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "person_profiles", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + CustomerProfileId = table.Column(type: "uuid", nullable: false), + Prefix = table.Column(type: "character varying(32)", maxLength: 32, nullable: true), + FirstNameTh = table.Column(type: "character varying(128)", maxLength: 128, nullable: true), + LastNameTh = table.Column(type: "character varying(128)", maxLength: 128, nullable: true), + FirstNameEn = table.Column(type: "character varying(128)", maxLength: 128, nullable: true), + LastNameEn = table.Column(type: "character varying(128)", maxLength: 128, nullable: true), + BirthDate = table.Column(type: "timestamp with time zone", nullable: true), + NationalId = table.Column(type: "character varying(13)", maxLength: 13, nullable: true), + PassportNo = table.Column(type: "character varying(32)", maxLength: 32, nullable: true), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false) + }, + constraints: table => + { + table.PrimaryKey("PK_person_profiles", x => x.Id); + table.CheckConstraint("ck_person_profiles_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_person_profiles_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + table.ForeignKey( + name: "FK_person_profiles_customer_profiles_tenant_id_CustomerProfile~", + columns: x => new { x.tenant_id, x.CustomerProfileId }, + principalTable: "customer_profiles", + principalColumns: new[] { "tenant_id", "Id" }, + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_addresses_tenant_id", + table: "addresses", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_customer_addresses_tenant_id", + table: "customer_addresses", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_customer_addresses_tenant_id_AddressId", + table: "customer_addresses", + columns: new[] { "tenant_id", "AddressId" }); + + migrationBuilder.CreateIndex( + name: "IX_customer_addresses_tenant_id_CustomerProfileId_Label", + table: "customer_addresses", + columns: new[] { "tenant_id", "CustomerProfileId", "Label" }); + + migrationBuilder.CreateIndex( + name: "ux_default_customer_address_per_label", + table: "customer_addresses", + columns: new[] { "tenant_id", "CustomerProfileId", "Label", "IsDefault" }, + unique: true, + filter: "\"IsDefault\" = TRUE"); + + migrationBuilder.CreateIndex( + name: "IX_customer_contacts_tenant_id", + table: "customer_contacts", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_customer_contacts_tenant_id_CustomerProfileId_Type", + table: "customer_contacts", + columns: new[] { "tenant_id", "CustomerProfileId", "Type" }); + + migrationBuilder.CreateIndex( + name: "ux_customer_contact_primary_per_type", + table: "customer_contacts", + columns: new[] { "tenant_id", "CustomerProfileId", "Type", "IsPrimary" }, + unique: true, + filter: "\"IsPrimary\" = TRUE"); + + migrationBuilder.CreateIndex( + name: "IX_customer_profiles_tenant_id", + table: "customer_profiles", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_customer_profiles_tenant_id_DisplayName", + table: "customer_profiles", + columns: new[] { "tenant_id", "DisplayName" }); + + migrationBuilder.CreateIndex( + name: "IX_customer_tags_tenant_id", + table: "customer_tags", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_customer_tags_tenant_id_CustomerProfileId_Tag", + table: "customer_tags", + columns: new[] { "tenant_id", "CustomerProfileId", "Tag" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_organization_profiles_tenant_id", + table: "organization_profiles", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_organization_profiles_tenant_id_CustomerProfileId", + table: "organization_profiles", + columns: new[] { "tenant_id", "CustomerProfileId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_organization_profiles_tenant_id_TaxId13_BranchCode", + table: "organization_profiles", + columns: new[] { "tenant_id", "TaxId13", "BranchCode" }, + unique: true, + filter: "\"TaxId13\" IS NOT NULL"); + + migrationBuilder.CreateIndex( + name: "IX_person_profiles_tenant_id", + table: "person_profiles", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_person_profiles_tenant_id_CustomerProfileId", + table: "person_profiles", + columns: new[] { "tenant_id", "CustomerProfileId" }, + unique: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "customer_addresses"); + + migrationBuilder.DropTable( + name: "customer_contacts"); + + migrationBuilder.DropTable( + name: "customer_tags"); + + migrationBuilder.DropTable( + name: "organization_profiles"); + + migrationBuilder.DropTable( + name: "person_profiles"); + + migrationBuilder.DropTable( + name: "addresses"); + + migrationBuilder.DropTable( + name: "customer_profiles"); + } + } +} diff --git a/AMREZ.EOP.Infrastructures/Migrations/20251010092049_AddProductMasterData.Designer.cs b/AMREZ.EOP.Infrastructures/Migrations/20251010092049_AddProductMasterData.Designer.cs new file mode 100644 index 0000000..bb5afae --- /dev/null +++ b/AMREZ.EOP.Infrastructures/Migrations/20251010092049_AddProductMasterData.Designer.cs @@ -0,0 +1,5789 @@ +// +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("20251010092049_AddProductMasterData")] + partial class AddProductMasterData + { + /// + 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("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("IsPrimary") + .HasColumnType("boolean"); + + b.Property("Note") + .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("UserProfileId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "UserProfileId", "IsPrimary"); + + b.ToTable("employee_bank_accounts", null, t => + { + t.HasCheckConstraint("ck_employee_bank_accounts_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_employee_bank_accounts_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.HumanResources.Employment", 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("DepartmentId") + .HasColumnType("uuid"); + + b.Property("EmploymentType") + .HasColumnType("integer"); + + b.Property("EndDate") + .HasColumnType("timestamp with time zone"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("ManagerUserId") + .HasColumnType("uuid"); + + b.Property("PositionId") + .HasColumnType("uuid"); + + b.Property("StartDate") + .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("UserProfileId") + .HasColumnType("uuid"); + + b.Property("WorkEmail") + .HasColumnType("text"); + + b.Property("WorkPhone") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "DepartmentId"); + + b.HasIndex("TenantId", "PositionId"); + + b.HasIndex("TenantId", "UserProfileId", "StartDate"); + + b.ToTable("employments", null, t => + { + t.HasCheckConstraint("ck_employments_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_employments_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.HumanResources.Position", 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("Level") + .HasColumnType("integer"); + + b.Property("TenantId") + .HasColumnType("uuid") + .HasColumnName("tenant_id"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + 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("positions", null, t => + { + t.HasCheckConstraint("ck_positions_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_positions_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.HumanResources.UserProfile", 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("DateOfBirth") + .HasColumnType("timestamp with time zone"); + + b.Property("DepartmentId") + .HasColumnType("uuid"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("Gender") + .HasColumnType("integer"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("MiddleName") + .HasColumnType("text"); + + b.Property("Nickname") + .HasColumnType("text"); + + b.Property("PositionId") + .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("DepartmentId"); + + b.HasIndex("PositionId"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "UserId") + .IsUnique(); + + b.ToTable("user_profiles", null, t => + { + t.HasCheckConstraint("ck_user_profiles_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_user_profiles_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.Allergen", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .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("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("IsSystem") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("Meta") + .HasColumnType("jsonb"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameI18n") + .HasColumnType("jsonb"); + + b.Property("OverridesGlobalId") + .HasColumnType("uuid"); + + b.Property("Scope") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue("global"); + + 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.HasAlternateKey("TenantId", "Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("Scope", "TenantId", "Code") + .IsUnique(); + + b.ToTable("allergens", "master", t => + { + t.HasCheckConstraint("ck_allergens_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_allergens_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.AllergenBlock", 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("GlobalId") + .HasColumnType("uuid"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + 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("GlobalId"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "GlobalId") + .IsUnique(); + + b.ToTable("allergen_blocks", "master", t => + { + t.HasCheckConstraint("ck_allergen_blocks_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_allergen_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.Brand", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .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("ExternalRef") + .HasColumnType("text"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("IsSystem") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("Meta") + .HasColumnType("jsonb"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameI18n") + .HasColumnType("jsonb"); + + b.Property("OverridesGlobalId") + .HasColumnType("uuid"); + + b.Property("Scope") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue("global"); + + 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.HasAlternateKey("TenantId", "Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("Scope", "TenantId", "Code") + .IsUnique(); + + b.ToTable("brands", "master", t => + { + t.HasCheckConstraint("ck_brands_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_brands_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.BrandBlock", 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("GlobalId") + .HasColumnType("uuid"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + 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("GlobalId"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "GlobalId") + .IsUnique(); + + b.ToTable("brand_blocks", "master", t => + { + t.HasCheckConstraint("ck_brand_blocks_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_brand_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.Category", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .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("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("IsSystem") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("Meta") + .HasColumnType("jsonb"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameI18n") + .HasColumnType("jsonb"); + + b.Property("OverridesGlobalId") + .HasColumnType("uuid"); + + b.Property("ParentId") + .HasColumnType("uuid"); + + b.Property("Path") + .HasColumnType("text"); + + b.Property("Scope") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue("global"); + + b.Property("SortOrder") + .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("ParentId"); + + b.HasIndex("Path"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "ParentId"); + + b.HasIndex("Scope", "TenantId", "Code") + .IsUnique(); + + b.HasIndex("Scope", "TenantId", "SortOrder"); + + b.ToTable("categories", "master", t => + { + t.HasCheckConstraint("ck_categories_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_categories_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.CategoryBlock", 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("GlobalId") + .HasColumnType("uuid"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + 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("GlobalId"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "GlobalId") + .IsUnique(); + + b.ToTable("category_blocks", "master", t => + { + t.HasCheckConstraint("ck_category_blocks_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_category_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.CategoryExt", b => + { + b.Property("CategoryId") + .HasColumnType("uuid"); + + b.Property("ChannelVisibility") + .HasColumnType("jsonb"); + + b.Property("FacetSchema") + .HasColumnType("jsonb"); + + b.Property("ImageUrl") + .HasColumnType("text"); + + b.Property("SeoDescription") + .HasColumnType("text"); + + b.Property("SeoTitle") + .HasColumnType("text"); + + b.Property("Slug") + .HasColumnType("text"); + + b.HasKey("CategoryId"); + + b.ToTable("category_exts", "master"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.ComplianceStatus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .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("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("IsSystem") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("Meta") + .HasColumnType("jsonb"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameI18n") + .HasColumnType("jsonb"); + + b.Property("OverridesGlobalId") + .HasColumnType("uuid"); + + b.Property("Scope") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue("global"); + + 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.HasAlternateKey("TenantId", "Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("Scope", "TenantId", "Code") + .IsUnique(); + + b.ToTable("compliance_statuses", "master", t => + { + t.HasCheckConstraint("ck_compliance_statuses_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_compliance_statuses_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.ComplianceStatusBlock", 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("GlobalId") + .HasColumnType("uuid"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + 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("GlobalId"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "GlobalId") + .IsUnique(); + + b.ToTable("compliance_status_blocks", "master", t => + { + t.HasCheckConstraint("ck_compliance_status_blocks_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_compliance_status_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.Country", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .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("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("IsSystem") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("Meta") + .HasColumnType("jsonb"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameI18n") + .HasColumnType("jsonb"); + + b.Property("OverridesGlobalId") + .HasColumnType("uuid"); + + b.Property("Scope") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue("global"); + + 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.HasAlternateKey("TenantId", "Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("Scope", "TenantId", "Code") + .IsUnique(); + + b.ToTable("countries", "master", t => + { + t.HasCheckConstraint("ck_countries_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_countries_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.CountryBlock", 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("GlobalId") + .HasColumnType("uuid"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + 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("GlobalId"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "GlobalId") + .IsUnique(); + + b.ToTable("country_blocks", "master", t => + { + t.HasCheckConstraint("ck_country_blocks_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_country_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.Currency", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .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("Exponent") + .HasColumnType("smallint"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("IsSystem") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("Meta") + .HasColumnType("jsonb"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameI18n") + .HasColumnType("jsonb"); + + b.Property("OverridesGlobalId") + .HasColumnType("uuid"); + + b.Property("Scope") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue("global"); + + 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.HasAlternateKey("TenantId", "Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("Scope", "TenantId", "Code") + .IsUnique(); + + b.ToTable("currencies", "master", t => + { + t.HasCheckConstraint("ck_currencies_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_currencies_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.CurrencyBlock", 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("GlobalId") + .HasColumnType("uuid"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + 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("GlobalId"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "GlobalId") + .IsUnique(); + + b.ToTable("currency_blocks", "master", t => + { + t.HasCheckConstraint("ck_currency_blocks_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_currency_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.DocControlStatus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .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("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("IsSystem") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("Meta") + .HasColumnType("jsonb"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameI18n") + .HasColumnType("jsonb"); + + b.Property("OverridesGlobalId") + .HasColumnType("uuid"); + + b.Property("Scope") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue("global"); + + 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.HasAlternateKey("TenantId", "Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("Scope", "TenantId", "Code") + .IsUnique(); + + b.ToTable("doc_control_statuses", "master", t => + { + t.HasCheckConstraint("ck_doc_control_statuses_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_doc_control_statuses_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.DocControlStatusBlock", 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("GlobalId") + .HasColumnType("uuid"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + 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("GlobalId"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "GlobalId") + .IsUnique(); + + b.ToTable("doc_control_status_blocks", "master", t => + { + t.HasCheckConstraint("ck_doc_control_status_blocks_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_doc_control_status_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.FuncTest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .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("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("IsSystem") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("Meta") + .HasColumnType("jsonb"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameI18n") + .HasColumnType("jsonb"); + + b.Property("OverridesGlobalId") + .HasColumnType("uuid"); + + b.Property("Scope") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue("global"); + + 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.HasAlternateKey("TenantId", "Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("Scope", "TenantId", "Code") + .IsUnique(); + + b.ToTable("func_tests", "master", t => + { + t.HasCheckConstraint("ck_func_tests_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_func_tests_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.FuncTestBlock", 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("GlobalId") + .HasColumnType("uuid"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + 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("GlobalId"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "GlobalId") + .IsUnique(); + + b.ToTable("func_test_blocks", "master", t => + { + t.HasCheckConstraint("ck_func_test_blocks_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_func_test_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.HazardClass", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .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("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("IsSystem") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("Meta") + .HasColumnType("jsonb"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameI18n") + .HasColumnType("jsonb"); + + b.Property("OverridesGlobalId") + .HasColumnType("uuid"); + + b.Property("Scope") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue("global"); + + 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.HasAlternateKey("TenantId", "Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("Scope", "TenantId", "Code") + .IsUnique(); + + b.ToTable("hazard_classes", "master", t => + { + t.HasCheckConstraint("ck_hazard_classes_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_hazard_classes_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.HazardClassBlock", 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("GlobalId") + .HasColumnType("uuid"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + 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("GlobalId"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "GlobalId") + .IsUnique(); + + b.ToTable("hazard_class_blocks", "master", t => + { + t.HasCheckConstraint("ck_hazard_class_blocks_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_hazard_class_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.Language", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .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("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("IsSystem") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("Meta") + .HasColumnType("jsonb"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameI18n") + .HasColumnType("jsonb"); + + b.Property("OverridesGlobalId") + .HasColumnType("uuid"); + + b.Property("Scope") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue("global"); + + 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.HasAlternateKey("TenantId", "Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("Scope", "TenantId", "Code") + .IsUnique(); + + b.ToTable("languages", "master", t => + { + t.HasCheckConstraint("ck_languages_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_languages_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.LanguageBlock", 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("GlobalId") + .HasColumnType("uuid"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + 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("GlobalId"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "GlobalId") + .IsUnique(); + + b.ToTable("language_blocks", "master", t => + { + t.HasCheckConstraint("ck_language_blocks_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_language_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.Manufacturer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .HasColumnType("text"); + + b.Property("CountryCode") + .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("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("IsSystem") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("Meta") + .HasColumnType("jsonb"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameI18n") + .HasColumnType("jsonb"); + + b.Property("OverridesGlobalId") + .HasColumnType("uuid"); + + b.Property("Scope") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue("global"); + + 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.HasAlternateKey("TenantId", "Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("Scope", "TenantId", "Code") + .IsUnique(); + + b.ToTable("manufacturers", "master", t => + { + t.HasCheckConstraint("ck_manufacturers_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_manufacturers_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.ManufacturerBlock", 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("GlobalId") + .HasColumnType("uuid"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + 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("GlobalId"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "GlobalId") + .IsUnique(); + + b.ToTable("manufacturer_blocks", "master", t => + { + t.HasCheckConstraint("ck_manufacturer_blocks_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_manufacturer_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.Market", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .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("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("IsSystem") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("Meta") + .HasColumnType("jsonb"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameI18n") + .HasColumnType("jsonb"); + + b.Property("OverridesGlobalId") + .HasColumnType("uuid"); + + b.Property("Scope") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue("global"); + + 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.HasAlternateKey("TenantId", "Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("Scope", "TenantId", "Code") + .IsUnique(); + + b.ToTable("markets", "master", t => + { + t.HasCheckConstraint("ck_markets_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_markets_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.MarketBlock", 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("GlobalId") + .HasColumnType("uuid"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + 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("GlobalId"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "GlobalId") + .IsUnique(); + + b.ToTable("market_blocks", "master", t => + { + t.HasCheckConstraint("ck_market_blocks_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_market_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.PackingGroup", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .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("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("IsSystem") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("Meta") + .HasColumnType("jsonb"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameI18n") + .HasColumnType("jsonb"); + + b.Property("OverridesGlobalId") + .HasColumnType("uuid"); + + b.Property("Scope") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue("global"); + + 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.HasAlternateKey("TenantId", "Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("Scope", "TenantId", "Code") + .IsUnique(); + + b.ToTable("packing_groups", "master", t => + { + t.HasCheckConstraint("ck_packing_groups_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_packing_groups_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.PackingGroupBlock", 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("GlobalId") + .HasColumnType("uuid"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + 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("GlobalId"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "GlobalId") + .IsUnique(); + + b.ToTable("packing_group_blocks", "master", t => + { + t.HasCheckConstraint("ck_packing_group_blocks_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_packing_group_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.QaStage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .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("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("IsSystem") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("Meta") + .HasColumnType("jsonb"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameI18n") + .HasColumnType("jsonb"); + + b.Property("OverridesGlobalId") + .HasColumnType("uuid"); + + b.Property("Scope") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue("global"); + + 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.HasAlternateKey("TenantId", "Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("Scope", "TenantId", "Code") + .IsUnique(); + + b.ToTable("qa_stages", "master", t => + { + t.HasCheckConstraint("ck_qa_stages_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_qa_stages_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.QaStageBlock", 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("GlobalId") + .HasColumnType("uuid"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + 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("GlobalId"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "GlobalId") + .IsUnique(); + + b.ToTable("qa_stage_blocks", "master", t => + { + t.HasCheckConstraint("ck_qa_stage_blocks_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_qa_stage_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.QcStatus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .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("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("IsSystem") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("Meta") + .HasColumnType("jsonb"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameI18n") + .HasColumnType("jsonb"); + + b.Property("OverridesGlobalId") + .HasColumnType("uuid"); + + b.Property("Scope") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue("global"); + + 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.HasAlternateKey("TenantId", "Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("Scope", "TenantId", "Code") + .IsUnique(); + + b.ToTable("qc_statuses", "master", t => + { + t.HasCheckConstraint("ck_qc_statuses_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_qc_statuses_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.QcStatusBlock", 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("GlobalId") + .HasColumnType("uuid"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + 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("GlobalId"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "GlobalId") + .IsUnique(); + + b.ToTable("qc_status_blocks", "master", t => + { + t.HasCheckConstraint("ck_qc_status_blocks_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_qc_status_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.RecallClass", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .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("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("IsSystem") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("Meta") + .HasColumnType("jsonb"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameI18n") + .HasColumnType("jsonb"); + + b.Property("OverridesGlobalId") + .HasColumnType("uuid"); + + b.Property("Scope") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue("global"); + + 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.HasAlternateKey("TenantId", "Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("Scope", "TenantId", "Code") + .IsUnique(); + + b.ToTable("recall_classes", "master", t => + { + t.HasCheckConstraint("ck_recall_classes_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_recall_classes_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.RecallClassBlock", 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("GlobalId") + .HasColumnType("uuid"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + 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("GlobalId"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "GlobalId") + .IsUnique(); + + b.ToTable("recall_class_blocks", "master", t => + { + t.HasCheckConstraint("ck_recall_class_blocks_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_recall_class_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.RiskClass", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .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("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("IsSystem") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("Meta") + .HasColumnType("jsonb"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameI18n") + .HasColumnType("jsonb"); + + b.Property("OverridesGlobalId") + .HasColumnType("uuid"); + + b.Property("Scope") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue("global"); + + 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.HasAlternateKey("TenantId", "Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("Scope", "TenantId", "Code") + .IsUnique(); + + b.ToTable("risk_classes", "master", t => + { + t.HasCheckConstraint("ck_risk_classes_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_risk_classes_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.RiskClassBlock", 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("GlobalId") + .HasColumnType("uuid"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + 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("GlobalId"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "GlobalId") + .IsUnique(); + + b.ToTable("risk_class_blocks", "master", t => + { + t.HasCheckConstraint("ck_risk_class_blocks_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_risk_class_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.Route", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .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("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("IsSystem") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("Meta") + .HasColumnType("jsonb"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameI18n") + .HasColumnType("jsonb"); + + b.Property("OverridesGlobalId") + .HasColumnType("uuid"); + + b.Property("Scope") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue("global"); + + 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.HasAlternateKey("TenantId", "Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("Scope", "TenantId", "Code") + .IsUnique(); + + b.ToTable("routes", "master", t => + { + t.HasCheckConstraint("ck_routes_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_routes_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.RouteBlock", 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("GlobalId") + .HasColumnType("uuid"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + 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("GlobalId"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "GlobalId") + .IsUnique(); + + b.ToTable("route_blocks", "master", t => + { + t.HasCheckConstraint("ck_route_blocks_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_route_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.RxSchedule", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .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("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("IsSystem") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("Meta") + .HasColumnType("jsonb"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameI18n") + .HasColumnType("jsonb"); + + b.Property("OverridesGlobalId") + .HasColumnType("uuid"); + + b.Property("Scope") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue("global"); + + 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.HasAlternateKey("TenantId", "Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("Scope", "TenantId", "Code") + .IsUnique(); + + b.ToTable("rx_schedules", "master", t => + { + t.HasCheckConstraint("ck_rx_schedules_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_rx_schedules_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.RxScheduleBlock", 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("GlobalId") + .HasColumnType("uuid"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + 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("GlobalId"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "GlobalId") + .IsUnique(); + + b.ToTable("rx_schedule_blocks", "master", t => + { + t.HasCheckConstraint("ck_rx_schedule_blocks_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_rx_schedule_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.Species", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .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("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("IsSystem") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("Meta") + .HasColumnType("jsonb"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameI18n") + .HasColumnType("jsonb"); + + b.Property("OverridesGlobalId") + .HasColumnType("uuid"); + + b.Property("Scope") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue("global"); + + 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.HasAlternateKey("TenantId", "Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("Scope", "TenantId", "Code") + .IsUnique(); + + b.ToTable("species", "master", t => + { + t.HasCheckConstraint("ck_species_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_species_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.SpeciesBlock", 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("GlobalId") + .HasColumnType("uuid"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + 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("GlobalId"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "GlobalId") + .IsUnique(); + + b.ToTable("species_blocks", "master", t => + { + t.HasCheckConstraint("ck_species_blocks_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_species_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.StabilityStatus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .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("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("IsSystem") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("Meta") + .HasColumnType("jsonb"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameI18n") + .HasColumnType("jsonb"); + + b.Property("OverridesGlobalId") + .HasColumnType("uuid"); + + b.Property("Scope") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue("global"); + + 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.HasAlternateKey("TenantId", "Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("Scope", "TenantId", "Code") + .IsUnique(); + + b.ToTable("stability_statuses", "master", t => + { + t.HasCheckConstraint("ck_stability_statuses_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_stability_statuses_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.StabilityStatusBlock", 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("GlobalId") + .HasColumnType("uuid"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + 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("GlobalId"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "GlobalId") + .IsUnique(); + + b.ToTable("stability_status_blocks", "master", t => + { + t.HasCheckConstraint("ck_stability_status_blocks_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_stability_status_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.SterilizationMethod", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .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("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("IsSystem") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("Meta") + .HasColumnType("jsonb"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameI18n") + .HasColumnType("jsonb"); + + b.Property("OverridesGlobalId") + .HasColumnType("uuid"); + + b.Property("Scope") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue("global"); + + 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.HasAlternateKey("TenantId", "Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("Scope", "TenantId", "Code") + .IsUnique(); + + b.ToTable("sterilization_methods", "master", t => + { + t.HasCheckConstraint("ck_sterilization_methods_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_sterilization_methods_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.SterilizationMethodBlock", 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("GlobalId") + .HasColumnType("uuid"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + 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("GlobalId"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "GlobalId") + .IsUnique(); + + b.ToTable("sterilization_method_blocks", "master", t => + { + t.HasCheckConstraint("ck_sterilization_method_blocks_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_sterilization_method_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.Uom", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("BaseCode") + .HasColumnType("text"); + + b.Property("Code") + .IsRequired() + .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("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("IsSystem") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("Meta") + .HasColumnType("jsonb"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameI18n") + .HasColumnType("jsonb"); + + b.Property("OverridesGlobalId") + .HasColumnType("uuid"); + + b.Property("Scope") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue("global"); + + b.Property("SiFactor") + .HasColumnType("numeric"); + + 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.HasAlternateKey("TenantId", "Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("Scope", "TenantId", "Code") + .IsUnique(); + + b.ToTable("uoms", "master", t => + { + t.HasCheckConstraint("ck_uoms_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_uoms_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.UomBlock", 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("GlobalId") + .HasColumnType("uuid"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + 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("GlobalId"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "GlobalId") + .IsUnique(); + + b.ToTable("uom_blocks", "master", t => + { + t.HasCheckConstraint("ck_uom_blocks_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_uom_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.Vvm", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .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("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("IsSystem") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("Meta") + .HasColumnType("jsonb"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameI18n") + .HasColumnType("jsonb"); + + b.Property("OverridesGlobalId") + .HasColumnType("uuid"); + + b.Property("Scope") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue("global"); + + 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.HasAlternateKey("TenantId", "Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("Scope", "TenantId", "Code") + .IsUnique(); + + b.ToTable("vvms", "master", t => + { + t.HasCheckConstraint("ck_vvms_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_vvms_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.VvmBlock", 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("GlobalId") + .HasColumnType("uuid"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + 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("GlobalId"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "GlobalId") + .IsUnique(); + + b.ToTable("vvm_blocks", "master", t => + { + t.HasCheckConstraint("ck_vvm_blocks_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_vvm_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Tenancy.TenantConfig", b => + { + b.Property("TenantKey") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("ConnectionString") + .HasColumnType("text"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("Mode") + .HasColumnType("integer"); + + b.Property("Schema") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UpdatedAtUtc") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_at_utc") + .HasDefaultValueSql("now() at time zone 'utc'"); + + b.HasKey("TenantKey"); + + b.HasAlternateKey("TenantId"); + + b.HasIndex("IsActive"); + + b.HasIndex("TenantId") + .IsUnique(); + + b.ToTable("tenants", "meta"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Tenancy.TenantDomain", b => + { + b.Property("Domain") + .HasMaxLength(253) + .HasColumnType("character varying(253)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsPlatformBaseDomain") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("TenantKey") + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("UpdatedAtUtc") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_at_utc") + .HasDefaultValueSql("now() at time zone 'utc'"); + + b.HasKey("Domain"); + + b.HasIndex("IsActive"); + + b.HasIndex("IsPlatformBaseDomain"); + + b.HasIndex("TenantKey"); + + b.ToTable("tenant_domains", "meta"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Authentications.RolePermission", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.Authentications.Permission", "Permission") + .WithMany("RolePermissions") + .HasForeignKey("PermissionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AMREZ.EOP.Domain.Entities.Authentications.Role", "Role") + .WithMany("RolePermissions") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AMREZ.EOP.Domain.Entities.Authentications.Permission", null) + .WithMany() + .HasForeignKey("TenantId", "PermissionId") + .HasPrincipalKey("TenantId", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AMREZ.EOP.Domain.Entities.Authentications.Role", null) + .WithMany() + .HasForeignKey("TenantId", "RoleId") + .HasPrincipalKey("TenantId", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Permission"); + + b.Navigation("Role"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Authentications.UserExternalAccount", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.Authentications.User", "User") + .WithMany("ExternalAccounts") + .HasForeignKey("TenantId", "UserId") + .HasPrincipalKey("TenantId", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Authentications.UserIdentity", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.Authentications.User", "User") + .WithMany("Identities") + .HasForeignKey("TenantId", "UserId") + .HasPrincipalKey("TenantId", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Authentications.UserMfaFactor", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.Authentications.User", "User") + .WithMany("MfaFactors") + .HasForeignKey("TenantId", "UserId") + .HasPrincipalKey("TenantId", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Authentications.UserPasswordHistory", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.Authentications.User", "User") + .WithMany("PasswordHistories") + .HasForeignKey("TenantId", "UserId") + .HasPrincipalKey("TenantId", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Authentications.UserRole", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.Authentications.Role", "Role") + .WithMany("UserRoles") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AMREZ.EOP.Domain.Entities.Authentications.User", "User") + .WithMany("UserRoles") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AMREZ.EOP.Domain.Entities.Authentications.Role", null) + .WithMany() + .HasForeignKey("TenantId", "RoleId") + .HasPrincipalKey("TenantId", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AMREZ.EOP.Domain.Entities.Authentications.User", null) + .WithMany() + .HasForeignKey("TenantId", "UserId") + .HasPrincipalKey("TenantId", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Authentications.UserSession", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.Authentications.User", "User") + .WithMany("Sessions") + .HasForeignKey("TenantId", "UserId") + .HasPrincipalKey("TenantId", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Customers.CustomerAddress", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.Customers.Address", "Address") + .WithMany("CustomerLinks") + .HasForeignKey("TenantId", "AddressId") + .HasPrincipalKey("TenantId", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AMREZ.EOP.Domain.Entities.Customers.CustomerProfile", "Customer") + .WithMany("Addresses") + .HasForeignKey("TenantId", "CustomerProfileId") + .HasPrincipalKey("TenantId", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Address"); + + b.Navigation("Customer"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Customers.CustomerContact", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.Customers.CustomerProfile", "Customer") + .WithMany("Contacts") + .HasForeignKey("TenantId", "CustomerProfileId") + .HasPrincipalKey("TenantId", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Customer"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Customers.CustomerTag", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.Customers.CustomerProfile", "Customer") + .WithMany("Tags") + .HasForeignKey("TenantId", "CustomerProfileId") + .HasPrincipalKey("TenantId", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Customer"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Customers.OrganizationProfile", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.Customers.CustomerProfile", "Customer") + .WithOne("Organization") + .HasForeignKey("AMREZ.EOP.Domain.Entities.Customers.OrganizationProfile", "TenantId", "CustomerProfileId") + .HasPrincipalKey("AMREZ.EOP.Domain.Entities.Customers.CustomerProfile", "TenantId", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Customer"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Customers.PersonProfile", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.Customers.CustomerProfile", "Customer") + .WithOne("Person") + .HasForeignKey("AMREZ.EOP.Domain.Entities.Customers.PersonProfile", "TenantId", "CustomerProfileId") + .HasPrincipalKey("AMREZ.EOP.Domain.Entities.Customers.CustomerProfile", "TenantId", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Customer"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.HumanResources.Department", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.HumanResources.Department", "Parent") + .WithMany("Children") + .HasForeignKey("TenantId", "ParentDepartmentId") + .HasPrincipalKey("TenantId", "Id") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Parent"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.HumanResources.EmergencyContact", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.HumanResources.UserProfile", "UserProfile") + .WithMany("EmergencyContacts") + .HasForeignKey("TenantId", "UserProfileId") + .HasPrincipalKey("TenantId", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("UserProfile"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.HumanResources.EmployeeAddress", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.HumanResources.UserProfile", "UserProfile") + .WithMany("Addresses") + .HasForeignKey("TenantId", "UserProfileId") + .HasPrincipalKey("TenantId", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("UserProfile"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.HumanResources.EmployeeBankAccount", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.HumanResources.UserProfile", "UserProfile") + .WithMany("BankAccounts") + .HasForeignKey("TenantId", "UserProfileId") + .HasPrincipalKey("TenantId", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("UserProfile"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.HumanResources.Employment", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.HumanResources.Department", "Department") + .WithMany() + .HasForeignKey("TenantId", "DepartmentId") + .HasPrincipalKey("TenantId", "Id") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("AMREZ.EOP.Domain.Entities.HumanResources.Position", "Position") + .WithMany() + .HasForeignKey("TenantId", "PositionId") + .HasPrincipalKey("TenantId", "Id") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("AMREZ.EOP.Domain.Entities.HumanResources.UserProfile", "UserProfile") + .WithMany("Employments") + .HasForeignKey("TenantId", "UserProfileId") + .HasPrincipalKey("TenantId", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Department"); + + b.Navigation("Position"); + + b.Navigation("UserProfile"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.HumanResources.UserProfile", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.HumanResources.Department", null) + .WithMany("Profiles") + .HasForeignKey("DepartmentId"); + + b.HasOne("AMREZ.EOP.Domain.Entities.HumanResources.Position", null) + .WithMany("Profiles") + .HasForeignKey("PositionId"); + + b.HasOne("AMREZ.EOP.Domain.Entities.Authentications.User", "User") + .WithOne() + .HasForeignKey("AMREZ.EOP.Domain.Entities.HumanResources.UserProfile", "TenantId", "UserId") + .HasPrincipalKey("AMREZ.EOP.Domain.Entities.Authentications.User", "TenantId", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.AllergenBlock", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.Allergen", null) + .WithMany() + .HasForeignKey("GlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.BrandBlock", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.Brand", null) + .WithMany() + .HasForeignKey("GlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.Category", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.Category", "Parent") + .WithMany("Children") + .HasForeignKey("TenantId", "ParentId") + .HasPrincipalKey("TenantId", "Id") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Parent"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.CategoryBlock", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.Category", null) + .WithMany() + .HasForeignKey("GlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.CategoryExt", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.Category", "Category") + .WithOne() + .HasForeignKey("AMREZ.EOP.Domain.Entities.MasterData.CategoryExt", "CategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.ComplianceStatusBlock", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.ComplianceStatus", null) + .WithMany() + .HasForeignKey("GlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.CountryBlock", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.Country", null) + .WithMany() + .HasForeignKey("GlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.CurrencyBlock", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.Currency", null) + .WithMany() + .HasForeignKey("GlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.DocControlStatusBlock", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.DocControlStatus", null) + .WithMany() + .HasForeignKey("GlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.FuncTestBlock", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.FuncTest", null) + .WithMany() + .HasForeignKey("GlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.HazardClassBlock", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.HazardClass", null) + .WithMany() + .HasForeignKey("GlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.LanguageBlock", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.Language", null) + .WithMany() + .HasForeignKey("GlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.ManufacturerBlock", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.Manufacturer", null) + .WithMany() + .HasForeignKey("GlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.MarketBlock", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.Market", null) + .WithMany() + .HasForeignKey("GlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.PackingGroupBlock", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.PackingGroup", null) + .WithMany() + .HasForeignKey("GlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.QaStageBlock", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.QaStage", null) + .WithMany() + .HasForeignKey("GlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.QcStatusBlock", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.QcStatus", null) + .WithMany() + .HasForeignKey("GlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.RecallClassBlock", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.RecallClass", null) + .WithMany() + .HasForeignKey("GlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.RiskClassBlock", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.RiskClass", null) + .WithMany() + .HasForeignKey("GlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.RouteBlock", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.Route", null) + .WithMany() + .HasForeignKey("GlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.RxScheduleBlock", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.RxSchedule", null) + .WithMany() + .HasForeignKey("GlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.SpeciesBlock", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.Species", null) + .WithMany() + .HasForeignKey("GlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.StabilityStatusBlock", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.StabilityStatus", null) + .WithMany() + .HasForeignKey("GlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.SterilizationMethodBlock", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.SterilizationMethod", null) + .WithMany() + .HasForeignKey("GlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.UomBlock", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.Uom", null) + .WithMany() + .HasForeignKey("GlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.VvmBlock", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.Vvm", null) + .WithMany() + .HasForeignKey("GlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Tenancy.TenantDomain", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.Tenancy.TenantConfig", null) + .WithMany() + .HasForeignKey("TenantKey") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Authentications.Permission", b => + { + b.Navigation("RolePermissions"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Authentications.Role", b => + { + b.Navigation("RolePermissions"); + + b.Navigation("UserRoles"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Authentications.User", b => + { + b.Navigation("ExternalAccounts"); + + b.Navigation("Identities"); + + b.Navigation("MfaFactors"); + + b.Navigation("PasswordHistories"); + + b.Navigation("Sessions"); + + b.Navigation("UserRoles"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Customers.Address", b => + { + b.Navigation("CustomerLinks"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Customers.CustomerProfile", b => + { + b.Navigation("Addresses"); + + b.Navigation("Contacts"); + + b.Navigation("Organization"); + + b.Navigation("Person"); + + b.Navigation("Tags"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.HumanResources.Department", b => + { + b.Navigation("Children"); + + b.Navigation("Profiles"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.HumanResources.Position", b => + { + b.Navigation("Profiles"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.HumanResources.UserProfile", b => + { + b.Navigation("Addresses"); + + b.Navigation("BankAccounts"); + + b.Navigation("EmergencyContacts"); + + b.Navigation("Employments"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.Category", b => + { + b.Navigation("Children"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/AMREZ.EOP.Infrastructures/Migrations/20251010092049_AddProductMasterData.cs b/AMREZ.EOP.Infrastructures/Migrations/20251010092049_AddProductMasterData.cs new file mode 100644 index 0000000..0125dc3 --- /dev/null +++ b/AMREZ.EOP.Infrastructures/Migrations/20251010092049_AddProductMasterData.cs @@ -0,0 +1,2418 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace AMREZ.EOP.Infrastructures.Migrations +{ + /// + public partial class AddProductMasterData : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.EnsureSchema( + name: "master"); + + migrationBuilder.CreateTable( + name: "allergens", + schema: "master", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false), + Scope = table.Column(type: "text", nullable: false, defaultValue: "global"), + Code = table.Column(type: "text", nullable: false), + Name = table.Column(type: "text", nullable: false), + NameI18n = table.Column(type: "jsonb", nullable: true), + OverridesGlobalId = table.Column(type: "uuid", nullable: true), + IsActive = table.Column(type: "boolean", nullable: false, defaultValue: true), + IsSystem = table.Column(type: "boolean", nullable: false, defaultValue: false), + Meta = table.Column(type: "jsonb", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_allergens", x => x.Id); + table.UniqueConstraint("AK_allergens_tenant_id_Id", x => new { x.tenant_id, x.Id }); + table.CheckConstraint("ck_allergens_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_allergens_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + + migrationBuilder.CreateTable( + name: "brands", + schema: "master", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + ExternalRef = table.Column(type: "text", nullable: true), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false), + Scope = table.Column(type: "text", nullable: false, defaultValue: "global"), + Code = table.Column(type: "text", nullable: false), + Name = table.Column(type: "text", nullable: false), + NameI18n = table.Column(type: "jsonb", nullable: true), + OverridesGlobalId = table.Column(type: "uuid", nullable: true), + IsActive = table.Column(type: "boolean", nullable: false, defaultValue: true), + IsSystem = table.Column(type: "boolean", nullable: false, defaultValue: false), + Meta = table.Column(type: "jsonb", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_brands", x => x.Id); + table.UniqueConstraint("AK_brands_tenant_id_Id", x => new { x.tenant_id, x.Id }); + table.CheckConstraint("ck_brands_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_brands_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + + migrationBuilder.CreateTable( + name: "categories", + schema: "master", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + ParentId = table.Column(type: "uuid", nullable: true), + Path = table.Column(type: "text", nullable: true), + SortOrder = table.Column(type: "integer", nullable: false), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false), + Scope = table.Column(type: "text", nullable: false, defaultValue: "global"), + Code = table.Column(type: "text", nullable: false), + Name = table.Column(type: "text", nullable: false), + NameI18n = table.Column(type: "jsonb", nullable: true), + OverridesGlobalId = table.Column(type: "uuid", nullable: true), + IsActive = table.Column(type: "boolean", nullable: false, defaultValue: true), + IsSystem = table.Column(type: "boolean", nullable: false, defaultValue: false), + Meta = table.Column(type: "jsonb", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_categories", x => x.Id); + table.UniqueConstraint("AK_categories_tenant_id_Id", x => new { x.tenant_id, x.Id }); + table.CheckConstraint("ck_categories_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_categories_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + table.ForeignKey( + name: "FK_categories_categories_tenant_id_ParentId", + columns: x => new { x.tenant_id, x.ParentId }, + principalSchema: "master", + principalTable: "categories", + principalColumns: new[] { "tenant_id", "Id" }, + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "compliance_statuses", + schema: "master", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false), + Scope = table.Column(type: "text", nullable: false, defaultValue: "global"), + Code = table.Column(type: "text", nullable: false), + Name = table.Column(type: "text", nullable: false), + NameI18n = table.Column(type: "jsonb", nullable: true), + OverridesGlobalId = table.Column(type: "uuid", nullable: true), + IsActive = table.Column(type: "boolean", nullable: false, defaultValue: true), + IsSystem = table.Column(type: "boolean", nullable: false, defaultValue: false), + Meta = table.Column(type: "jsonb", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_compliance_statuses", x => x.Id); + table.UniqueConstraint("AK_compliance_statuses_tenant_id_Id", x => new { x.tenant_id, x.Id }); + table.CheckConstraint("ck_compliance_statuses_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_compliance_statuses_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + + migrationBuilder.CreateTable( + name: "countries", + schema: "master", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false), + Scope = table.Column(type: "text", nullable: false, defaultValue: "global"), + Code = table.Column(type: "text", nullable: false), + Name = table.Column(type: "text", nullable: false), + NameI18n = table.Column(type: "jsonb", nullable: true), + OverridesGlobalId = table.Column(type: "uuid", nullable: true), + IsActive = table.Column(type: "boolean", nullable: false, defaultValue: true), + IsSystem = table.Column(type: "boolean", nullable: false, defaultValue: false), + Meta = table.Column(type: "jsonb", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_countries", x => x.Id); + table.UniqueConstraint("AK_countries_tenant_id_Id", x => new { x.tenant_id, x.Id }); + table.CheckConstraint("ck_countries_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_countries_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + + migrationBuilder.CreateTable( + name: "currencies", + schema: "master", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + Exponent = table.Column(type: "smallint", nullable: false), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false), + Scope = table.Column(type: "text", nullable: false, defaultValue: "global"), + Code = table.Column(type: "text", nullable: false), + Name = table.Column(type: "text", nullable: false), + NameI18n = table.Column(type: "jsonb", nullable: true), + OverridesGlobalId = table.Column(type: "uuid", nullable: true), + IsActive = table.Column(type: "boolean", nullable: false, defaultValue: true), + IsSystem = table.Column(type: "boolean", nullable: false, defaultValue: false), + Meta = table.Column(type: "jsonb", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_currencies", x => x.Id); + table.UniqueConstraint("AK_currencies_tenant_id_Id", x => new { x.tenant_id, x.Id }); + table.CheckConstraint("ck_currencies_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_currencies_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + + migrationBuilder.CreateTable( + name: "doc_control_statuses", + schema: "master", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false), + Scope = table.Column(type: "text", nullable: false, defaultValue: "global"), + Code = table.Column(type: "text", nullable: false), + Name = table.Column(type: "text", nullable: false), + NameI18n = table.Column(type: "jsonb", nullable: true), + OverridesGlobalId = table.Column(type: "uuid", nullable: true), + IsActive = table.Column(type: "boolean", nullable: false, defaultValue: true), + IsSystem = table.Column(type: "boolean", nullable: false, defaultValue: false), + Meta = table.Column(type: "jsonb", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_doc_control_statuses", x => x.Id); + table.UniqueConstraint("AK_doc_control_statuses_tenant_id_Id", x => new { x.tenant_id, x.Id }); + table.CheckConstraint("ck_doc_control_statuses_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_doc_control_statuses_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + + migrationBuilder.CreateTable( + name: "func_tests", + schema: "master", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false), + Scope = table.Column(type: "text", nullable: false, defaultValue: "global"), + Code = table.Column(type: "text", nullable: false), + Name = table.Column(type: "text", nullable: false), + NameI18n = table.Column(type: "jsonb", nullable: true), + OverridesGlobalId = table.Column(type: "uuid", nullable: true), + IsActive = table.Column(type: "boolean", nullable: false, defaultValue: true), + IsSystem = table.Column(type: "boolean", nullable: false, defaultValue: false), + Meta = table.Column(type: "jsonb", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_func_tests", x => x.Id); + table.UniqueConstraint("AK_func_tests_tenant_id_Id", x => new { x.tenant_id, x.Id }); + table.CheckConstraint("ck_func_tests_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_func_tests_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + + migrationBuilder.CreateTable( + name: "hazard_classes", + schema: "master", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false), + Scope = table.Column(type: "text", nullable: false, defaultValue: "global"), + Code = table.Column(type: "text", nullable: false), + Name = table.Column(type: "text", nullable: false), + NameI18n = table.Column(type: "jsonb", nullable: true), + OverridesGlobalId = table.Column(type: "uuid", nullable: true), + IsActive = table.Column(type: "boolean", nullable: false, defaultValue: true), + IsSystem = table.Column(type: "boolean", nullable: false, defaultValue: false), + Meta = table.Column(type: "jsonb", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_hazard_classes", x => x.Id); + table.UniqueConstraint("AK_hazard_classes_tenant_id_Id", x => new { x.tenant_id, x.Id }); + table.CheckConstraint("ck_hazard_classes_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_hazard_classes_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + + migrationBuilder.CreateTable( + name: "languages", + schema: "master", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false), + Scope = table.Column(type: "text", nullable: false, defaultValue: "global"), + Code = table.Column(type: "text", nullable: false), + Name = table.Column(type: "text", nullable: false), + NameI18n = table.Column(type: "jsonb", nullable: true), + OverridesGlobalId = table.Column(type: "uuid", nullable: true), + IsActive = table.Column(type: "boolean", nullable: false, defaultValue: true), + IsSystem = table.Column(type: "boolean", nullable: false, defaultValue: false), + Meta = table.Column(type: "jsonb", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_languages", x => x.Id); + table.UniqueConstraint("AK_languages_tenant_id_Id", x => new { x.tenant_id, x.Id }); + table.CheckConstraint("ck_languages_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_languages_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + + migrationBuilder.CreateTable( + name: "manufacturers", + schema: "master", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + CountryCode = table.Column(type: "text", nullable: true), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false), + Scope = table.Column(type: "text", nullable: false, defaultValue: "global"), + Code = table.Column(type: "text", nullable: false), + Name = table.Column(type: "text", nullable: false), + NameI18n = table.Column(type: "jsonb", nullable: true), + OverridesGlobalId = table.Column(type: "uuid", nullable: true), + IsActive = table.Column(type: "boolean", nullable: false, defaultValue: true), + IsSystem = table.Column(type: "boolean", nullable: false, defaultValue: false), + Meta = table.Column(type: "jsonb", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_manufacturers", x => x.Id); + table.UniqueConstraint("AK_manufacturers_tenant_id_Id", x => new { x.tenant_id, x.Id }); + table.CheckConstraint("ck_manufacturers_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_manufacturers_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + + migrationBuilder.CreateTable( + name: "markets", + schema: "master", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false), + Scope = table.Column(type: "text", nullable: false, defaultValue: "global"), + Code = table.Column(type: "text", nullable: false), + Name = table.Column(type: "text", nullable: false), + NameI18n = table.Column(type: "jsonb", nullable: true), + OverridesGlobalId = table.Column(type: "uuid", nullable: true), + IsActive = table.Column(type: "boolean", nullable: false, defaultValue: true), + IsSystem = table.Column(type: "boolean", nullable: false, defaultValue: false), + Meta = table.Column(type: "jsonb", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_markets", x => x.Id); + table.UniqueConstraint("AK_markets_tenant_id_Id", x => new { x.tenant_id, x.Id }); + table.CheckConstraint("ck_markets_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_markets_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + + migrationBuilder.CreateTable( + name: "packing_groups", + schema: "master", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false), + Scope = table.Column(type: "text", nullable: false, defaultValue: "global"), + Code = table.Column(type: "text", nullable: false), + Name = table.Column(type: "text", nullable: false), + NameI18n = table.Column(type: "jsonb", nullable: true), + OverridesGlobalId = table.Column(type: "uuid", nullable: true), + IsActive = table.Column(type: "boolean", nullable: false, defaultValue: true), + IsSystem = table.Column(type: "boolean", nullable: false, defaultValue: false), + Meta = table.Column(type: "jsonb", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_packing_groups", x => x.Id); + table.UniqueConstraint("AK_packing_groups_tenant_id_Id", x => new { x.tenant_id, x.Id }); + table.CheckConstraint("ck_packing_groups_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_packing_groups_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + + migrationBuilder.CreateTable( + name: "qa_stages", + schema: "master", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false), + Scope = table.Column(type: "text", nullable: false, defaultValue: "global"), + Code = table.Column(type: "text", nullable: false), + Name = table.Column(type: "text", nullable: false), + NameI18n = table.Column(type: "jsonb", nullable: true), + OverridesGlobalId = table.Column(type: "uuid", nullable: true), + IsActive = table.Column(type: "boolean", nullable: false, defaultValue: true), + IsSystem = table.Column(type: "boolean", nullable: false, defaultValue: false), + Meta = table.Column(type: "jsonb", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_qa_stages", x => x.Id); + table.UniqueConstraint("AK_qa_stages_tenant_id_Id", x => new { x.tenant_id, x.Id }); + table.CheckConstraint("ck_qa_stages_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_qa_stages_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + + migrationBuilder.CreateTable( + name: "qc_statuses", + schema: "master", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false), + Scope = table.Column(type: "text", nullable: false, defaultValue: "global"), + Code = table.Column(type: "text", nullable: false), + Name = table.Column(type: "text", nullable: false), + NameI18n = table.Column(type: "jsonb", nullable: true), + OverridesGlobalId = table.Column(type: "uuid", nullable: true), + IsActive = table.Column(type: "boolean", nullable: false, defaultValue: true), + IsSystem = table.Column(type: "boolean", nullable: false, defaultValue: false), + Meta = table.Column(type: "jsonb", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_qc_statuses", x => x.Id); + table.UniqueConstraint("AK_qc_statuses_tenant_id_Id", x => new { x.tenant_id, x.Id }); + table.CheckConstraint("ck_qc_statuses_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_qc_statuses_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + + migrationBuilder.CreateTable( + name: "recall_classes", + schema: "master", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false), + Scope = table.Column(type: "text", nullable: false, defaultValue: "global"), + Code = table.Column(type: "text", nullable: false), + Name = table.Column(type: "text", nullable: false), + NameI18n = table.Column(type: "jsonb", nullable: true), + OverridesGlobalId = table.Column(type: "uuid", nullable: true), + IsActive = table.Column(type: "boolean", nullable: false, defaultValue: true), + IsSystem = table.Column(type: "boolean", nullable: false, defaultValue: false), + Meta = table.Column(type: "jsonb", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_recall_classes", x => x.Id); + table.UniqueConstraint("AK_recall_classes_tenant_id_Id", x => new { x.tenant_id, x.Id }); + table.CheckConstraint("ck_recall_classes_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_recall_classes_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + + migrationBuilder.CreateTable( + name: "risk_classes", + schema: "master", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false), + Scope = table.Column(type: "text", nullable: false, defaultValue: "global"), + Code = table.Column(type: "text", nullable: false), + Name = table.Column(type: "text", nullable: false), + NameI18n = table.Column(type: "jsonb", nullable: true), + OverridesGlobalId = table.Column(type: "uuid", nullable: true), + IsActive = table.Column(type: "boolean", nullable: false, defaultValue: true), + IsSystem = table.Column(type: "boolean", nullable: false, defaultValue: false), + Meta = table.Column(type: "jsonb", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_risk_classes", x => x.Id); + table.UniqueConstraint("AK_risk_classes_tenant_id_Id", x => new { x.tenant_id, x.Id }); + table.CheckConstraint("ck_risk_classes_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_risk_classes_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + + migrationBuilder.CreateTable( + name: "routes", + schema: "master", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false), + Scope = table.Column(type: "text", nullable: false, defaultValue: "global"), + Code = table.Column(type: "text", nullable: false), + Name = table.Column(type: "text", nullable: false), + NameI18n = table.Column(type: "jsonb", nullable: true), + OverridesGlobalId = table.Column(type: "uuid", nullable: true), + IsActive = table.Column(type: "boolean", nullable: false, defaultValue: true), + IsSystem = table.Column(type: "boolean", nullable: false, defaultValue: false), + Meta = table.Column(type: "jsonb", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_routes", x => x.Id); + table.UniqueConstraint("AK_routes_tenant_id_Id", x => new { x.tenant_id, x.Id }); + table.CheckConstraint("ck_routes_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_routes_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + + migrationBuilder.CreateTable( + name: "rx_schedules", + schema: "master", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false), + Scope = table.Column(type: "text", nullable: false, defaultValue: "global"), + Code = table.Column(type: "text", nullable: false), + Name = table.Column(type: "text", nullable: false), + NameI18n = table.Column(type: "jsonb", nullable: true), + OverridesGlobalId = table.Column(type: "uuid", nullable: true), + IsActive = table.Column(type: "boolean", nullable: false, defaultValue: true), + IsSystem = table.Column(type: "boolean", nullable: false, defaultValue: false), + Meta = table.Column(type: "jsonb", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_rx_schedules", x => x.Id); + table.UniqueConstraint("AK_rx_schedules_tenant_id_Id", x => new { x.tenant_id, x.Id }); + table.CheckConstraint("ck_rx_schedules_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_rx_schedules_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + + migrationBuilder.CreateTable( + name: "species", + schema: "master", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false), + Scope = table.Column(type: "text", nullable: false, defaultValue: "global"), + Code = table.Column(type: "text", nullable: false), + Name = table.Column(type: "text", nullable: false), + NameI18n = table.Column(type: "jsonb", nullable: true), + OverridesGlobalId = table.Column(type: "uuid", nullable: true), + IsActive = table.Column(type: "boolean", nullable: false, defaultValue: true), + IsSystem = table.Column(type: "boolean", nullable: false, defaultValue: false), + Meta = table.Column(type: "jsonb", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_species", x => x.Id); + table.UniqueConstraint("AK_species_tenant_id_Id", x => new { x.tenant_id, x.Id }); + table.CheckConstraint("ck_species_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_species_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + + migrationBuilder.CreateTable( + name: "stability_statuses", + schema: "master", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false), + Scope = table.Column(type: "text", nullable: false, defaultValue: "global"), + Code = table.Column(type: "text", nullable: false), + Name = table.Column(type: "text", nullable: false), + NameI18n = table.Column(type: "jsonb", nullable: true), + OverridesGlobalId = table.Column(type: "uuid", nullable: true), + IsActive = table.Column(type: "boolean", nullable: false, defaultValue: true), + IsSystem = table.Column(type: "boolean", nullable: false, defaultValue: false), + Meta = table.Column(type: "jsonb", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_stability_statuses", x => x.Id); + table.UniqueConstraint("AK_stability_statuses_tenant_id_Id", x => new { x.tenant_id, x.Id }); + table.CheckConstraint("ck_stability_statuses_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_stability_statuses_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + + migrationBuilder.CreateTable( + name: "sterilization_methods", + schema: "master", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false), + Scope = table.Column(type: "text", nullable: false, defaultValue: "global"), + Code = table.Column(type: "text", nullable: false), + Name = table.Column(type: "text", nullable: false), + NameI18n = table.Column(type: "jsonb", nullable: true), + OverridesGlobalId = table.Column(type: "uuid", nullable: true), + IsActive = table.Column(type: "boolean", nullable: false, defaultValue: true), + IsSystem = table.Column(type: "boolean", nullable: false, defaultValue: false), + Meta = table.Column(type: "jsonb", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_sterilization_methods", x => x.Id); + table.UniqueConstraint("AK_sterilization_methods_tenant_id_Id", x => new { x.tenant_id, x.Id }); + table.CheckConstraint("ck_sterilization_methods_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_sterilization_methods_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + + migrationBuilder.CreateTable( + name: "uoms", + schema: "master", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + BaseCode = table.Column(type: "text", nullable: true), + SiFactor = table.Column(type: "numeric", nullable: true), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false), + Scope = table.Column(type: "text", nullable: false, defaultValue: "global"), + Code = table.Column(type: "text", nullable: false), + Name = table.Column(type: "text", nullable: false), + NameI18n = table.Column(type: "jsonb", nullable: true), + OverridesGlobalId = table.Column(type: "uuid", nullable: true), + IsActive = table.Column(type: "boolean", nullable: false, defaultValue: true), + IsSystem = table.Column(type: "boolean", nullable: false, defaultValue: false), + Meta = table.Column(type: "jsonb", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_uoms", x => x.Id); + table.UniqueConstraint("AK_uoms_tenant_id_Id", x => new { x.tenant_id, x.Id }); + table.CheckConstraint("ck_uoms_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_uoms_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + + migrationBuilder.CreateTable( + name: "vvms", + schema: "master", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false), + Scope = table.Column(type: "text", nullable: false, defaultValue: "global"), + Code = table.Column(type: "text", nullable: false), + Name = table.Column(type: "text", nullable: false), + NameI18n = table.Column(type: "jsonb", nullable: true), + OverridesGlobalId = table.Column(type: "uuid", nullable: true), + IsActive = table.Column(type: "boolean", nullable: false, defaultValue: true), + IsSystem = table.Column(type: "boolean", nullable: false, defaultValue: false), + Meta = table.Column(type: "jsonb", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_vvms", x => x.Id); + table.UniqueConstraint("AK_vvms_tenant_id_Id", x => new { x.tenant_id, x.Id }); + table.CheckConstraint("ck_vvms_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_vvms_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + + migrationBuilder.CreateTable( + name: "allergen_blocks", + schema: "master", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false), + GlobalId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_allergen_blocks", x => x.Id); + table.CheckConstraint("ck_allergen_blocks_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_allergen_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + table.ForeignKey( + name: "FK_allergen_blocks_allergens_GlobalId", + column: x => x.GlobalId, + principalSchema: "master", + principalTable: "allergens", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "brand_blocks", + schema: "master", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false), + GlobalId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_brand_blocks", x => x.Id); + table.CheckConstraint("ck_brand_blocks_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_brand_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + table.ForeignKey( + name: "FK_brand_blocks_brands_GlobalId", + column: x => x.GlobalId, + principalSchema: "master", + principalTable: "brands", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "category_blocks", + schema: "master", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false), + GlobalId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_category_blocks", x => x.Id); + table.CheckConstraint("ck_category_blocks_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_category_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + table.ForeignKey( + name: "FK_category_blocks_categories_GlobalId", + column: x => x.GlobalId, + principalSchema: "master", + principalTable: "categories", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "category_exts", + schema: "master", + columns: table => new + { + CategoryId = table.Column(type: "uuid", nullable: false), + Slug = table.Column(type: "text", nullable: true), + SeoTitle = table.Column(type: "text", nullable: true), + SeoDescription = table.Column(type: "text", nullable: true), + ImageUrl = table.Column(type: "text", nullable: true), + ChannelVisibility = table.Column(type: "jsonb", nullable: true), + FacetSchema = table.Column(type: "jsonb", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_category_exts", x => x.CategoryId); + table.ForeignKey( + name: "FK_category_exts_categories_CategoryId", + column: x => x.CategoryId, + principalSchema: "master", + principalTable: "categories", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "compliance_status_blocks", + schema: "master", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false), + GlobalId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_compliance_status_blocks", x => x.Id); + table.CheckConstraint("ck_compliance_status_blocks_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_compliance_status_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + table.ForeignKey( + name: "FK_compliance_status_blocks_compliance_statuses_GlobalId", + column: x => x.GlobalId, + principalSchema: "master", + principalTable: "compliance_statuses", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "country_blocks", + schema: "master", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false), + GlobalId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_country_blocks", x => x.Id); + table.CheckConstraint("ck_country_blocks_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_country_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + table.ForeignKey( + name: "FK_country_blocks_countries_GlobalId", + column: x => x.GlobalId, + principalSchema: "master", + principalTable: "countries", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "currency_blocks", + schema: "master", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false), + GlobalId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_currency_blocks", x => x.Id); + table.CheckConstraint("ck_currency_blocks_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_currency_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + table.ForeignKey( + name: "FK_currency_blocks_currencies_GlobalId", + column: x => x.GlobalId, + principalSchema: "master", + principalTable: "currencies", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "doc_control_status_blocks", + schema: "master", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false), + GlobalId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_doc_control_status_blocks", x => x.Id); + table.CheckConstraint("ck_doc_control_status_blocks_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_doc_control_status_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + table.ForeignKey( + name: "FK_doc_control_status_blocks_doc_control_statuses_GlobalId", + column: x => x.GlobalId, + principalSchema: "master", + principalTable: "doc_control_statuses", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "func_test_blocks", + schema: "master", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false), + GlobalId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_func_test_blocks", x => x.Id); + table.CheckConstraint("ck_func_test_blocks_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_func_test_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + table.ForeignKey( + name: "FK_func_test_blocks_func_tests_GlobalId", + column: x => x.GlobalId, + principalSchema: "master", + principalTable: "func_tests", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "hazard_class_blocks", + schema: "master", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false), + GlobalId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_hazard_class_blocks", x => x.Id); + table.CheckConstraint("ck_hazard_class_blocks_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_hazard_class_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + table.ForeignKey( + name: "FK_hazard_class_blocks_hazard_classes_GlobalId", + column: x => x.GlobalId, + principalSchema: "master", + principalTable: "hazard_classes", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "language_blocks", + schema: "master", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false), + GlobalId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_language_blocks", x => x.Id); + table.CheckConstraint("ck_language_blocks_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_language_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + table.ForeignKey( + name: "FK_language_blocks_languages_GlobalId", + column: x => x.GlobalId, + principalSchema: "master", + principalTable: "languages", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "manufacturer_blocks", + schema: "master", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false), + GlobalId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_manufacturer_blocks", x => x.Id); + table.CheckConstraint("ck_manufacturer_blocks_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_manufacturer_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + table.ForeignKey( + name: "FK_manufacturer_blocks_manufacturers_GlobalId", + column: x => x.GlobalId, + principalSchema: "master", + principalTable: "manufacturers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "market_blocks", + schema: "master", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false), + GlobalId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_market_blocks", x => x.Id); + table.CheckConstraint("ck_market_blocks_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_market_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + table.ForeignKey( + name: "FK_market_blocks_markets_GlobalId", + column: x => x.GlobalId, + principalSchema: "master", + principalTable: "markets", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "packing_group_blocks", + schema: "master", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false), + GlobalId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_packing_group_blocks", x => x.Id); + table.CheckConstraint("ck_packing_group_blocks_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_packing_group_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + table.ForeignKey( + name: "FK_packing_group_blocks_packing_groups_GlobalId", + column: x => x.GlobalId, + principalSchema: "master", + principalTable: "packing_groups", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "qa_stage_blocks", + schema: "master", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false), + GlobalId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_qa_stage_blocks", x => x.Id); + table.CheckConstraint("ck_qa_stage_blocks_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_qa_stage_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + table.ForeignKey( + name: "FK_qa_stage_blocks_qa_stages_GlobalId", + column: x => x.GlobalId, + principalSchema: "master", + principalTable: "qa_stages", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "qc_status_blocks", + schema: "master", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false), + GlobalId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_qc_status_blocks", x => x.Id); + table.CheckConstraint("ck_qc_status_blocks_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_qc_status_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + table.ForeignKey( + name: "FK_qc_status_blocks_qc_statuses_GlobalId", + column: x => x.GlobalId, + principalSchema: "master", + principalTable: "qc_statuses", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "recall_class_blocks", + schema: "master", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false), + GlobalId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_recall_class_blocks", x => x.Id); + table.CheckConstraint("ck_recall_class_blocks_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_recall_class_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + table.ForeignKey( + name: "FK_recall_class_blocks_recall_classes_GlobalId", + column: x => x.GlobalId, + principalSchema: "master", + principalTable: "recall_classes", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "risk_class_blocks", + schema: "master", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false), + GlobalId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_risk_class_blocks", x => x.Id); + table.CheckConstraint("ck_risk_class_blocks_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_risk_class_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + table.ForeignKey( + name: "FK_risk_class_blocks_risk_classes_GlobalId", + column: x => x.GlobalId, + principalSchema: "master", + principalTable: "risk_classes", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "route_blocks", + schema: "master", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false), + GlobalId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_route_blocks", x => x.Id); + table.CheckConstraint("ck_route_blocks_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_route_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + table.ForeignKey( + name: "FK_route_blocks_routes_GlobalId", + column: x => x.GlobalId, + principalSchema: "master", + principalTable: "routes", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "rx_schedule_blocks", + schema: "master", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false), + GlobalId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_rx_schedule_blocks", x => x.Id); + table.CheckConstraint("ck_rx_schedule_blocks_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_rx_schedule_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + table.ForeignKey( + name: "FK_rx_schedule_blocks_rx_schedules_GlobalId", + column: x => x.GlobalId, + principalSchema: "master", + principalTable: "rx_schedules", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "species_blocks", + schema: "master", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false), + GlobalId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_species_blocks", x => x.Id); + table.CheckConstraint("ck_species_blocks_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_species_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + table.ForeignKey( + name: "FK_species_blocks_species_GlobalId", + column: x => x.GlobalId, + principalSchema: "master", + principalTable: "species", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "stability_status_blocks", + schema: "master", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false), + GlobalId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_stability_status_blocks", x => x.Id); + table.CheckConstraint("ck_stability_status_blocks_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_stability_status_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + table.ForeignKey( + name: "FK_stability_status_blocks_stability_statuses_GlobalId", + column: x => x.GlobalId, + principalSchema: "master", + principalTable: "stability_statuses", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "sterilization_method_blocks", + schema: "master", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false), + GlobalId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_sterilization_method_blocks", x => x.Id); + table.CheckConstraint("ck_sterilization_method_blocks_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_sterilization_method_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + table.ForeignKey( + name: "FK_sterilization_method_blocks_sterilization_methods_GlobalId", + column: x => x.GlobalId, + principalSchema: "master", + principalTable: "sterilization_methods", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "uom_blocks", + schema: "master", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false), + GlobalId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_uom_blocks", x => x.Id); + table.CheckConstraint("ck_uom_blocks_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_uom_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + table.ForeignKey( + name: "FK_uom_blocks_uoms_GlobalId", + column: x => x.GlobalId, + principalSchema: "master", + principalTable: "uoms", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "vvm_blocks", + schema: "master", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + tenant_id = table.Column(type: "uuid", nullable: false), + created_at = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now() at time zone 'utc'"), + created_by = table.Column(type: "text", nullable: true), + updated_at = table.Column(type: "timestamp with time zone", nullable: true), + updated_by = table.Column(type: "text", nullable: true), + is_deleted = table.Column(type: "boolean", nullable: false, defaultValue: false), + GlobalId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_vvm_blocks", x => x.Id); + table.CheckConstraint("ck_vvm_blocks_tenant_not_null", "tenant_id is not null"); + table.CheckConstraint("ck_vvm_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + table.ForeignKey( + name: "FK_vvm_blocks_vvms_GlobalId", + column: x => x.GlobalId, + principalSchema: "master", + principalTable: "vvms", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_allergen_blocks_GlobalId", + schema: "master", + table: "allergen_blocks", + column: "GlobalId"); + + migrationBuilder.CreateIndex( + name: "IX_allergen_blocks_tenant_id", + schema: "master", + table: "allergen_blocks", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_allergen_blocks_tenant_id_GlobalId", + schema: "master", + table: "allergen_blocks", + columns: new[] { "tenant_id", "GlobalId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_allergens_Scope_tenant_id_Code", + schema: "master", + table: "allergens", + columns: new[] { "Scope", "tenant_id", "Code" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_allergens_tenant_id", + schema: "master", + table: "allergens", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_brand_blocks_GlobalId", + schema: "master", + table: "brand_blocks", + column: "GlobalId"); + + migrationBuilder.CreateIndex( + name: "IX_brand_blocks_tenant_id", + schema: "master", + table: "brand_blocks", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_brand_blocks_tenant_id_GlobalId", + schema: "master", + table: "brand_blocks", + columns: new[] { "tenant_id", "GlobalId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_brands_Scope_tenant_id_Code", + schema: "master", + table: "brands", + columns: new[] { "Scope", "tenant_id", "Code" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_brands_tenant_id", + schema: "master", + table: "brands", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_categories_ParentId", + schema: "master", + table: "categories", + column: "ParentId"); + + migrationBuilder.CreateIndex( + name: "IX_categories_Path", + schema: "master", + table: "categories", + column: "Path"); + + migrationBuilder.CreateIndex( + name: "IX_categories_Scope_tenant_id_Code", + schema: "master", + table: "categories", + columns: new[] { "Scope", "tenant_id", "Code" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_categories_Scope_tenant_id_SortOrder", + schema: "master", + table: "categories", + columns: new[] { "Scope", "tenant_id", "SortOrder" }); + + migrationBuilder.CreateIndex( + name: "IX_categories_tenant_id", + schema: "master", + table: "categories", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_categories_tenant_id_ParentId", + schema: "master", + table: "categories", + columns: new[] { "tenant_id", "ParentId" }); + + migrationBuilder.CreateIndex( + name: "IX_category_blocks_GlobalId", + schema: "master", + table: "category_blocks", + column: "GlobalId"); + + migrationBuilder.CreateIndex( + name: "IX_category_blocks_tenant_id", + schema: "master", + table: "category_blocks", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_category_blocks_tenant_id_GlobalId", + schema: "master", + table: "category_blocks", + columns: new[] { "tenant_id", "GlobalId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_compliance_status_blocks_GlobalId", + schema: "master", + table: "compliance_status_blocks", + column: "GlobalId"); + + migrationBuilder.CreateIndex( + name: "IX_compliance_status_blocks_tenant_id", + schema: "master", + table: "compliance_status_blocks", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_compliance_status_blocks_tenant_id_GlobalId", + schema: "master", + table: "compliance_status_blocks", + columns: new[] { "tenant_id", "GlobalId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_compliance_statuses_Scope_tenant_id_Code", + schema: "master", + table: "compliance_statuses", + columns: new[] { "Scope", "tenant_id", "Code" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_compliance_statuses_tenant_id", + schema: "master", + table: "compliance_statuses", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_countries_Scope_tenant_id_Code", + schema: "master", + table: "countries", + columns: new[] { "Scope", "tenant_id", "Code" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_countries_tenant_id", + schema: "master", + table: "countries", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_country_blocks_GlobalId", + schema: "master", + table: "country_blocks", + column: "GlobalId"); + + migrationBuilder.CreateIndex( + name: "IX_country_blocks_tenant_id", + schema: "master", + table: "country_blocks", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_country_blocks_tenant_id_GlobalId", + schema: "master", + table: "country_blocks", + columns: new[] { "tenant_id", "GlobalId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_currencies_Scope_tenant_id_Code", + schema: "master", + table: "currencies", + columns: new[] { "Scope", "tenant_id", "Code" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_currencies_tenant_id", + schema: "master", + table: "currencies", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_currency_blocks_GlobalId", + schema: "master", + table: "currency_blocks", + column: "GlobalId"); + + migrationBuilder.CreateIndex( + name: "IX_currency_blocks_tenant_id", + schema: "master", + table: "currency_blocks", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_currency_blocks_tenant_id_GlobalId", + schema: "master", + table: "currency_blocks", + columns: new[] { "tenant_id", "GlobalId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_doc_control_status_blocks_GlobalId", + schema: "master", + table: "doc_control_status_blocks", + column: "GlobalId"); + + migrationBuilder.CreateIndex( + name: "IX_doc_control_status_blocks_tenant_id", + schema: "master", + table: "doc_control_status_blocks", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_doc_control_status_blocks_tenant_id_GlobalId", + schema: "master", + table: "doc_control_status_blocks", + columns: new[] { "tenant_id", "GlobalId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_doc_control_statuses_Scope_tenant_id_Code", + schema: "master", + table: "doc_control_statuses", + columns: new[] { "Scope", "tenant_id", "Code" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_doc_control_statuses_tenant_id", + schema: "master", + table: "doc_control_statuses", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_func_test_blocks_GlobalId", + schema: "master", + table: "func_test_blocks", + column: "GlobalId"); + + migrationBuilder.CreateIndex( + name: "IX_func_test_blocks_tenant_id", + schema: "master", + table: "func_test_blocks", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_func_test_blocks_tenant_id_GlobalId", + schema: "master", + table: "func_test_blocks", + columns: new[] { "tenant_id", "GlobalId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_func_tests_Scope_tenant_id_Code", + schema: "master", + table: "func_tests", + columns: new[] { "Scope", "tenant_id", "Code" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_func_tests_tenant_id", + schema: "master", + table: "func_tests", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_hazard_class_blocks_GlobalId", + schema: "master", + table: "hazard_class_blocks", + column: "GlobalId"); + + migrationBuilder.CreateIndex( + name: "IX_hazard_class_blocks_tenant_id", + schema: "master", + table: "hazard_class_blocks", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_hazard_class_blocks_tenant_id_GlobalId", + schema: "master", + table: "hazard_class_blocks", + columns: new[] { "tenant_id", "GlobalId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_hazard_classes_Scope_tenant_id_Code", + schema: "master", + table: "hazard_classes", + columns: new[] { "Scope", "tenant_id", "Code" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_hazard_classes_tenant_id", + schema: "master", + table: "hazard_classes", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_language_blocks_GlobalId", + schema: "master", + table: "language_blocks", + column: "GlobalId"); + + migrationBuilder.CreateIndex( + name: "IX_language_blocks_tenant_id", + schema: "master", + table: "language_blocks", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_language_blocks_tenant_id_GlobalId", + schema: "master", + table: "language_blocks", + columns: new[] { "tenant_id", "GlobalId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_languages_Scope_tenant_id_Code", + schema: "master", + table: "languages", + columns: new[] { "Scope", "tenant_id", "Code" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_languages_tenant_id", + schema: "master", + table: "languages", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_manufacturer_blocks_GlobalId", + schema: "master", + table: "manufacturer_blocks", + column: "GlobalId"); + + migrationBuilder.CreateIndex( + name: "IX_manufacturer_blocks_tenant_id", + schema: "master", + table: "manufacturer_blocks", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_manufacturer_blocks_tenant_id_GlobalId", + schema: "master", + table: "manufacturer_blocks", + columns: new[] { "tenant_id", "GlobalId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_manufacturers_Scope_tenant_id_Code", + schema: "master", + table: "manufacturers", + columns: new[] { "Scope", "tenant_id", "Code" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_manufacturers_tenant_id", + schema: "master", + table: "manufacturers", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_market_blocks_GlobalId", + schema: "master", + table: "market_blocks", + column: "GlobalId"); + + migrationBuilder.CreateIndex( + name: "IX_market_blocks_tenant_id", + schema: "master", + table: "market_blocks", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_market_blocks_tenant_id_GlobalId", + schema: "master", + table: "market_blocks", + columns: new[] { "tenant_id", "GlobalId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_markets_Scope_tenant_id_Code", + schema: "master", + table: "markets", + columns: new[] { "Scope", "tenant_id", "Code" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_markets_tenant_id", + schema: "master", + table: "markets", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_packing_group_blocks_GlobalId", + schema: "master", + table: "packing_group_blocks", + column: "GlobalId"); + + migrationBuilder.CreateIndex( + name: "IX_packing_group_blocks_tenant_id", + schema: "master", + table: "packing_group_blocks", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_packing_group_blocks_tenant_id_GlobalId", + schema: "master", + table: "packing_group_blocks", + columns: new[] { "tenant_id", "GlobalId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_packing_groups_Scope_tenant_id_Code", + schema: "master", + table: "packing_groups", + columns: new[] { "Scope", "tenant_id", "Code" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_packing_groups_tenant_id", + schema: "master", + table: "packing_groups", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_qa_stage_blocks_GlobalId", + schema: "master", + table: "qa_stage_blocks", + column: "GlobalId"); + + migrationBuilder.CreateIndex( + name: "IX_qa_stage_blocks_tenant_id", + schema: "master", + table: "qa_stage_blocks", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_qa_stage_blocks_tenant_id_GlobalId", + schema: "master", + table: "qa_stage_blocks", + columns: new[] { "tenant_id", "GlobalId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_qa_stages_Scope_tenant_id_Code", + schema: "master", + table: "qa_stages", + columns: new[] { "Scope", "tenant_id", "Code" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_qa_stages_tenant_id", + schema: "master", + table: "qa_stages", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_qc_status_blocks_GlobalId", + schema: "master", + table: "qc_status_blocks", + column: "GlobalId"); + + migrationBuilder.CreateIndex( + name: "IX_qc_status_blocks_tenant_id", + schema: "master", + table: "qc_status_blocks", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_qc_status_blocks_tenant_id_GlobalId", + schema: "master", + table: "qc_status_blocks", + columns: new[] { "tenant_id", "GlobalId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_qc_statuses_Scope_tenant_id_Code", + schema: "master", + table: "qc_statuses", + columns: new[] { "Scope", "tenant_id", "Code" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_qc_statuses_tenant_id", + schema: "master", + table: "qc_statuses", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_recall_class_blocks_GlobalId", + schema: "master", + table: "recall_class_blocks", + column: "GlobalId"); + + migrationBuilder.CreateIndex( + name: "IX_recall_class_blocks_tenant_id", + schema: "master", + table: "recall_class_blocks", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_recall_class_blocks_tenant_id_GlobalId", + schema: "master", + table: "recall_class_blocks", + columns: new[] { "tenant_id", "GlobalId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_recall_classes_Scope_tenant_id_Code", + schema: "master", + table: "recall_classes", + columns: new[] { "Scope", "tenant_id", "Code" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_recall_classes_tenant_id", + schema: "master", + table: "recall_classes", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_risk_class_blocks_GlobalId", + schema: "master", + table: "risk_class_blocks", + column: "GlobalId"); + + migrationBuilder.CreateIndex( + name: "IX_risk_class_blocks_tenant_id", + schema: "master", + table: "risk_class_blocks", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_risk_class_blocks_tenant_id_GlobalId", + schema: "master", + table: "risk_class_blocks", + columns: new[] { "tenant_id", "GlobalId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_risk_classes_Scope_tenant_id_Code", + schema: "master", + table: "risk_classes", + columns: new[] { "Scope", "tenant_id", "Code" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_risk_classes_tenant_id", + schema: "master", + table: "risk_classes", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_route_blocks_GlobalId", + schema: "master", + table: "route_blocks", + column: "GlobalId"); + + migrationBuilder.CreateIndex( + name: "IX_route_blocks_tenant_id", + schema: "master", + table: "route_blocks", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_route_blocks_tenant_id_GlobalId", + schema: "master", + table: "route_blocks", + columns: new[] { "tenant_id", "GlobalId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_routes_Scope_tenant_id_Code", + schema: "master", + table: "routes", + columns: new[] { "Scope", "tenant_id", "Code" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_routes_tenant_id", + schema: "master", + table: "routes", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_rx_schedule_blocks_GlobalId", + schema: "master", + table: "rx_schedule_blocks", + column: "GlobalId"); + + migrationBuilder.CreateIndex( + name: "IX_rx_schedule_blocks_tenant_id", + schema: "master", + table: "rx_schedule_blocks", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_rx_schedule_blocks_tenant_id_GlobalId", + schema: "master", + table: "rx_schedule_blocks", + columns: new[] { "tenant_id", "GlobalId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_rx_schedules_Scope_tenant_id_Code", + schema: "master", + table: "rx_schedules", + columns: new[] { "Scope", "tenant_id", "Code" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_rx_schedules_tenant_id", + schema: "master", + table: "rx_schedules", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_species_Scope_tenant_id_Code", + schema: "master", + table: "species", + columns: new[] { "Scope", "tenant_id", "Code" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_species_tenant_id", + schema: "master", + table: "species", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_species_blocks_GlobalId", + schema: "master", + table: "species_blocks", + column: "GlobalId"); + + migrationBuilder.CreateIndex( + name: "IX_species_blocks_tenant_id", + schema: "master", + table: "species_blocks", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_species_blocks_tenant_id_GlobalId", + schema: "master", + table: "species_blocks", + columns: new[] { "tenant_id", "GlobalId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_stability_status_blocks_GlobalId", + schema: "master", + table: "stability_status_blocks", + column: "GlobalId"); + + migrationBuilder.CreateIndex( + name: "IX_stability_status_blocks_tenant_id", + schema: "master", + table: "stability_status_blocks", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_stability_status_blocks_tenant_id_GlobalId", + schema: "master", + table: "stability_status_blocks", + columns: new[] { "tenant_id", "GlobalId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_stability_statuses_Scope_tenant_id_Code", + schema: "master", + table: "stability_statuses", + columns: new[] { "Scope", "tenant_id", "Code" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_stability_statuses_tenant_id", + schema: "master", + table: "stability_statuses", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_sterilization_method_blocks_GlobalId", + schema: "master", + table: "sterilization_method_blocks", + column: "GlobalId"); + + migrationBuilder.CreateIndex( + name: "IX_sterilization_method_blocks_tenant_id", + schema: "master", + table: "sterilization_method_blocks", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_sterilization_method_blocks_tenant_id_GlobalId", + schema: "master", + table: "sterilization_method_blocks", + columns: new[] { "tenant_id", "GlobalId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_sterilization_methods_Scope_tenant_id_Code", + schema: "master", + table: "sterilization_methods", + columns: new[] { "Scope", "tenant_id", "Code" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_sterilization_methods_tenant_id", + schema: "master", + table: "sterilization_methods", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_uom_blocks_GlobalId", + schema: "master", + table: "uom_blocks", + column: "GlobalId"); + + migrationBuilder.CreateIndex( + name: "IX_uom_blocks_tenant_id", + schema: "master", + table: "uom_blocks", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_uom_blocks_tenant_id_GlobalId", + schema: "master", + table: "uom_blocks", + columns: new[] { "tenant_id", "GlobalId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_uoms_Scope_tenant_id_Code", + schema: "master", + table: "uoms", + columns: new[] { "Scope", "tenant_id", "Code" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_uoms_tenant_id", + schema: "master", + table: "uoms", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_vvm_blocks_GlobalId", + schema: "master", + table: "vvm_blocks", + column: "GlobalId"); + + migrationBuilder.CreateIndex( + name: "IX_vvm_blocks_tenant_id", + schema: "master", + table: "vvm_blocks", + column: "tenant_id"); + + migrationBuilder.CreateIndex( + name: "IX_vvm_blocks_tenant_id_GlobalId", + schema: "master", + table: "vvm_blocks", + columns: new[] { "tenant_id", "GlobalId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_vvms_Scope_tenant_id_Code", + schema: "master", + table: "vvms", + columns: new[] { "Scope", "tenant_id", "Code" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_vvms_tenant_id", + schema: "master", + table: "vvms", + column: "tenant_id"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "allergen_blocks", + schema: "master"); + + migrationBuilder.DropTable( + name: "brand_blocks", + schema: "master"); + + migrationBuilder.DropTable( + name: "category_blocks", + schema: "master"); + + migrationBuilder.DropTable( + name: "category_exts", + schema: "master"); + + migrationBuilder.DropTable( + name: "compliance_status_blocks", + schema: "master"); + + migrationBuilder.DropTable( + name: "country_blocks", + schema: "master"); + + migrationBuilder.DropTable( + name: "currency_blocks", + schema: "master"); + + migrationBuilder.DropTable( + name: "doc_control_status_blocks", + schema: "master"); + + migrationBuilder.DropTable( + name: "func_test_blocks", + schema: "master"); + + migrationBuilder.DropTable( + name: "hazard_class_blocks", + schema: "master"); + + migrationBuilder.DropTable( + name: "language_blocks", + schema: "master"); + + migrationBuilder.DropTable( + name: "manufacturer_blocks", + schema: "master"); + + migrationBuilder.DropTable( + name: "market_blocks", + schema: "master"); + + migrationBuilder.DropTable( + name: "packing_group_blocks", + schema: "master"); + + migrationBuilder.DropTable( + name: "qa_stage_blocks", + schema: "master"); + + migrationBuilder.DropTable( + name: "qc_status_blocks", + schema: "master"); + + migrationBuilder.DropTable( + name: "recall_class_blocks", + schema: "master"); + + migrationBuilder.DropTable( + name: "risk_class_blocks", + schema: "master"); + + migrationBuilder.DropTable( + name: "route_blocks", + schema: "master"); + + migrationBuilder.DropTable( + name: "rx_schedule_blocks", + schema: "master"); + + migrationBuilder.DropTable( + name: "species_blocks", + schema: "master"); + + migrationBuilder.DropTable( + name: "stability_status_blocks", + schema: "master"); + + migrationBuilder.DropTable( + name: "sterilization_method_blocks", + schema: "master"); + + migrationBuilder.DropTable( + name: "uom_blocks", + schema: "master"); + + migrationBuilder.DropTable( + name: "vvm_blocks", + schema: "master"); + + migrationBuilder.DropTable( + name: "allergens", + schema: "master"); + + migrationBuilder.DropTable( + name: "brands", + schema: "master"); + + migrationBuilder.DropTable( + name: "categories", + schema: "master"); + + migrationBuilder.DropTable( + name: "compliance_statuses", + schema: "master"); + + migrationBuilder.DropTable( + name: "countries", + schema: "master"); + + migrationBuilder.DropTable( + name: "currencies", + schema: "master"); + + migrationBuilder.DropTable( + name: "doc_control_statuses", + schema: "master"); + + migrationBuilder.DropTable( + name: "func_tests", + schema: "master"); + + migrationBuilder.DropTable( + name: "hazard_classes", + schema: "master"); + + migrationBuilder.DropTable( + name: "languages", + schema: "master"); + + migrationBuilder.DropTable( + name: "manufacturers", + schema: "master"); + + migrationBuilder.DropTable( + name: "markets", + schema: "master"); + + migrationBuilder.DropTable( + name: "packing_groups", + schema: "master"); + + migrationBuilder.DropTable( + name: "qa_stages", + schema: "master"); + + migrationBuilder.DropTable( + name: "qc_statuses", + schema: "master"); + + migrationBuilder.DropTable( + name: "recall_classes", + schema: "master"); + + migrationBuilder.DropTable( + name: "risk_classes", + schema: "master"); + + migrationBuilder.DropTable( + name: "routes", + schema: "master"); + + migrationBuilder.DropTable( + name: "rx_schedules", + schema: "master"); + + migrationBuilder.DropTable( + name: "species", + schema: "master"); + + migrationBuilder.DropTable( + name: "stability_statuses", + schema: "master"); + + migrationBuilder.DropTable( + name: "sterilization_methods", + schema: "master"); + + migrationBuilder.DropTable( + name: "uoms", + schema: "master"); + + migrationBuilder.DropTable( + name: "vvms", + schema: "master"); + } + } +} diff --git a/AMREZ.EOP.Infrastructures/Migrations/AppDbContextModelSnapshot.cs b/AMREZ.EOP.Infrastructures/Migrations/AppDbContextModelSnapshot.cs index 8b6e62c..8668aea 100644 --- a/AMREZ.EOP.Infrastructures/Migrations/AppDbContextModelSnapshot.cs +++ b/AMREZ.EOP.Infrastructures/Migrations/AppDbContextModelSnapshot.cs @@ -687,6 +687,525 @@ namespace AMREZ.EOP.Infrastructures.Migrations }); }); + 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") @@ -1204,6 +1723,3376 @@ namespace AMREZ.EOP.Infrastructures.Migrations }); }); + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.Allergen", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .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("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("IsSystem") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("Meta") + .HasColumnType("jsonb"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameI18n") + .HasColumnType("jsonb"); + + b.Property("OverridesGlobalId") + .HasColumnType("uuid"); + + b.Property("Scope") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue("global"); + + 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.HasAlternateKey("TenantId", "Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("Scope", "TenantId", "Code") + .IsUnique(); + + b.ToTable("allergens", "master", t => + { + t.HasCheckConstraint("ck_allergens_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_allergens_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.AllergenBlock", 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("GlobalId") + .HasColumnType("uuid"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + 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("GlobalId"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "GlobalId") + .IsUnique(); + + b.ToTable("allergen_blocks", "master", t => + { + t.HasCheckConstraint("ck_allergen_blocks_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_allergen_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.Brand", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .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("ExternalRef") + .HasColumnType("text"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("IsSystem") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("Meta") + .HasColumnType("jsonb"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameI18n") + .HasColumnType("jsonb"); + + b.Property("OverridesGlobalId") + .HasColumnType("uuid"); + + b.Property("Scope") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue("global"); + + 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.HasAlternateKey("TenantId", "Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("Scope", "TenantId", "Code") + .IsUnique(); + + b.ToTable("brands", "master", t => + { + t.HasCheckConstraint("ck_brands_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_brands_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.BrandBlock", 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("GlobalId") + .HasColumnType("uuid"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + 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("GlobalId"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "GlobalId") + .IsUnique(); + + b.ToTable("brand_blocks", "master", t => + { + t.HasCheckConstraint("ck_brand_blocks_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_brand_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.Category", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .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("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("IsSystem") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("Meta") + .HasColumnType("jsonb"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameI18n") + .HasColumnType("jsonb"); + + b.Property("OverridesGlobalId") + .HasColumnType("uuid"); + + b.Property("ParentId") + .HasColumnType("uuid"); + + b.Property("Path") + .HasColumnType("text"); + + b.Property("Scope") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue("global"); + + b.Property("SortOrder") + .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("ParentId"); + + b.HasIndex("Path"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "ParentId"); + + b.HasIndex("Scope", "TenantId", "Code") + .IsUnique(); + + b.HasIndex("Scope", "TenantId", "SortOrder"); + + b.ToTable("categories", "master", t => + { + t.HasCheckConstraint("ck_categories_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_categories_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.CategoryBlock", 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("GlobalId") + .HasColumnType("uuid"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + 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("GlobalId"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "GlobalId") + .IsUnique(); + + b.ToTable("category_blocks", "master", t => + { + t.HasCheckConstraint("ck_category_blocks_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_category_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.CategoryExt", b => + { + b.Property("CategoryId") + .HasColumnType("uuid"); + + b.Property("ChannelVisibility") + .HasColumnType("jsonb"); + + b.Property("FacetSchema") + .HasColumnType("jsonb"); + + b.Property("ImageUrl") + .HasColumnType("text"); + + b.Property("SeoDescription") + .HasColumnType("text"); + + b.Property("SeoTitle") + .HasColumnType("text"); + + b.Property("Slug") + .HasColumnType("text"); + + b.HasKey("CategoryId"); + + b.ToTable("category_exts", "master"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.ComplianceStatus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .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("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("IsSystem") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("Meta") + .HasColumnType("jsonb"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameI18n") + .HasColumnType("jsonb"); + + b.Property("OverridesGlobalId") + .HasColumnType("uuid"); + + b.Property("Scope") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue("global"); + + 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.HasAlternateKey("TenantId", "Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("Scope", "TenantId", "Code") + .IsUnique(); + + b.ToTable("compliance_statuses", "master", t => + { + t.HasCheckConstraint("ck_compliance_statuses_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_compliance_statuses_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.ComplianceStatusBlock", 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("GlobalId") + .HasColumnType("uuid"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + 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("GlobalId"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "GlobalId") + .IsUnique(); + + b.ToTable("compliance_status_blocks", "master", t => + { + t.HasCheckConstraint("ck_compliance_status_blocks_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_compliance_status_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.Country", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .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("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("IsSystem") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("Meta") + .HasColumnType("jsonb"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameI18n") + .HasColumnType("jsonb"); + + b.Property("OverridesGlobalId") + .HasColumnType("uuid"); + + b.Property("Scope") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue("global"); + + 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.HasAlternateKey("TenantId", "Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("Scope", "TenantId", "Code") + .IsUnique(); + + b.ToTable("countries", "master", t => + { + t.HasCheckConstraint("ck_countries_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_countries_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.CountryBlock", 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("GlobalId") + .HasColumnType("uuid"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + 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("GlobalId"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "GlobalId") + .IsUnique(); + + b.ToTable("country_blocks", "master", t => + { + t.HasCheckConstraint("ck_country_blocks_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_country_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.Currency", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .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("Exponent") + .HasColumnType("smallint"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("IsSystem") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("Meta") + .HasColumnType("jsonb"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameI18n") + .HasColumnType("jsonb"); + + b.Property("OverridesGlobalId") + .HasColumnType("uuid"); + + b.Property("Scope") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue("global"); + + 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.HasAlternateKey("TenantId", "Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("Scope", "TenantId", "Code") + .IsUnique(); + + b.ToTable("currencies", "master", t => + { + t.HasCheckConstraint("ck_currencies_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_currencies_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.CurrencyBlock", 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("GlobalId") + .HasColumnType("uuid"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + 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("GlobalId"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "GlobalId") + .IsUnique(); + + b.ToTable("currency_blocks", "master", t => + { + t.HasCheckConstraint("ck_currency_blocks_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_currency_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.DocControlStatus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .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("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("IsSystem") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("Meta") + .HasColumnType("jsonb"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameI18n") + .HasColumnType("jsonb"); + + b.Property("OverridesGlobalId") + .HasColumnType("uuid"); + + b.Property("Scope") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue("global"); + + 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.HasAlternateKey("TenantId", "Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("Scope", "TenantId", "Code") + .IsUnique(); + + b.ToTable("doc_control_statuses", "master", t => + { + t.HasCheckConstraint("ck_doc_control_statuses_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_doc_control_statuses_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.DocControlStatusBlock", 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("GlobalId") + .HasColumnType("uuid"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + 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("GlobalId"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "GlobalId") + .IsUnique(); + + b.ToTable("doc_control_status_blocks", "master", t => + { + t.HasCheckConstraint("ck_doc_control_status_blocks_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_doc_control_status_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.FuncTest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .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("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("IsSystem") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("Meta") + .HasColumnType("jsonb"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameI18n") + .HasColumnType("jsonb"); + + b.Property("OverridesGlobalId") + .HasColumnType("uuid"); + + b.Property("Scope") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue("global"); + + 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.HasAlternateKey("TenantId", "Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("Scope", "TenantId", "Code") + .IsUnique(); + + b.ToTable("func_tests", "master", t => + { + t.HasCheckConstraint("ck_func_tests_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_func_tests_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.FuncTestBlock", 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("GlobalId") + .HasColumnType("uuid"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + 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("GlobalId"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "GlobalId") + .IsUnique(); + + b.ToTable("func_test_blocks", "master", t => + { + t.HasCheckConstraint("ck_func_test_blocks_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_func_test_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.HazardClass", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .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("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("IsSystem") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("Meta") + .HasColumnType("jsonb"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameI18n") + .HasColumnType("jsonb"); + + b.Property("OverridesGlobalId") + .HasColumnType("uuid"); + + b.Property("Scope") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue("global"); + + 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.HasAlternateKey("TenantId", "Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("Scope", "TenantId", "Code") + .IsUnique(); + + b.ToTable("hazard_classes", "master", t => + { + t.HasCheckConstraint("ck_hazard_classes_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_hazard_classes_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.HazardClassBlock", 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("GlobalId") + .HasColumnType("uuid"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + 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("GlobalId"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "GlobalId") + .IsUnique(); + + b.ToTable("hazard_class_blocks", "master", t => + { + t.HasCheckConstraint("ck_hazard_class_blocks_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_hazard_class_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.Language", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .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("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("IsSystem") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("Meta") + .HasColumnType("jsonb"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameI18n") + .HasColumnType("jsonb"); + + b.Property("OverridesGlobalId") + .HasColumnType("uuid"); + + b.Property("Scope") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue("global"); + + 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.HasAlternateKey("TenantId", "Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("Scope", "TenantId", "Code") + .IsUnique(); + + b.ToTable("languages", "master", t => + { + t.HasCheckConstraint("ck_languages_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_languages_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.LanguageBlock", 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("GlobalId") + .HasColumnType("uuid"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + 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("GlobalId"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "GlobalId") + .IsUnique(); + + b.ToTable("language_blocks", "master", t => + { + t.HasCheckConstraint("ck_language_blocks_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_language_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.Manufacturer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .HasColumnType("text"); + + b.Property("CountryCode") + .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("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("IsSystem") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("Meta") + .HasColumnType("jsonb"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameI18n") + .HasColumnType("jsonb"); + + b.Property("OverridesGlobalId") + .HasColumnType("uuid"); + + b.Property("Scope") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue("global"); + + 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.HasAlternateKey("TenantId", "Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("Scope", "TenantId", "Code") + .IsUnique(); + + b.ToTable("manufacturers", "master", t => + { + t.HasCheckConstraint("ck_manufacturers_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_manufacturers_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.ManufacturerBlock", 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("GlobalId") + .HasColumnType("uuid"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + 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("GlobalId"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "GlobalId") + .IsUnique(); + + b.ToTable("manufacturer_blocks", "master", t => + { + t.HasCheckConstraint("ck_manufacturer_blocks_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_manufacturer_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.Market", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .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("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("IsSystem") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("Meta") + .HasColumnType("jsonb"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameI18n") + .HasColumnType("jsonb"); + + b.Property("OverridesGlobalId") + .HasColumnType("uuid"); + + b.Property("Scope") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue("global"); + + 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.HasAlternateKey("TenantId", "Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("Scope", "TenantId", "Code") + .IsUnique(); + + b.ToTable("markets", "master", t => + { + t.HasCheckConstraint("ck_markets_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_markets_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.MarketBlock", 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("GlobalId") + .HasColumnType("uuid"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + 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("GlobalId"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "GlobalId") + .IsUnique(); + + b.ToTable("market_blocks", "master", t => + { + t.HasCheckConstraint("ck_market_blocks_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_market_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.PackingGroup", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .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("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("IsSystem") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("Meta") + .HasColumnType("jsonb"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameI18n") + .HasColumnType("jsonb"); + + b.Property("OverridesGlobalId") + .HasColumnType("uuid"); + + b.Property("Scope") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue("global"); + + 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.HasAlternateKey("TenantId", "Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("Scope", "TenantId", "Code") + .IsUnique(); + + b.ToTable("packing_groups", "master", t => + { + t.HasCheckConstraint("ck_packing_groups_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_packing_groups_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.PackingGroupBlock", 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("GlobalId") + .HasColumnType("uuid"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + 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("GlobalId"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "GlobalId") + .IsUnique(); + + b.ToTable("packing_group_blocks", "master", t => + { + t.HasCheckConstraint("ck_packing_group_blocks_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_packing_group_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.QaStage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .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("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("IsSystem") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("Meta") + .HasColumnType("jsonb"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameI18n") + .HasColumnType("jsonb"); + + b.Property("OverridesGlobalId") + .HasColumnType("uuid"); + + b.Property("Scope") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue("global"); + + 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.HasAlternateKey("TenantId", "Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("Scope", "TenantId", "Code") + .IsUnique(); + + b.ToTable("qa_stages", "master", t => + { + t.HasCheckConstraint("ck_qa_stages_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_qa_stages_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.QaStageBlock", 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("GlobalId") + .HasColumnType("uuid"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + 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("GlobalId"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "GlobalId") + .IsUnique(); + + b.ToTable("qa_stage_blocks", "master", t => + { + t.HasCheckConstraint("ck_qa_stage_blocks_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_qa_stage_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.QcStatus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .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("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("IsSystem") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("Meta") + .HasColumnType("jsonb"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameI18n") + .HasColumnType("jsonb"); + + b.Property("OverridesGlobalId") + .HasColumnType("uuid"); + + b.Property("Scope") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue("global"); + + 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.HasAlternateKey("TenantId", "Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("Scope", "TenantId", "Code") + .IsUnique(); + + b.ToTable("qc_statuses", "master", t => + { + t.HasCheckConstraint("ck_qc_statuses_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_qc_statuses_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.QcStatusBlock", 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("GlobalId") + .HasColumnType("uuid"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + 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("GlobalId"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "GlobalId") + .IsUnique(); + + b.ToTable("qc_status_blocks", "master", t => + { + t.HasCheckConstraint("ck_qc_status_blocks_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_qc_status_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.RecallClass", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .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("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("IsSystem") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("Meta") + .HasColumnType("jsonb"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameI18n") + .HasColumnType("jsonb"); + + b.Property("OverridesGlobalId") + .HasColumnType("uuid"); + + b.Property("Scope") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue("global"); + + 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.HasAlternateKey("TenantId", "Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("Scope", "TenantId", "Code") + .IsUnique(); + + b.ToTable("recall_classes", "master", t => + { + t.HasCheckConstraint("ck_recall_classes_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_recall_classes_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.RecallClassBlock", 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("GlobalId") + .HasColumnType("uuid"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + 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("GlobalId"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "GlobalId") + .IsUnique(); + + b.ToTable("recall_class_blocks", "master", t => + { + t.HasCheckConstraint("ck_recall_class_blocks_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_recall_class_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.RiskClass", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .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("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("IsSystem") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("Meta") + .HasColumnType("jsonb"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameI18n") + .HasColumnType("jsonb"); + + b.Property("OverridesGlobalId") + .HasColumnType("uuid"); + + b.Property("Scope") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue("global"); + + 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.HasAlternateKey("TenantId", "Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("Scope", "TenantId", "Code") + .IsUnique(); + + b.ToTable("risk_classes", "master", t => + { + t.HasCheckConstraint("ck_risk_classes_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_risk_classes_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.RiskClassBlock", 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("GlobalId") + .HasColumnType("uuid"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + 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("GlobalId"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "GlobalId") + .IsUnique(); + + b.ToTable("risk_class_blocks", "master", t => + { + t.HasCheckConstraint("ck_risk_class_blocks_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_risk_class_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.Route", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .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("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("IsSystem") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("Meta") + .HasColumnType("jsonb"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameI18n") + .HasColumnType("jsonb"); + + b.Property("OverridesGlobalId") + .HasColumnType("uuid"); + + b.Property("Scope") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue("global"); + + 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.HasAlternateKey("TenantId", "Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("Scope", "TenantId", "Code") + .IsUnique(); + + b.ToTable("routes", "master", t => + { + t.HasCheckConstraint("ck_routes_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_routes_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.RouteBlock", 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("GlobalId") + .HasColumnType("uuid"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + 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("GlobalId"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "GlobalId") + .IsUnique(); + + b.ToTable("route_blocks", "master", t => + { + t.HasCheckConstraint("ck_route_blocks_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_route_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.RxSchedule", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .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("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("IsSystem") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("Meta") + .HasColumnType("jsonb"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameI18n") + .HasColumnType("jsonb"); + + b.Property("OverridesGlobalId") + .HasColumnType("uuid"); + + b.Property("Scope") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue("global"); + + 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.HasAlternateKey("TenantId", "Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("Scope", "TenantId", "Code") + .IsUnique(); + + b.ToTable("rx_schedules", "master", t => + { + t.HasCheckConstraint("ck_rx_schedules_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_rx_schedules_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.RxScheduleBlock", 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("GlobalId") + .HasColumnType("uuid"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + 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("GlobalId"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "GlobalId") + .IsUnique(); + + b.ToTable("rx_schedule_blocks", "master", t => + { + t.HasCheckConstraint("ck_rx_schedule_blocks_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_rx_schedule_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.Species", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .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("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("IsSystem") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("Meta") + .HasColumnType("jsonb"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameI18n") + .HasColumnType("jsonb"); + + b.Property("OverridesGlobalId") + .HasColumnType("uuid"); + + b.Property("Scope") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue("global"); + + 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.HasAlternateKey("TenantId", "Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("Scope", "TenantId", "Code") + .IsUnique(); + + b.ToTable("species", "master", t => + { + t.HasCheckConstraint("ck_species_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_species_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.SpeciesBlock", 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("GlobalId") + .HasColumnType("uuid"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + 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("GlobalId"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "GlobalId") + .IsUnique(); + + b.ToTable("species_blocks", "master", t => + { + t.HasCheckConstraint("ck_species_blocks_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_species_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.StabilityStatus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .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("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("IsSystem") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("Meta") + .HasColumnType("jsonb"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameI18n") + .HasColumnType("jsonb"); + + b.Property("OverridesGlobalId") + .HasColumnType("uuid"); + + b.Property("Scope") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue("global"); + + 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.HasAlternateKey("TenantId", "Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("Scope", "TenantId", "Code") + .IsUnique(); + + b.ToTable("stability_statuses", "master", t => + { + t.HasCheckConstraint("ck_stability_statuses_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_stability_statuses_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.StabilityStatusBlock", 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("GlobalId") + .HasColumnType("uuid"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + 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("GlobalId"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "GlobalId") + .IsUnique(); + + b.ToTable("stability_status_blocks", "master", t => + { + t.HasCheckConstraint("ck_stability_status_blocks_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_stability_status_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.SterilizationMethod", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .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("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("IsSystem") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("Meta") + .HasColumnType("jsonb"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameI18n") + .HasColumnType("jsonb"); + + b.Property("OverridesGlobalId") + .HasColumnType("uuid"); + + b.Property("Scope") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue("global"); + + 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.HasAlternateKey("TenantId", "Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("Scope", "TenantId", "Code") + .IsUnique(); + + b.ToTable("sterilization_methods", "master", t => + { + t.HasCheckConstraint("ck_sterilization_methods_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_sterilization_methods_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.SterilizationMethodBlock", 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("GlobalId") + .HasColumnType("uuid"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + 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("GlobalId"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "GlobalId") + .IsUnique(); + + b.ToTable("sterilization_method_blocks", "master", t => + { + t.HasCheckConstraint("ck_sterilization_method_blocks_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_sterilization_method_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.Uom", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("BaseCode") + .HasColumnType("text"); + + b.Property("Code") + .IsRequired() + .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("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("IsSystem") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("Meta") + .HasColumnType("jsonb"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameI18n") + .HasColumnType("jsonb"); + + b.Property("OverridesGlobalId") + .HasColumnType("uuid"); + + b.Property("Scope") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue("global"); + + b.Property("SiFactor") + .HasColumnType("numeric"); + + 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.HasAlternateKey("TenantId", "Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("Scope", "TenantId", "Code") + .IsUnique(); + + b.ToTable("uoms", "master", t => + { + t.HasCheckConstraint("ck_uoms_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_uoms_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.UomBlock", 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("GlobalId") + .HasColumnType("uuid"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + 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("GlobalId"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "GlobalId") + .IsUnique(); + + b.ToTable("uom_blocks", "master", t => + { + t.HasCheckConstraint("ck_uom_blocks_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_uom_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.Vvm", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .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("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(true); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + b.Property("IsSystem") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false); + + b.Property("Meta") + .HasColumnType("jsonb"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NameI18n") + .HasColumnType("jsonb"); + + b.Property("OverridesGlobalId") + .HasColumnType("uuid"); + + b.Property("Scope") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("text") + .HasDefaultValue("global"); + + 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.HasAlternateKey("TenantId", "Id"); + + b.HasIndex("TenantId"); + + b.HasIndex("Scope", "TenantId", "Code") + .IsUnique(); + + b.ToTable("vvms", "master", t => + { + t.HasCheckConstraint("ck_vvms_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_vvms_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.VvmBlock", 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("GlobalId") + .HasColumnType("uuid"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("boolean") + .HasDefaultValue(false) + .HasColumnName("is_deleted"); + + 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("GlobalId"); + + b.HasIndex("TenantId"); + + b.HasIndex("TenantId", "GlobalId") + .IsUnique(); + + b.ToTable("vvm_blocks", "master", t => + { + t.HasCheckConstraint("ck_vvm_blocks_tenant_not_null", "tenant_id is not null"); + + t.HasCheckConstraint("ck_vvm_blocks_tenant_not_zero", "tenant_id <> '00000000-0000-0000-0000-000000000000'"); + }); + }); + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Tenancy.TenantConfig", b => { b.Property("TenantKey") @@ -1409,6 +5298,75 @@ namespace AMREZ.EOP.Infrastructures.Migrations b.Navigation("User"); }); + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Customers.CustomerAddress", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.Customers.Address", "Address") + .WithMany("CustomerLinks") + .HasForeignKey("TenantId", "AddressId") + .HasPrincipalKey("TenantId", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AMREZ.EOP.Domain.Entities.Customers.CustomerProfile", "Customer") + .WithMany("Addresses") + .HasForeignKey("TenantId", "CustomerProfileId") + .HasPrincipalKey("TenantId", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Address"); + + b.Navigation("Customer"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Customers.CustomerContact", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.Customers.CustomerProfile", "Customer") + .WithMany("Contacts") + .HasForeignKey("TenantId", "CustomerProfileId") + .HasPrincipalKey("TenantId", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Customer"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Customers.CustomerTag", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.Customers.CustomerProfile", "Customer") + .WithMany("Tags") + .HasForeignKey("TenantId", "CustomerProfileId") + .HasPrincipalKey("TenantId", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Customer"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Customers.OrganizationProfile", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.Customers.CustomerProfile", "Customer") + .WithOne("Organization") + .HasForeignKey("AMREZ.EOP.Domain.Entities.Customers.OrganizationProfile", "TenantId", "CustomerProfileId") + .HasPrincipalKey("AMREZ.EOP.Domain.Entities.Customers.CustomerProfile", "TenantId", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Customer"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Customers.PersonProfile", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.Customers.CustomerProfile", "Customer") + .WithOne("Person") + .HasForeignKey("AMREZ.EOP.Domain.Entities.Customers.PersonProfile", "TenantId", "CustomerProfileId") + .HasPrincipalKey("AMREZ.EOP.Domain.Entities.Customers.CustomerProfile", "TenantId", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Customer"); + }); + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.HumanResources.Department", b => { b.HasOne("AMREZ.EOP.Domain.Entities.HumanResources.Department", "Parent") @@ -1504,6 +5462,244 @@ namespace AMREZ.EOP.Infrastructures.Migrations b.Navigation("User"); }); + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.AllergenBlock", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.Allergen", null) + .WithMany() + .HasForeignKey("GlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.BrandBlock", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.Brand", null) + .WithMany() + .HasForeignKey("GlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.Category", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.Category", "Parent") + .WithMany("Children") + .HasForeignKey("TenantId", "ParentId") + .HasPrincipalKey("TenantId", "Id") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Parent"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.CategoryBlock", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.Category", null) + .WithMany() + .HasForeignKey("GlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.CategoryExt", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.Category", "Category") + .WithOne() + .HasForeignKey("AMREZ.EOP.Domain.Entities.MasterData.CategoryExt", "CategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.ComplianceStatusBlock", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.ComplianceStatus", null) + .WithMany() + .HasForeignKey("GlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.CountryBlock", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.Country", null) + .WithMany() + .HasForeignKey("GlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.CurrencyBlock", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.Currency", null) + .WithMany() + .HasForeignKey("GlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.DocControlStatusBlock", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.DocControlStatus", null) + .WithMany() + .HasForeignKey("GlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.FuncTestBlock", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.FuncTest", null) + .WithMany() + .HasForeignKey("GlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.HazardClassBlock", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.HazardClass", null) + .WithMany() + .HasForeignKey("GlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.LanguageBlock", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.Language", null) + .WithMany() + .HasForeignKey("GlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.ManufacturerBlock", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.Manufacturer", null) + .WithMany() + .HasForeignKey("GlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.MarketBlock", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.Market", null) + .WithMany() + .HasForeignKey("GlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.PackingGroupBlock", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.PackingGroup", null) + .WithMany() + .HasForeignKey("GlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.QaStageBlock", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.QaStage", null) + .WithMany() + .HasForeignKey("GlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.QcStatusBlock", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.QcStatus", null) + .WithMany() + .HasForeignKey("GlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.RecallClassBlock", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.RecallClass", null) + .WithMany() + .HasForeignKey("GlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.RiskClassBlock", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.RiskClass", null) + .WithMany() + .HasForeignKey("GlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.RouteBlock", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.Route", null) + .WithMany() + .HasForeignKey("GlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.RxScheduleBlock", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.RxSchedule", null) + .WithMany() + .HasForeignKey("GlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.SpeciesBlock", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.Species", null) + .WithMany() + .HasForeignKey("GlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.StabilityStatusBlock", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.StabilityStatus", null) + .WithMany() + .HasForeignKey("GlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.SterilizationMethodBlock", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.SterilizationMethod", null) + .WithMany() + .HasForeignKey("GlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.UomBlock", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.Uom", null) + .WithMany() + .HasForeignKey("GlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.VvmBlock", b => + { + b.HasOne("AMREZ.EOP.Domain.Entities.MasterData.Vvm", null) + .WithMany() + .HasForeignKey("GlobalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Tenancy.TenantDomain", b => { b.HasOne("AMREZ.EOP.Domain.Entities.Tenancy.TenantConfig", null) @@ -1539,6 +5735,24 @@ namespace AMREZ.EOP.Infrastructures.Migrations b.Navigation("UserRoles"); }); + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Customers.Address", b => + { + b.Navigation("CustomerLinks"); + }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.Customers.CustomerProfile", b => + { + b.Navigation("Addresses"); + + b.Navigation("Contacts"); + + b.Navigation("Organization"); + + b.Navigation("Person"); + + b.Navigation("Tags"); + }); + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.HumanResources.Department", b => { b.Navigation("Children"); @@ -1561,6 +5775,11 @@ namespace AMREZ.EOP.Infrastructures.Migrations b.Navigation("Employments"); }); + + modelBuilder.Entity("AMREZ.EOP.Domain.Entities.MasterData.Category", b => + { + b.Navigation("Children"); + }); #pragma warning restore 612, 618 } } diff --git a/AMREZ.EOP.Infrastructures/Repositories/UserRepository.cs b/AMREZ.EOP.Infrastructures/Repositories/UserRepository.cs index deed518..508541e 100644 --- a/AMREZ.EOP.Infrastructures/Repositories/UserRepository.cs +++ b/AMREZ.EOP.Infrastructures/Repositories/UserRepository.cs @@ -65,47 +65,16 @@ public class UserRepository : IUserRepository public async Task FindActiveByEmailAsync(string email, CancellationToken ct = default) { - var r = _redis?.GetDatabase(); var norm = email.Trim().ToLowerInvariant(); - - if (r is not null) - { - try - { - var cached = await r.StringGetAsync($"uidx:{norm}"); - if (cached.HasValue) - { - var hit = JsonSerializer.Deserialize(cached!); - if (hit?.IsActive == true) return hit; - } - } - catch { /* ignore cache errors */ } - } - var db = _scope.Get(); - var user = await ( - from u in db.Users.AsNoTracking() - join i in db.UserIdentities.AsNoTracking() on u.Id equals i.UserId - where u.IsActive - && i.Type == IdentityType.Email - && i.Identifier == norm - select u - ).FirstOrDefaultAsync(ct); - - if (user is not null && r is not null) - { - try - { - var payload = JsonSerializer.Serialize(user); - var ttl = TimeSpan.FromMinutes(5); - await r.StringSetAsync($"uidx:{norm}", payload, ttl); - await r.StringSetAsync($"user:{user.Id:N}", payload, ttl); - } - catch { /* ignore cache errors */ } - } - - return user; + return await db.Users + .AsNoTracking() + .Include(u => u.UserRoles) + .ThenInclude(ur => ur.Role) + .Where(u => u.IsActive && + u.Identities.Any(i => i.Type == IdentityType.Email && i.Identifier == norm)) + .FirstOrDefaultAsync(ct); } public async Task EmailExistsAsync(string email, CancellationToken ct = default) @@ -142,11 +111,61 @@ public class UserRepository : IUserRepository if (!string.IsNullOrWhiteSpace(email)) await r.StringSetAsync(IdentityEmailKey(tid.ToString(), email!), payload, ttl); } - catch { } + catch + { + } } } - public async Task AddIdentityAsync(Guid userId, IdentityType type, string identifier, bool isPrimary, CancellationToken ct = default) + public async Task GetRoleCodesByUserIdAsync(Guid userId, Guid tenantId, CancellationToken ct = default) + { + var r = _redis?.GetDatabase(); + var cacheKey = $"urole:{tenantId:N}:{userId:N}"; + + // ---- cache hit ---- + if (r is not null) + { + try + { + var cached = await r.StringGetAsync(cacheKey); + if (cached.HasValue) + { + var arr = JsonSerializer.Deserialize(cached!) ?? Array.Empty(); + if (arr.Length > 0) return arr; + } + } + catch { /* ignore cache errors */ } + } + + var db = _scope.Get(); + + // NOTE: + // - ไม่อ้างอิง r.TenantId เพื่อให้คอมไพล์ได้แม้ Role ยังไม่มีฟิลด์ TenantId + // - ถ้าคุณเพิ่ม Role.TenantId แล้ว และต้องการกรองตาม tenant ให้เติม .Where(role => role.TenantId == tenantId) + var roles = await db.UserRoles + .AsNoTracking() + .Where(ur => ur.UserId == userId) + .Select(ur => ur.Role) + .Where(role => role != null) + .Select(role => role!.Code) // ใช้ Code เป็นค่าของ claim "role" + .Distinct() + .ToArrayAsync(ct); + + // ---- cache miss → set ---- + if (r is not null) + { + try + { + await r.StringSetAsync(cacheKey, JsonSerializer.Serialize(roles), TimeSpan.FromMinutes(5)); + } + catch { /* ignore cache errors */ } + } + + return roles; + } + + public async Task AddIdentityAsync(Guid userId, IdentityType type, string identifier, bool isPrimary, + CancellationToken ct = default) { var tid = TenantId(); var db = _scope.Get(); @@ -162,18 +181,19 @@ public class UserRepository : IUserRepository var entity = new UserIdentity { - TenantId = tid, - UserId = userId, - Type = type, + TenantId = tid, + UserId = userId, + Type = type, Identifier = norm, - IsPrimary = isPrimary + IsPrimary = isPrimary }; await db.UserIdentities.AddAsync(entity, ct); await db.SaveChangesAsync(ct); } - public async Task VerifyIdentityAsync(Guid userId, IdentityType type, string identifier, DateTimeOffset verifiedAt, CancellationToken ct = default) + public async Task VerifyIdentityAsync(Guid userId, IdentityType type, string identifier, DateTimeOffset verifiedAt, + CancellationToken ct = default) { var tid = TenantId(); var db = _scope.Get(); @@ -191,7 +211,8 @@ public class UserRepository : IUserRepository await db.SaveChangesAsync(ct); } - public async Task GetPrimaryIdentityAsync(Guid userId, IdentityType type, CancellationToken ct = default) + public async Task GetPrimaryIdentityAsync(Guid userId, IdentityType type, + CancellationToken ct = default) { var tid = TenantId(); var db = _scope.Get(); @@ -234,7 +255,8 @@ public class UserRepository : IUserRepository await db.SaveChangesAsync(ct); } - public async Task AddTotpFactorAsync(Guid userId, string label, string secret, CancellationToken ct = default) + public async Task AddTotpFactorAsync(Guid userId, string label, string secret, + CancellationToken ct = default) { var tid = TenantId(); var db = _scope.Get(); @@ -294,7 +316,8 @@ public class UserRepository : IUserRepository return session; } - public async Task FindSessionByRefreshHashAsync(Guid tenantId, string refreshTokenHash, CancellationToken ct = default) + public async Task FindSessionByRefreshHashAsync(Guid tenantId, string refreshTokenHash, + CancellationToken ct = default) { var db = _scope.Get(); return await db.UserSessions @@ -302,7 +325,8 @@ public class UserRepository : IUserRepository .FirstOrDefaultAsync(x => x.TenantId == tenantId && x.RefreshTokenHash == refreshTokenHash, ct); } - public async Task RotateSessionRefreshAsync(Guid tenantId, Guid sessionId, string newRefreshTokenHash, DateTimeOffset newIssuedAt, DateTimeOffset? newExpiresAt, CancellationToken ct = default) + public async Task RotateSessionRefreshAsync(Guid tenantId, Guid sessionId, string newRefreshTokenHash, + DateTimeOffset newIssuedAt, DateTimeOffset? newExpiresAt, CancellationToken ct = default) { var db = _scope.Get(); var s = await db.UserSessions.FirstOrDefaultAsync(x => x.TenantId == tenantId && x.Id == sessionId, ct); @@ -319,7 +343,8 @@ public class UserRepository : IUserRepository var tid = TenantId(); var db = _scope.Get(); - var s = await db.UserSessions.FirstOrDefaultAsync(x => x.TenantId == tid && x.Id == sessionId && x.UserId == userId, ct); + var s = await db.UserSessions.FirstOrDefaultAsync( + x => x.TenantId == tid && x.Id == sessionId && x.UserId == userId, ct); if (s is null) return 0; s.RevokedAt = DateTimeOffset.UtcNow;