-
Notifications
You must be signed in to change notification settings - Fork 0
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
0950432
commit f29c070
Showing
3 changed files
with
115 additions
and
50 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
84 changes: 44 additions & 40 deletions
84
...ources/db/changelog/changesets/migrationReactiveCapabilityCurvePoint_20242011T150009Z.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 |
---|---|---|
@@ -1,57 +1,61 @@ | ||
alter table generator_modification_entity_reactive_capability_curve_points add column id UUID default random_uuid(); | ||
alter table battery_modification_entity_reactive_capability_curve_points add column id UUID default random_uuid(); | ||
alter table converter_station_modification_rcc_points add column id UUID default random_uuid(); | ||
|
||
with position_value_generator as ( | ||
select | ||
id, | ||
generator_modification_entity_id, | ||
old_maxq, | ||
old_minq, | ||
oldp, | ||
maxq, | ||
minq, | ||
p, | ||
(row_number() over (partition by generator_modification_entity_id) - 1) AS pos_point_new | ||
FROM generator_modification_entity_reactive_capability_curve_points | ||
(row_number() over (partition by generator_modification_entity_id) - 1) as pos_point_new | ||
from generator_modification_entity_reactive_capability_curve_points | ||
) | ||
|
||
update generator_modification_entity_reactive_capability_curve_points g | ||
set pos_point = c.pos_point_new | ||
from position_value_generator c | ||
where g.generator_modification_entity_id = c.generator_modification_entity_id | ||
and g.old_maxq = c.old_maxq and g.old_minq = c.old_minq and g.oldp = c.oldp | ||
and g.maxq = c.maxq and g.minq = c.minq and g.p = c.p; | ||
update generator_modification_entity_reactive_capability_curve_points | ||
set pos_point = ( | ||
select pos_point_new | ||
from position_value_generator | ||
where position_value_generator.id = generator_modification_entity_reactive_capability_curve_points.id | ||
) | ||
where id in ( | ||
select id | ||
from position_value_generator | ||
); | ||
|
||
with position_value_battery as ( | ||
select | ||
id, | ||
battery_modification_entity_id, | ||
old_maxq, | ||
old_minq, | ||
oldp, | ||
maxq, | ||
minq, | ||
p, | ||
(row_number() OVER (partition by battery_modification_entity_id) - 1) AS pos_point_new | ||
(row_number() over (partition by battery_modification_entity_id) - 1) as pos_point_new | ||
from battery_modification_entity_reactive_capability_curve_points | ||
) | ||
update battery_modification_entity_reactive_capability_curve_points g | ||
set pos_point = c.pos_point_new | ||
from position_value_battery c | ||
where g.battery_modification_entity_id = c.battery_modification_entity_id | ||
and g.old_maxq = c.old_maxq and g.old_minq = c.old_minq and g.oldp = c.oldp | ||
and g.maxq = c.maxq and g.minq = c.minq and g.p = c.p; | ||
update battery_modification_entity_reactive_capability_curve_points | ||
set pos_point = ( | ||
select pos_point_new | ||
from position_value_battery | ||
where position_value_battery.id = battery_modification_entity_reactive_capability_curve_points.id | ||
) | ||
where id in ( | ||
select id | ||
from position_value_battery | ||
); | ||
|
||
with position_value_converter_station as ( | ||
select | ||
id, | ||
converter_station_modification_entity_id, | ||
old_maxq, | ||
old_minq, | ||
oldp, | ||
maxq, | ||
minq, | ||
p, | ||
(row_number() over (partition by converter_station_modification_entity_id) - 1) as pos_point_new | ||
from converter_station_modification_rcc_points | ||
) | ||
update converter_station_modification_rcc_points g | ||
set pos_point = c.pos_point_new | ||
from position_value_converter_station c | ||
where g.converter_station_modification_entity_id = c.converter_station_modification_entity_id | ||
and g.old_maxq = c.old_maxq and g.old_minq = c.old_minq and g.oldp = c.oldp | ||
and g.maxq = c.maxq and g.minq = c.minq and g.p = c.p; | ||
update converter_station_modification_rcc_points | ||
set pos_point = ( | ||
select pos_point_new | ||
from position_value_converter_station | ||
where position_value_converter_station.id = converter_station_modification_rcc_points.id | ||
) | ||
where id in ( | ||
select id | ||
from position_value_converter_station | ||
); | ||
|
||
alter table generator_modification_entity_reactive_capability_curve_points drop column id; | ||
alter table battery_modification_entity_reactive_capability_curve_points drop column id; | ||
alter table converter_station_modification_rcc_points drop column id; |
61 changes: 61 additions & 0 deletions
61
...ces/db/changelog/changesets/migrationReactiveCapabilityCurvePoint_pg_20242011T150009Z.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,61 @@ | ||
alter table generator_modification_entity_reactive_capability_curve_points add column id UUID default gen_random_uuid(); | ||
alter table battery_modification_entity_reactive_capability_curve_points add column id UUID default gen_random_uuid(); | ||
alter table converter_station_modification_rcc_points add column id UUID default gen_random_uuid(); | ||
|
||
with position_value_generator as ( | ||
select | ||
id, | ||
generator_modification_entity_id, | ||
(row_number() over (partition by generator_modification_entity_id) - 1) AS pos_point_new | ||
from generator_modification_entity_reactive_capability_curve_points | ||
) | ||
update generator_modification_entity_reactive_capability_curve_points | ||
set pos_point = ( | ||
select pos_point_new | ||
from position_value_generator | ||
where position_value_generator.id = generator_modification_entity_reactive_capability_curve_points.id | ||
) | ||
where id in ( | ||
select id | ||
from position_value_generator | ||
); | ||
|
||
with position_value_battery as ( | ||
select | ||
id, | ||
battery_modification_entity_id, | ||
(row_number() over (partition by battery_modification_entity_id) - 1) AS pos_point_new | ||
from battery_modification_entity_reactive_capability_curve_points | ||
) | ||
update battery_modification_entity_reactive_capability_curve_points | ||
set pos_point = ( | ||
select pos_point_new | ||
from position_value_battery | ||
where position_value_battery.id = battery_modification_entity_reactive_capability_curve_points.id | ||
) | ||
where id in ( | ||
select id | ||
from position_value_battery | ||
); | ||
|
||
with position_value_converter_station as ( | ||
select | ||
id, | ||
converter_station_modification_entity_id, | ||
(row_number() over (partition by converter_station_modification_entity_id) - 1) AS pos_point_new | ||
from converter_station_modification_rcc_points | ||
) | ||
update converter_station_modification_rcc_points | ||
set pos_point = ( | ||
select pos_point_new | ||
from position_value_converter_station | ||
where position_value_converter_station.id = converter_station_modification_rcc_points.id | ||
) | ||
where id in ( | ||
select id | ||
from position_value_converter_station | ||
); | ||
|
||
alter table generator_modification_entity_reactive_capability_curve_points drop column id; | ||
alter table battery_modification_entity_reactive_capability_curve_points drop column id; | ||
alter table converter_station_modification_rcc_points drop column id; |