-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3da3357
commit ce9d077
Showing
16 changed files
with
141 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...se/tractusx/edc/postgresql/migration/asset/V0_0_5__Alter_Asset_Internalize_Properties.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
-- | ||
-- Copyright (c) 2022 Mercedes-Benz Tech Innovation GmbH | ||
-- | ||
-- This program and the accompanying materials are made available under the | ||
-- terms of the Apache License, Version 2.0 which is available at | ||
-- https://www.apache.org/licenses/LICENSE-2.0 | ||
-- | ||
-- SPDX-License-Identifier: Apache-2.0 | ||
-- | ||
-- Contributors: | ||
-- Mercedes-Benz Tech Innovation GmbH - EDC Snapshot 20220815 Update | ||
-- | ||
|
||
-- add columns | ||
ALTER TABLE edc_asset | ||
ADD COLUMN properties JSON; | ||
|
||
ALTER TABLE edc_asset | ||
ADD COLUMN private_properties JSON; | ||
|
||
ALTER TABLE edc_asset | ||
ADD COLUMN data_address JSON; | ||
|
||
-- update data address, move all JSON data into the edc_asset table | ||
UPDATE edc_asset | ||
SET data_address = (SELECT properties FROM edc_asset_dataaddress WHERE asset_id_fk = a.asset_id)::json | ||
FROM edc_asset as a | ||
WHERE edc_asset.asset_id = a.asset_id; | ||
|
||
|
||
-- update properties, move all JSON data from the edc_asset_properties table | ||
UPDATE edc_asset | ||
SET private_properties = (SELECT json_agg(json_build_object('property_name', prop.property_name, 'property_value', | ||
prop.property_value, 'property_type', prop.property_type)) | ||
FROM edc_asset_property prop | ||
WHERE asset_id_fk = a.asset_id | ||
AND prop.property_is_private = true) | ||
FROM edc_asset as a | ||
WHERE edc_asset.asset_id = a.asset_id; | ||
|
||
-- update private properties, move all JSON data from the edc_asset_properties table | ||
UPDATE edc_asset | ||
SET properties = (SELECT json_agg(json_build_object('property_name', prop.property_name, 'property_value', | ||
prop.property_value, 'property_type', prop.property_type)) | ||
FROM edc_asset_property prop | ||
WHERE asset_id_fk = a.asset_id | ||
AND prop.property_is_private = false) | ||
FROM edc_asset as a | ||
WHERE edc_asset.asset_id = a.asset_id; | ||
|
||
|
||
-- do NOT drop edc_asset_dataaddress and edc_asset_property to enable further data migration scripts | ||
|
||
|
16 changes: 16 additions & 0 deletions
16
.../migration/contractdefinition/V0_0_7__Alter_ContractDefinition_Add_Private_Properties.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
-- | ||
-- Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) | ||
-- | ||
-- This program and the accompanying materials are made available under the | ||
-- terms of the Apache License, Version 2.0 which is available at | ||
-- https://www.apache.org/licenses/LICENSE-2.0 | ||
-- | ||
-- SPDX-License-Identifier: Apache-2.0 | ||
-- | ||
-- Contributors: | ||
-- Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation | ||
-- | ||
|
||
-- add columns | ||
ALTER TABLE edc_contract_definitions | ||
ADD COLUMN private_properties JSON; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.