models/db: introduce TargetEnvironment side-table; batch attach on reads; add CRUD... 08/14808/6
authoralswp006 <alswp006@gmail.com>
Sat, 9 Aug 2025 10:14:43 +0000 (19:14 +0900)
committerMinje Kim <alswp006@gmail.com>
Mon, 13 Oct 2025 09:31:15 +0000 (09:31 +0000)
commit4248cbcab434d0b55c8c59e9eec03a4c1df1d42d
tree5ba01446e14502c7dc5d02abfa8c82956a3a9403
parent7991cedb7c9611e92531611e2207830931554f7a
models/db: introduce TargetEnvironment side-table; batch attach on reads; add CRUD tests

- Add internal-only fields to models.TargetEnvironment:
  * ID (uuid, PK)
  * ModelRelatedInformationID (FK -> model_related_informations.id)
  Both are tagged with json:"-" so the public API remains unchanged.

- Migration:
  * AutoMigrate(&ModelRelatedInformation{}, &TargetEnvironment{}) so
    target_environments has 5 columns:
    (id, model_related_information_id, platform_name, environment_type, dependency_list).
  * For existing DBs, legacy rows without model_related_information_id need
    backfill or archival; otherwise they will not attach to parents.

- Fixes the registration error:
  "column model_related_information_id does not exist".

- Tests:
  * Add CRUD unit test (TestCRUD_Subtests) covering create/read/replace/partial(nil)/clear([])/delete.
    All pass with -race.

Change-Id: Id57bf7721ce2295fceb394a0dd82feab72e60a95
Signed-off-by: alswp006 <alswp006@gmail.com>
db/modelInfoRepository.go
db/modelInfoRepository_test.go [new file with mode: 0644]
main.go
models/modelInfo.go