-
Notifications
You must be signed in to change notification settings - Fork 24
/
051-add-source-view-configuration.sql
35 lines (25 loc) · 1.57 KB
/
051-add-source-view-configuration.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
-- https://github.com/scalableminds/webknossos/pull/4357
START TRANSACTION;
DROP VIEW webknossos.dataSets_;
ALTER TABLE webknossos.dataSets ADD COLUMN sourceDefaultConfiguration JSONB;
CREATE VIEW webknossos.dataSets_ AS SELECT * FROM webknossos.dataSets WHERE NOT isDeleted;
ALTER TABLE webknossos.dataSets ADD CONSTRAINT sourceDefaultConfigurationIsJsonObject CHECK(jsonb_typeof(sourceDefaultConfiguration) = 'object');
ALTER TABLE webknossos.dataSet_layers ADD COLUMN defaultViewConfiguration JSONB;
ALTER TABLE webknossos.dataSet_layers ADD CONSTRAINT defaultViewConfigurationIsJsonObject CHECK(jsonb_typeof(defaultViewConfiguration) = 'object');
-- Update alpha value of segmentation layer based on segmentationOpacity
UPDATE webknossos.datasets
SET defaultConfiguration = jsonb_set(
defaultConfiguration,
array['configuration','layers'],
(defaultConfiguration->'configuration'->'layers')::jsonb || jsonb_build_object(dl.name, jsonb_build_object('alpha', defaultconfiguration->'configuration'->'segmentationOpacity')))
FROM webknossos.dataSet_layers dl
WHERE _id = dl._dataset and dl.category = 'segmentation' and defaultconfiguration->'configuration' ? 'segmentationOpacity';
-- Remove segmentationOpacityField
UPDATE webknossos.datasets
SET defaultConfiguration = jsonb_set(
defaultConfiguration,
array['configuration'],
(defaultConfiguration->'configuration')::jsonb - 'segmentationOpacity')
WHERE defaultconfiguration->'configuration' ? 'segmentationOpacity';
UPDATE webknossos.releaseInformation SET schemaVersion = 51;
COMMIT TRANSACTION;