@balena/open-balena-api 31.2.0-build-add-device-service-fks-1ff87a4571c56db99c0ea335811003f32b366432-1 → 31.2.0-build-add-device-service-fks-9099156216b4ffb1e85f2dcd4475a760cb8da5c7-1
Sign up to get free protection for your applications and to get access to all the features.
package/dist/migrations/00095-add-device-service-fks-to-device-service-environment-variable.sql
CHANGED
@@ -1,14 +1,41 @@
|
|
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
|
+
$$;
|
41
|
+
|
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-9099156216b4ffb1e85f2dcd4475a760cb8da5c7-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-13T11:35:20.955Z"
|
170
170
|
}
|
171
171
|
}
|