set Identity,Passport, DrivingLisence number as unique, add unit into nurse and set not nulll device's name

This commit is contained in:
dpurbosakti
2025-09-03 11:25:43 +07:00
parent 0fc0612a58
commit fbc10aec4b
5 changed files with 16 additions and 6 deletions
@@ -0,0 +1,6 @@
-- Modify "Device" table
ALTER TABLE "public"."Device" ALTER COLUMN "Name" SET NOT NULL;
-- Modify "Person" table
ALTER TABLE "public"."Person" ADD CONSTRAINT "uni_Person_DrivingLicenseNumber" UNIQUE ("DrivingLicenseNumber"), ADD CONSTRAINT "uni_Person_PassportNumber" UNIQUE ("PassportNumber"), ADD CONSTRAINT "uni_Person_ResidentIdentityNumber" UNIQUE ("ResidentIdentityNumber");
-- Modify "Nurse" table
ALTER TABLE "public"."Nurse" ADD COLUMN "Unit_Id" integer NULL, ADD CONSTRAINT "fk_Nurse_Unit" FOREIGN KEY ("Unit_Id") REFERENCES "public"."Unit" ("Id") ON UPDATE NO ACTION ON DELETE NO ACTION;
+3 -2
View File
@@ -1,8 +1,9 @@
h1:XRXWqXK7AhgwoDbOnYqWln74qQUn071LDRB7OmotZ5Y=
h1:/oxZnT+1LpkBjyeDak9iLLwckizN6WbyuPQlG7bmr+c=
20250829081952.sql h1:YMsYq3uPsx70EjWSGfYnVRR5GV0q1fRGIszYZAWzXNo=
20250901073356.sql h1:jjd5TLs+Pyi0u3SrOM+aNTbHxSJboXgcOz/L4bkYx+c=
20250901080035.sql h1:LWa3X0NWjalVcxNbk5HaHj1Oqu60/AQabi0jBmCeQBI=
20250901105703.sql h1:2h2B/wOFM0826sBXQutTtq24C+5duLqi4zEFOdbPsCI=
20250902052320.sql h1:+tWdeS4NorPj5WdKHMirBfP4EeS01wyyfdT03DBMmcI=
20250902063217.sql h1:wYFIrAIp1RczNvzlmu8jP8P1J7xEXqgDLKDUNBbkt84=
20250902105300.sql h1:5FRCQkxe/P97WwGJT05HsqLlOEbR9/BdWBY5wMSykYg=
20250902105300.sql h1:6N2SDYK3a6djaO6u468E/DrDR9kM+uYoJvNlTFon6bY=
20250903041718.sql h1:9s5sfoT+RBGP5NYNafcnHWNb8nLtZ9jhYbyKKPFCK8k=
@@ -10,7 +10,7 @@ import (
type Device struct {
ecore.Main // adjust this according to the needs
Code string `json:"code" gorm:"unique;size:10"`
Name string `json:"name" gorm:"size:50"`
Name string `json:"name" gorm:"not null;size:50"`
Uom_Code string `json:"uom_code" gorm:"size:10"`
Uom *eu.Uom `json:"uom,omitempty" gorm:"foreignKey:Uom_Code;references:Code"`
Infra_Id *uint16 `json:"infra_id"`
@@ -3,6 +3,7 @@ package nurse
import (
ecore "simrs-vx/internal/domain/base-entities/core"
ee "simrs-vx/internal/domain/main-entities/employee"
eu "simrs-vx/internal/domain/main-entities/unit"
)
type Nurse struct {
@@ -10,4 +11,6 @@ type Nurse struct {
Employee_Id *uint `json:"employee_id"`
Employee *ee.Employee `json:"employee,omitempty" gorm:"foreignKey:Employee_Id;references:Id"`
IHS_Number *string `json:"ihs_number" gorm:"size:20"`
Unit_Id *uint16 `json:"unit_id"`
Unit *eu.Unit `json:"unit,omitempty" gorm:"foreignKey:Unit_Id;references:Id"`
}
@@ -20,9 +20,9 @@ type Person struct {
BirthDate *time.Time `json:"birthDate,omitempty"`
BirthRegency_Code *string `json:"birthRegency_code" gorm:"size:4"`
Gender_Code *erp.GenderCode `json:"gender_code" gorm:"size:10"`
ResidentIdentityNumber *string `json:"residentIdentityNumber" gorm:"size:16"`
PassportNumber *string `json:"passportNumber" gorm:"size:20"`
DrivingLicenseNumber *string `json:"drivingLicenseNumber" gorm:"size:20"`
ResidentIdentityNumber *string `json:"residentIdentityNumber" gorm:"unique;size:16"`
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"`
Education_Code *erp.EducationCode `json:"education_code" gorm:"size:10"`
Ocupation_Code *erp.OcupationCode `json:"occupation_code" gorm:"size:15"`