diff options
author | adheli.tavares <adheli.tavares@est.tech> | 2021-08-20 14:44:30 +0100 |
---|---|---|
committer | adheli.tavares <adheli.tavares@est.tech> | 2021-08-20 15:47:53 +0100 |
commit | 22cc75eb4b868bc768c8680802131931912acadd (patch) | |
tree | e5bf37ff71a496c8c8a6d7feea7916b90bb43fad /policy-db-migrator | |
parent | 418adf8e5183871e44ff1af47910344cc301e1fe (diff) |
Update pdpstatistics with IDs for change of PK.
Update the new created ID column with values
when changing pdpstatistics PK composition.
Issue-ID: POLICY-3546
Change-Id: I53939557700237ccc7ab21e4069bd82ec6a4a4cf
Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'policy-db-migrator')
3 files changed, 5 insertions, 1 deletions
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0160-pk_pdpstatistics.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0160-pk_pdpstatistics.sql index 98fecd2f..012344b9 100644 --- a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0160-pk_pdpstatistics.sql +++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0160-pk_pdpstatistics.sql @@ -18,3 +18,5 @@ */ ALTER TABLE pdpstatistics DROP CONSTRAINT PRIMARY KEY; + +UPDATE pdpstatistics set ID = 0; diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0160-pk_pdpstatistics.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0160-pk_pdpstatistics.sql index e0987223..b8a96b68 100644 --- a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0160-pk_pdpstatistics.sql +++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0160-pk_pdpstatistics.sql @@ -17,4 +17,6 @@ * ============LICENSE_END========================================================= */ +UPDATE pdpstatistics as p JOIN (SELECT name, version, timeStamp, ROW_NUMBER() OVER (ORDER BY timeStamp ASC) AS row_num FROM pdpstatistics GROUP BY name, version, timeStamp) AS t ON (p.name=t.name AND p.version=t.version AND p.timeStamp = t.timeStamp) SET p.id=t.row_num; + ALTER TABLE pdpstatistics ADD CONSTRAINT PK_PDPSTATISTICS PRIMARY KEY (ID, name, version); diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0210-sequence.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0210-sequence.sql index 8b1a0c22..c90905ef 100644 --- a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0210-sequence.sql +++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0210-sequence.sql @@ -17,4 +17,4 @@ * ============LICENSE_END========================================================= */ -INSERT INTO sequence(SEQ_NAME, SEQ_COUNT) VALUES('SEQ_GEN', 0); +INSERT INTO sequence(SEQ_NAME, SEQ_COUNT) VALUES('SEQ_GEN', (SELECT IFNULL(max(id),0) FROM pdpstatistics)); |