diff --git a/cmd/main-migration/migrations/20251119063438.sql b/cmd/main-migration/migrations/20251119063438.sql new file mode 100644 index 00000000..1d67246e --- /dev/null +++ b/cmd/main-migration/migrations/20251119063438.sql @@ -0,0 +1,4 @@ +-- Modify "Person" table +ALTER TABLE "public"."Person" DROP CONSTRAINT "uni_Person_ResidentIdentityNumber", ALTER COLUMN "ResidentIdentityNumber" TYPE text; +-- Create index "idx_resident_identity" to table: "Person" +CREATE UNIQUE INDEX "idx_resident_identity" ON "public"."Person" ("ResidentIdentityNumber") WHERE ("DeletedAt" IS NULL); diff --git a/cmd/main-migration/migrations/atlas.sum b/cmd/main-migration/migrations/atlas.sum index 4898eefa..7d7f66ee 100644 --- a/cmd/main-migration/migrations/atlas.sum +++ b/cmd/main-migration/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:vOoMJhDkNM1zFHHQLD+cHi5Xz/K4Bnv0bSNVF8IjdLs= +h1:UhULOHIbuhMYkKVWh97sQJdSpsgfHegvn8gwivFk6YQ= 20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k= 20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0= 20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI= @@ -120,3 +120,4 @@ h1:vOoMJhDkNM1zFHHQLD+cHi5Xz/K4Bnv0bSNVF8IjdLs= 20251114062746.sql h1:FInLaEFQByESEwFJKuKnuUSTKmcDpi3ZXaxkKwz2+D8= 20251117005942.sql h1:wD3BWrUSmo1HlW16V3lkaBkJvbAZ0fNk77te7J9NhOc= 20251117075427.sql h1:TqU9VKZa3I8YNXUGQWY3WVBYN+1FvyyaKy0hB1jgAho= +20251119063438.sql h1:7BCr8Pr2doQT2BmsKYpyGa7gap4pWH711vClDw/VQ6s= diff --git a/internal/domain/main-entities/person/entity.go b/internal/domain/main-entities/person/entity.go index d6e6744a..aa00e6f9 100644 --- a/internal/domain/main-entities/person/entity.go +++ b/internal/domain/main-entities/person/entity.go @@ -25,7 +25,7 @@ type Person struct { BirthRegency_Code *string `json:"birthRegency_code" gorm:"size:4"` BirthRegency *er.Regency `json:"birthRegency,omitempty" gorm:"foreignKey:BirthRegency_Code;references:Code"` Gender_Code *erp.GenderCode `json:"gender_code" gorm:"size:10"` - ResidentIdentityNumber *string `json:"residentIdentityNumber" gorm:"unique;size:16"` + ResidentIdentityNumber *string `json:"residentIdentityNumber" gorm:"uniqueIndex:idx_resident_identity,where:\"DeletedAt\" IS NULL"` PassportNumber *string `json:"passportNumber" gorm:"unique;size:20"` DrivingLicenseNumber *string `json:"drivingLicenseNumber" gorm:"unique;size:20"` Religion_Code *erp.ReligionCode `json:"religion_code" gorm:"size:10"`