Skip to content

Commit

Permalink
Merge branch 'main' into battery_tabular_modifications
Browse files Browse the repository at this point in the history
  • Loading branch information
FranckLecuyer authored Dec 19, 2023
2 parents 1cc88bd + 61f9dcb commit bfdc255
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:pro="http://www.liquibase.org/xml/ns/pro" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-latest.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd">
<changeSet author="boutiercha" id="migrationMetadataFixNullValues-20231215-1">
<sqlFile
encoding="UTF-8"
path="migrationMetadataFixNullValues_20231215T170225Z.sql"
relativeToChangelogFile="true"
splitStatements="true"
stripComments="true"/>
</changeSet>
</databaseChangeLog>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
-- REMOVE USELESS DATA FROM TABLE BRANCH_STATUS_MODIFICATION
UPDATE branch_status_modification
SET energized_voltage_level_id = NULL
WHERE ( action = 'TRIP' OR action = 'LOCKOUT' OR action = 'SWITCH_ON' )
AND energized_voltage_level_id IS NOT NULL;
-- RECREATE MESSAGE_VALUES IN TABLE MODIFICATION
UPDATE modification m1
SET message_values = (
SELECT
CASE
WHEN bsm.energized_voltage_level_id IS NULL AND bsm.action IS NOT NULL AND bsm.equipment_id IS NOT NULL
THEN '{"action":"' || bsm.action || '","equipmentId":"' || bsm.equipment_id || '"}'
WHEN bsm.energized_voltage_level_id IS NOT NULL AND bsm.action IS NOT NULL AND bsm.equipment_id IS NOT NULL
THEN '{"energizedVoltageLevelId":"' || bsm.energized_voltage_level_id || '","action":"' || bsm.action || '","equipmentId":"' || bsm.equipment_id || '"}'
ELSE m1.message_values
END
FROM modification m
LEFT JOIN branch_status_modification bsm ON m.id = bsm.id
WHERE m1.id = m.id)
WHERE m1.type = 'BRANCH_STATUS_MODIFICATION';
3 changes: 3 additions & 0 deletions src/main/resources/db/changelog/db.changelog-master.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -224,4 +224,7 @@ databaseChangeLog:
relativeToChangelogFile: true
- include:
file: changesets/changelog_20231117T175127Z.xml
relativeToChangelogFile: true
- include:
file: changesets/changelog_20231215T170225Z.xml
relativeToChangelogFile: true

0 comments on commit bfdc255

Please sign in to comment.