From 015ab2d3fb82da0867b76d5de3c1ce9c96f3223d Mon Sep 17 00:00:00 2001 From: vanilia Date: Wed, 19 Nov 2025 13:59:19 +0700 Subject: [PATCH] update person entity --- cmd/main-migration/migrations/20251119065730.sql | 6 ++++++ cmd/main-migration/migrations/atlas.sum | 5 +++-- internal/domain/main-entities/person/entity.go | 8 ++++---- internal/domain/simgos-entities/patient/entity.go | 2 +- 4 files changed, 14 insertions(+), 7 deletions(-) create mode 100644 cmd/main-migration/migrations/20251119065730.sql diff --git a/cmd/main-migration/migrations/20251119065730.sql b/cmd/main-migration/migrations/20251119065730.sql new file mode 100644 index 00000000..23015cdb --- /dev/null +++ b/cmd/main-migration/migrations/20251119065730.sql @@ -0,0 +1,6 @@ +-- Modify "Person" table +ALTER TABLE "public"."Person" DROP CONSTRAINT "uni_Person_DrivingLicenseNumber", DROP CONSTRAINT "uni_Person_PassportNumber", ALTER COLUMN "ResidentIdentityNumber" TYPE character varying(16), ALTER COLUMN "Nationality" TYPE character varying(50); +-- Create index "idx_driver_license" to table: "Person" +CREATE UNIQUE INDEX "idx_driver_license" ON "public"."Person" ("DrivingLicenseNumber") WHERE ("DeletedAt" IS NULL); +-- Create index "idx_passport" to table: "Person" +CREATE UNIQUE INDEX "idx_passport" ON "public"."Person" ("PassportNumber") WHERE ("DeletedAt" IS NULL); diff --git a/cmd/main-migration/migrations/atlas.sum b/cmd/main-migration/migrations/atlas.sum index 7d7f66ee..6ebacb54 100644 --- a/cmd/main-migration/migrations/atlas.sum +++ b/cmd/main-migration/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:UhULOHIbuhMYkKVWh97sQJdSpsgfHegvn8gwivFk6YQ= +h1:f+74L4+GTfxWUjGdRBK4+cl+dMKS9xAWE2a+KlI27MY= 20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k= 20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0= 20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI= @@ -120,4 +120,5 @@ h1:UhULOHIbuhMYkKVWh97sQJdSpsgfHegvn8gwivFk6YQ= 20251114062746.sql h1:FInLaEFQByESEwFJKuKnuUSTKmcDpi3ZXaxkKwz2+D8= 20251117005942.sql h1:wD3BWrUSmo1HlW16V3lkaBkJvbAZ0fNk77te7J9NhOc= 20251117075427.sql h1:TqU9VKZa3I8YNXUGQWY3WVBYN+1FvyyaKy0hB1jgAho= -20251119063438.sql h1:7BCr8Pr2doQT2BmsKYpyGa7gap4pWH711vClDw/VQ6s= +20251119063438.sql h1:esk+Su7PqfQmRmRv7aDlGvzollkNAA3UK27W430xFHI= +20251119065730.sql h1:pYEs4zblH2NuhGSsM+9iPKCkAV7w81KQWdnUIifD1rk= diff --git a/internal/domain/main-entities/person/entity.go b/internal/domain/main-entities/person/entity.go index aa00e6f9..8d7f79a8 100644 --- a/internal/domain/main-entities/person/entity.go +++ b/internal/domain/main-entities/person/entity.go @@ -25,16 +25,16 @@ 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:"uniqueIndex:idx_resident_identity,where:\"DeletedAt\" IS NULL"` - PassportNumber *string `json:"passportNumber" gorm:"unique;size:20"` - DrivingLicenseNumber *string `json:"drivingLicenseNumber" gorm:"unique;size:20"` + ResidentIdentityNumber *string `json:"residentIdentityNumber" gorm:"uniqueIndex:idx_resident_identity,where:\"DeletedAt\" IS NULL;size:16"` + PassportNumber *string `json:"passportNumber" gorm:"uniqueIndex:idx_passport,where:\"DeletedAt\" IS NULL;size:20"` + DrivingLicenseNumber *string `json:"drivingLicenseNumber" gorm:"uniqueIndex:idx_driver_license,where:\"DeletedAt\" IS NULL;size:20"` Religion_Code *erp.ReligionCode `json:"religion_code" gorm:"size:10"` Confidence *string `json:"confidence" gorm:"size:512"` Education_Code *erp.EducationCode `json:"education_code" gorm:"size:10"` Ocupation_Code *erp.OcupationCode `json:"occupation_code" gorm:"size:15"` Ocupation_Name *string `json:"occupation_name" gorm:"size:50"` MaritalStatus_Code *erp.MaritalStatusCode `json:"maritalStatus_code" gorm:"size:10"` - Nationality *string `json:"nationality": gorm:"size:50"` + Nationality *string `json:"nationality" gorm:"size:50"` Ethnic_Code *string `json:"ethnic_code" gorm:"size:20"` Ethnic *ee.Ethnic `json:"ethnic,omitempty" gorm:"foreignKey:Ethnic_Code;references:Code"` Language_Code *string `json:"language_code" gorm:"size:10"` diff --git a/internal/domain/simgos-entities/patient/entity.go b/internal/domain/simgos-entities/patient/entity.go index 3013e121..605c5722 100644 --- a/internal/domain/simgos-entities/patient/entity.go +++ b/internal/domain/simgos-entities/patient/entity.go @@ -41,7 +41,7 @@ type MPasien struct { Sim *string `json:"sim" gorm:"column:sim"` Paspor *string `json:"paspor" gorm:"column:paspor"` Disabilitas *string `json:"disabilitas" gorm:"column:disabilitas"` - Bahasa string `json:"bahasa" json:"bahasa"` + Bahasa string `json:"bahasa" gorm:"column:bahasa"` HambatanKomunikasi string `json:"hambatan_komunikasi" gorm:"column:hambatan_komunikasi"` Kebangsaan string `json:"kebangsaan" gorm:"column:kebangsaan"` Notelprumah1 string `json:"notelprumah1" gorm:"column:notelprumah1"`