From 9a0b37390df772d3be6ea99f0d3b3b5611490ad3 Mon Sep 17 00:00:00 2001 From: dpurbosakti Date: Mon, 1 Sep 2025 15:01:02 +0700 Subject: [PATCH] add fk mcusrccategory for mcusrc --- cmd/migration/migrations/20250901080035.sql | 2 ++ cmd/migration/migrations/atlas.sum | 5 +++-- internal/domain/main-entities/mcu-src/entity.go | 10 ++++++---- 3 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 cmd/migration/migrations/20250901080035.sql diff --git a/cmd/migration/migrations/20250901080035.sql b/cmd/migration/migrations/20250901080035.sql new file mode 100644 index 00000000..8b41cd0d --- /dev/null +++ b/cmd/migration/migrations/20250901080035.sql @@ -0,0 +1,2 @@ +-- Modify "McuSrc" table +ALTER TABLE "public"."McuSrc" ADD CONSTRAINT "fk_McuSrc_CheckupCategory" FOREIGN KEY ("CheckupCategory_Code") REFERENCES "public"."McuSrcCategory" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION; diff --git a/cmd/migration/migrations/atlas.sum b/cmd/migration/migrations/atlas.sum index 6da3d7a3..ede3d757 100644 --- a/cmd/migration/migrations/atlas.sum +++ b/cmd/migration/migrations/atlas.sum @@ -1,3 +1,4 @@ -h1:LmZ7NtbArHgEvza5276tSjY3D8/0w98RKEJYM3gxMZk= +h1:MnN9ZF4JC2g1P1r3le7M54HgeoPRDPSY/s+NwP7B9e4= 20250829081952.sql h1:YMsYq3uPsx70EjWSGfYnVRR5GV0q1fRGIszYZAWzXNo= -20250901073356.sql h1:Me41GuoGLGDagM6claco/7G6I1aFBxZAQjdR3qhTxuQ= +20250901073356.sql h1:jjd5TLs+Pyi0u3SrOM+aNTbHxSJboXgcOz/L4bkYx+c= +20250901080035.sql h1:YHNFHu7P0NtRL0kKWHxzrg0n7Hf0aZjthFn8KoJDEpw= diff --git a/internal/domain/main-entities/mcu-src/entity.go b/internal/domain/main-entities/mcu-src/entity.go index bec60ac0..cdd8356f 100644 --- a/internal/domain/main-entities/mcu-src/entity.go +++ b/internal/domain/main-entities/mcu-src/entity.go @@ -2,11 +2,13 @@ package mcusrc import ( ecore "simrs-vx/internal/domain/base-entities/core" + emsc "simrs-vx/internal/domain/main-entities/mcu-src-category" ) type McuSrc struct { - ecore.SmallMain // adjust this according to the needs - Code string `json:"code" gorm:"unique;size:20"` - Name string `json:"name" gorm:"size:50"` - CheckupCategory_Code *string `json:"checkupCategory_code" gorm:"size:20"` + ecore.SmallMain // adjust this according to the needs + Code string `json:"code" gorm:"unique;size:20"` + Name string `json:"name" gorm:"size:50"` + CheckupCategory_Code *string `json:"checkupCategory_code" gorm:"size:20"` + CheckupCategory *emsc.McuSrcCategory `json:"checkupCategory,omitempty" gorm:"foreignKey:CheckupCategory_Code;references:Code"` }