From 9a86235c89a95a5bfd4457c2b9f229abb403c380 Mon Sep 17 00:00:00 2001 From: Otavio Jacobi Date: Thu, 12 Dec 2024 09:09:59 -0300 Subject: [PATCH] Rollback nullable service install FK on device service environment variable Change-type: patch --- src/balena-model.ts | 14 ++++---------- src/balena.sbvr | 2 +- ...able-on-device-service-environment-variable.sql | 2 ++ 3 files changed, 7 insertions(+), 11 deletions(-) create mode 100644 src/migrations/00101-make-service-install-fk-not-nullable-on-device-service-environment-variable.sql diff --git a/src/balena-model.ts b/src/balena-model.ts index 4f260d69b..1d1aeb2a2 100644 --- a/src/balena-model.ts +++ b/src/balena-model.ts @@ -976,19 +976,13 @@ export interface DeviceServiceEnvironmentVariable { value: Types['Text']['Read']; service_install: | { __id: ServiceInstall['Read']['id'] } - | [ServiceInstall['Read']] - | [] - | null; + | [ServiceInstall['Read']]; device__installs__application__has__service_name: | { __id: ServiceInstall['Read']['id'] } - | [ServiceInstall['Read']] - | [] - | null; + | [ServiceInstall['Read']]; device__installs__service: | { __id: ServiceInstall['Read']['id'] } - | [ServiceInstall['Read']] - | [] - | null; + | [ServiceInstall['Read']]; application__has__service_name: | { __id: Service['Read']['id'] } | [Service['Read']]; @@ -1001,7 +995,7 @@ export interface DeviceServiceEnvironmentVariable { name: Types['Short Text']['Write']; id: Types['Serial']['Write']; value: Types['Text']['Write']; - service_install: ServiceInstall['Write']['id'] | null; + service_install: ServiceInstall['Write']['id']; }; } diff --git a/src/balena.sbvr b/src/balena.sbvr index cb73249d0..a7ec4f273 100644 --- a/src/balena.sbvr +++ b/src/balena.sbvr @@ -813,7 +813,7 @@ Fact type: image environment variable has value Fact type: device service environment variable has value Necessity: each device service environment variable has exactly one value. Fact type: device service environment variable has service install - Necessity: each device service environment variable has at most one service install. + Necessity: each device service environment variable has exactly one service install. -- application tag diff --git a/src/migrations/00101-make-service-install-fk-not-nullable-on-device-service-environment-variable.sql b/src/migrations/00101-make-service-install-fk-not-nullable-on-device-service-environment-variable.sql new file mode 100644 index 000000000..d9a5a5925 --- /dev/null +++ b/src/migrations/00101-make-service-install-fk-not-nullable-on-device-service-environment-variable.sql @@ -0,0 +1,2 @@ +ALTER TABLE "device service environment variable" +ALTER COLUMN "service install" SET NOT NULL;