@balena/open-balena-api 31.2.0-build-add-device-service-fks-1ff87a4571c56db99c0ea335811003f32b366432-1 → 31.2.0-build-add-device-service-fks-e134122e881a2870c98ee9012ef32361ecbb0685-1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/features/ci-cd/hooks/backfill-device-service-environment-variable.js +1 -1
- package/dist/features/ci-cd/hooks/backfill-device-service-environment-variable.js.map +1 -1
- package/dist/migrations/00095-add-device-service-fks-to-device-service-environment-variable.sql +35 -9
- package/package.json +2 -2
@@ -12,7 +12,7 @@ async function backfillDeviceAndService({ request, api, }) {
|
|
12
12
|
},
|
13
13
|
});
|
14
14
|
if (si == null) {
|
15
|
-
throw new errors.
|
15
|
+
throw new errors.UnauthorizedError();
|
16
16
|
}
|
17
17
|
request.values.device = si.device.__id;
|
18
18
|
request.values.service = si.service.__id;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"backfill-device-service-environment-variable.js","sourceRoot":"","sources":["../../../../src/features/ci-cd/hooks/backfill-device-service-environment-variable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAkB,MAAM,gBAAgB,CAAC;AAE/D,KAAK,UAAU,wBAAwB,CAAC,EACvC,OAAO,EACP,GAAG,GAC0B;IAC7B,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAEjD,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;QAClB,OAAO;IACR,CAAC;IAED,MAAM,EAAE,GAAG,MAAM,GAAG,CAAC,GAAG,CAAC;QACxB,QAAQ,EAAE,iBAAiB;QAC3B,EAAE,EAAE,IAAI;QACR,OAAO,EAAE;YACR,OAAO,EAAE,CAAC,QAAQ,EAAE,SAAS,CAAC;SAC9B;KACD,CAAC,CAAC;IAEH,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC;QAChB,MAAM,IAAI,MAAM,CAAC,
|
1
|
+
{"version":3,"file":"backfill-device-service-environment-variable.js","sourceRoot":"","sources":["../../../../src/features/ci-cd/hooks/backfill-device-service-environment-variable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAkB,MAAM,gBAAgB,CAAC;AAE/D,KAAK,UAAU,wBAAwB,CAAC,EACvC,OAAO,EACP,GAAG,GAC0B;IAC7B,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAEjD,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;QAClB,OAAO;IACR,CAAC;IAED,MAAM,EAAE,GAAG,MAAM,GAAG,CAAC,GAAG,CAAC;QACxB,QAAQ,EAAE,iBAAiB;QAC3B,EAAE,EAAE,IAAI;QACR,OAAO,EAAE;YACR,OAAO,EAAE,CAAC,QAAQ,EAAE,SAAS,CAAC;SAC9B;KACD,CAAC,CAAC;IAEH,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC;QAChB,MAAM,IAAI,MAAM,CAAC,iBAAiB,EAAE,CAAC;IACtC,CAAC;IAED,OAAO,CAAC,MAAM,CAAC,MAAM,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC;IACvC,OAAO,CAAC,MAAM,CAAC,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;AAC1C,CAAC;AAED,KAAK,CAAC,WAAW,CAAC,MAAM,EAAE,OAAO,EAAE,qCAAqC,EAAE;IACzE,SAAS,EAAE,wBAAwB;CACnC,CAAC,CAAC;AAEH,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,qCAAqC,EAAE;IAC1E,SAAS,EAAE,wBAAwB;CACnC,CAAC,CAAC"}
|
package/dist/migrations/00095-add-device-service-fks-to-device-service-environment-variable.sql
CHANGED
@@ -1,14 +1,40 @@
|
|
1
1
|
ALTER TABLE "device service environment variable"
|
2
|
-
ADD COLUMN IF NOT EXISTS "device" INTEGER NULL
|
3
|
-
ADD CONSTRAINT "device service environment variable_device_fkey"
|
4
|
-
FOREIGN KEY ("device")
|
5
|
-
REFERENCES "device" ("id");
|
2
|
+
ADD COLUMN IF NOT EXISTS "device" INTEGER NULL;
|
6
3
|
|
7
4
|
ALTER TABLE "device service environment variable"
|
8
|
-
ADD COLUMN IF NOT EXISTS "service" INTEGER NULL
|
9
|
-
ADD CONSTRAINT "device service environment variable_service_fkey"
|
10
|
-
FOREIGN KEY ("service")
|
11
|
-
REFERENCES "service" ("id");
|
5
|
+
ADD COLUMN IF NOT EXISTS "service" INTEGER NULL;
|
12
6
|
|
13
|
-
CREATE UNIQUE INDEX
|
7
|
+
CREATE UNIQUE INDEX IF NOT EXISTS "device service environment variable_device_service_name_key"
|
14
8
|
ON "device service environment variable" ("device", "service", "name");
|
9
|
+
|
10
|
+
DO $$
|
11
|
+
BEGIN
|
12
|
+
IF NOT EXISTS (
|
13
|
+
SELECT 1
|
14
|
+
FROM information_schema.table_constraints AS tc
|
15
|
+
JOIN information_schema.key_column_usage AS kcu ON tc.constraint_name = kcu.constraint_name
|
16
|
+
WHERE tc.constraint_type = 'FOREIGN KEY'
|
17
|
+
AND tc.table_schema = CURRENT_SCHEMA()
|
18
|
+
AND tc.table_name = 'device service environment variable'
|
19
|
+
AND kcu.column_name = 'device'
|
20
|
+
) THEN
|
21
|
+
ALTER TABLE "device service environment variable"
|
22
|
+
ADD CONSTRAINT "device service environment variable_device_fkey"
|
23
|
+
FOREIGN KEY ("device") REFERENCES "device" ("id");
|
24
|
+
END IF;
|
25
|
+
|
26
|
+
IF NOT EXISTS (
|
27
|
+
SELECT 1
|
28
|
+
FROM information_schema.table_constraints AS tc
|
29
|
+
JOIN information_schema.key_column_usage AS kcu ON tc.constraint_name = kcu.constraint_name
|
30
|
+
WHERE tc.constraint_type = 'FOREIGN KEY'
|
31
|
+
AND tc.table_schema = CURRENT_SCHEMA()
|
32
|
+
AND tc.table_name = 'device service environment variable'
|
33
|
+
AND kcu.column_name = 'service'
|
34
|
+
) THEN
|
35
|
+
ALTER TABLE "device service environment variable"
|
36
|
+
ADD CONSTRAINT "device service environment variable_service_fkey"
|
37
|
+
FOREIGN KEY ("service") REFERENCES "service" ("id");
|
38
|
+
END IF;
|
39
|
+
END;
|
40
|
+
$$;
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@balena/open-balena-api",
|
3
3
|
"description": "Internet of things, Made Simple",
|
4
|
-
"version": "31.2.0-build-add-device-service-fks-
|
4
|
+
"version": "31.2.0-build-add-device-service-fks-e134122e881a2870c98ee9012ef32361ecbb0685-1",
|
5
5
|
"license": "AGPL-3.0",
|
6
6
|
"repository": {
|
7
7
|
"type": "git",
|
@@ -166,6 +166,6 @@
|
|
166
166
|
"loader": "ts-node/esm/transpile-only"
|
167
167
|
},
|
168
168
|
"versionist": {
|
169
|
-
"publishedAt": "2024-11-
|
169
|
+
"publishedAt": "2024-11-13T12:32:09.328Z"
|
170
170
|
}
|
171
171
|
}
|