aboutsummaryrefslogtreecommitdiffstats
path: root/policy-db-migrator/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'policy-db-migrator/src/main')
-rw-r--r--policy-db-migrator/src/main/docker/Dockerfile2
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0100-pdp.sql (renamed from policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0120-pdp.sql)0
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0110-idx_tsidx1.sql (renamed from policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0130-idx_tsidx1.sql)0
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0120-pk_pdpstatistics.sql (renamed from policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0170-pdpstatistics.sql)2
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0130-pdpstatistics.sql20
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0140-pk_pdpstatistics.sql4
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0150-pdpstatistics.sql2
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0160-jpapdpstatistics_enginestats.sql (renamed from policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0110-jpapdpstatistics_enginestats.sql)0
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0170-jpapdpstatistics_enginestats.sql22
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0180-jpapdpstatistics_enginestats.sql (renamed from policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0100-jpapdpstatistics_enginestats.sql)0
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0190-jpapolicyaudit.sql (renamed from policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0180-jpapolicyaudit.sql)0
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0200-JpaPolicyAuditIndex_timestamp.sql (renamed from policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0190-JpaPolicyAuditIndex_timestamp.sql)0
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0210-sequence.sql2
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0220-sequence.sql (renamed from policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0200-sequence.sql)2
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0100-pdp.sql (renamed from policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0160-pk_pdpstatistics.sql)4
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0110-idx_tsidx1.sql (renamed from policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0130-idx_tsidx1.sql)0
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0120-pk_pdpstatistics.sql (renamed from policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0170-pdpstatistics.sql)2
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0130-pdpstatistics.sql20
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0140-pk_pdpstatistics.sql4
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0150-pdpstatistics.sql2
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0160-jpapdpstatistics_enginestats.sql (renamed from policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0110-jpapdpstatistics_enginestats.sql)0
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0160-pk_pdpstatistics.sql22
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0170-jpapdpstatistics_enginestats.sql22
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0180-jpapdpstatistics_enginestats.sql (renamed from policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0100-jpapdpstatistics_enginestats.sql)0
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0190-jpapolicyaudit.sql (renamed from policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0180-jpapolicyaudit.sql)0
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0200-JpaPolicyAuditIndex_timestamp.sql (renamed from policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0190-JpaPolicyAuditIndex_timestamp.sql)0
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0200-sequence.sql20
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0210-sequence.sql2
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0220-sequence.sql (renamed from policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0120-pdp.sql)2
-rwxr-xr-xpolicy-db-migrator/src/main/docker/db-migrator4
30 files changed, 102 insertions, 58 deletions
diff --git a/policy-db-migrator/src/main/docker/Dockerfile b/policy-db-migrator/src/main/docker/Dockerfile
index 581c8299..42cb42fb 100644
--- a/policy-db-migrator/src/main/docker/Dockerfile
+++ b/policy-db-migrator/src/main/docker/Dockerfile
@@ -18,7 +18,7 @@
# SPDX-License-Identifier: Apache-2.0
# ============LICENSE_END=========================================================
#-------------------------------------------------------------------------------
-FROM onap/policy-jdk-alpine:2.2.1
+FROM onap/policy-jdk-alpine:2.3.0
LABEL maintainer="Policy Team"
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0120-pdp.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0100-pdp.sql
index f10c8501..f10c8501 100644
--- a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0120-pdp.sql
+++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0100-pdp.sql
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0130-idx_tsidx1.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0110-idx_tsidx1.sql
index bf9927a3..bf9927a3 100644
--- a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0130-idx_tsidx1.sql
+++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0110-idx_tsidx1.sql
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0170-pdpstatistics.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0120-pk_pdpstatistics.sql
index 4bf55e84..b3d4767d 100644
--- a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0170-pdpstatistics.sql
+++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0120-pk_pdpstatistics.sql
@@ -17,4 +17,4 @@
* ============LICENSE_END=========================================================
*/
-ALTER TABLE pdpstatistics MODIFY COLUMN timeStamp datetime NOT NULL;
+ALTER TABLE pdpstatistics ADD CONSTRAINT PK_PDPSTATISTICS PRIMARY KEY (timeStamp, name, version);
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0130-pdpstatistics.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0130-pdpstatistics.sql
new file mode 100644
index 00000000..461f147b
--- /dev/null
+++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0130-pdpstatistics.sql
@@ -0,0 +1,20 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+ALTER TABLE pdpstatistics DROP COLUMN POLICYUNDEPLOYCOUNT, DROP COLUMN POLICYUNDEPLOYFAILCOUNT, DROP COLUMN POLICYUNDEPLOYSUCCESSCOUNT, DROP COLUMN ID;
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0140-pk_pdpstatistics.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0140-pk_pdpstatistics.sql
index b3d4767d..012344b9 100644
--- a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0140-pk_pdpstatistics.sql
+++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0140-pk_pdpstatistics.sql
@@ -17,4 +17,6 @@
* ============LICENSE_END=========================================================
*/
-ALTER TABLE pdpstatistics ADD CONSTRAINT PK_PDPSTATISTICS PRIMARY KEY (timeStamp, name, version);
+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/downgrade/0150-pdpstatistics.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0150-pdpstatistics.sql
index 461f147b..4bf55e84 100644
--- a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0150-pdpstatistics.sql
+++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0150-pdpstatistics.sql
@@ -17,4 +17,4 @@
* ============LICENSE_END=========================================================
*/
-ALTER TABLE pdpstatistics DROP COLUMN POLICYUNDEPLOYCOUNT, DROP COLUMN POLICYUNDEPLOYFAILCOUNT, DROP COLUMN POLICYUNDEPLOYSUCCESSCOUNT, DROP COLUMN ID;
+ALTER TABLE pdpstatistics MODIFY COLUMN timeStamp datetime NOT NULL;
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0110-jpapdpstatistics_enginestats.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0160-jpapdpstatistics_enginestats.sql
index e3b5a487..e3b5a487 100644
--- a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0110-jpapdpstatistics_enginestats.sql
+++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0160-jpapdpstatistics_enginestats.sql
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0170-jpapdpstatistics_enginestats.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0170-jpapdpstatistics_enginestats.sql
new file mode 100644
index 00000000..7163431b
--- /dev/null
+++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0170-jpapdpstatistics_enginestats.sql
@@ -0,0 +1,22 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+UPDATE jpapdpstatistics_enginestats a
+ JOIN pdpstatistics b
+ ON a.name = b.name AND a.version = b.version AND a.id = b.id
+ SET a.timeStamp = b.timeStamp;
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0100-jpapdpstatistics_enginestats.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0180-jpapdpstatistics_enginestats.sql
index 64b1ad54..64b1ad54 100644
--- a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0100-jpapdpstatistics_enginestats.sql
+++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0180-jpapdpstatistics_enginestats.sql
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0180-jpapolicyaudit.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0190-jpapolicyaudit.sql
index b51d8769..b51d8769 100644
--- a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0180-jpapolicyaudit.sql
+++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0190-jpapolicyaudit.sql
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0190-JpaPolicyAuditIndex_timestamp.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0200-JpaPolicyAuditIndex_timestamp.sql
index 68265c5b..68265c5b 100644
--- a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0190-JpaPolicyAuditIndex_timestamp.sql
+++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0200-JpaPolicyAuditIndex_timestamp.sql
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0210-sequence.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0210-sequence.sql
index 6e3eb083..553b1f16 100644
--- a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0210-sequence.sql
+++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0210-sequence.sql
@@ -17,4 +17,4 @@
* ============LICENSE_END=========================================================
*/
-DELETE from sequence;
+DROP TABLE IF EXISTS `sequence`;
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0200-sequence.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0220-sequence.sql
index 553b1f16..6e3eb083 100644
--- a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0200-sequence.sql
+++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0220-sequence.sql
@@ -17,4 +17,4 @@
* ============LICENSE_END=========================================================
*/
-DROP TABLE IF EXISTS `sequence`;
+DELETE from sequence;
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/upgrade/0100-pdp.sql
index 012344b9..934d89e8 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/upgrade/0100-pdp.sql
@@ -17,6 +17,4 @@
* ============LICENSE_END=========================================================
*/
-ALTER TABLE pdpstatistics DROP CONSTRAINT PRIMARY KEY;
-
-UPDATE pdpstatistics set ID = 0;
+ALTER TABLE pdp ADD COLUMN LASTUPDATE datetime NOT NULL DEFAULT CURRENT_TIMESTAMP AFTER HEALTHY;
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0130-idx_tsidx1.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0110-idx_tsidx1.sql
index 864e4f03..864e4f03 100644
--- a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0130-idx_tsidx1.sql
+++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0110-idx_tsidx1.sql
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0170-pdpstatistics.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0120-pk_pdpstatistics.sql
index 98e26993..4066c012 100644
--- a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0170-pdpstatistics.sql
+++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0120-pk_pdpstatistics.sql
@@ -17,4 +17,4 @@
* ============LICENSE_END=========================================================
*/
-ALTER TABLE pdpstatistics MODIFY COLUMN timeStamp datetime NULL;
+ALTER TABLE pdpstatistics DROP PRIMARY KEY;
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0130-pdpstatistics.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0130-pdpstatistics.sql
new file mode 100644
index 00000000..c4a1123e
--- /dev/null
+++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0130-pdpstatistics.sql
@@ -0,0 +1,20 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+ALTER TABLE pdpstatistics ADD COLUMN POLICYUNDEPLOYCOUNT BIGINT DEFAULT NULL NULL AFTER POLICYEXECUTEDSUCCESSCOUNT, ADD COLUMN POLICYUNDEPLOYFAILCOUNT BIGINT DEFAULT NULL NULL, ADD COLUMN POLICYUNDEPLOYSUCCESSCOUNT BIGINT DEFAULT NULL NULL, ADD COLUMN ID BIGINT NOT NULL;
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0140-pk_pdpstatistics.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0140-pk_pdpstatistics.sql
index 4066c012..b8a96b68 100644
--- a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0140-pk_pdpstatistics.sql
+++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0140-pk_pdpstatistics.sql
@@ -17,4 +17,6 @@
* ============LICENSE_END=========================================================
*/
-ALTER TABLE pdpstatistics DROP PRIMARY KEY;
+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/0150-pdpstatistics.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0150-pdpstatistics.sql
index c4a1123e..98e26993 100644
--- a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0150-pdpstatistics.sql
+++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0150-pdpstatistics.sql
@@ -17,4 +17,4 @@
* ============LICENSE_END=========================================================
*/
-ALTER TABLE pdpstatistics ADD COLUMN POLICYUNDEPLOYCOUNT BIGINT DEFAULT NULL NULL AFTER POLICYEXECUTEDSUCCESSCOUNT, ADD COLUMN POLICYUNDEPLOYFAILCOUNT BIGINT DEFAULT NULL NULL, ADD COLUMN POLICYUNDEPLOYSUCCESSCOUNT BIGINT DEFAULT NULL NULL, ADD COLUMN ID BIGINT NOT NULL;
+ALTER TABLE pdpstatistics MODIFY COLUMN timeStamp datetime NULL;
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0110-jpapdpstatistics_enginestats.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0160-jpapdpstatistics_enginestats.sql
index 6e5bfecd..6e5bfecd 100644
--- a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0110-jpapdpstatistics_enginestats.sql
+++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0160-jpapdpstatistics_enginestats.sql
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
deleted file mode 100644
index b8a96b68..00000000
--- a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0160-pk_pdpstatistics.sql
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============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/0170-jpapdpstatistics_enginestats.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0170-jpapdpstatistics_enginestats.sql
new file mode 100644
index 00000000..ce78c340
--- /dev/null
+++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0170-jpapdpstatistics_enginestats.sql
@@ -0,0 +1,22 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+UPDATE jpapdpstatistics_enginestats a
+ JOIN pdpstatistics b
+ ON a.name = b.name AND a.version = b.version AND a.timeStamp = b.timeStamp
+ SET a.id = b.id;
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0100-jpapdpstatistics_enginestats.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0180-jpapdpstatistics_enginestats.sql
index 16825f4f..16825f4f 100644
--- a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0100-jpapdpstatistics_enginestats.sql
+++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0180-jpapdpstatistics_enginestats.sql
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0180-jpapolicyaudit.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0190-jpapolicyaudit.sql
index a31d2421..a31d2421 100644
--- a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0180-jpapolicyaudit.sql
+++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0190-jpapolicyaudit.sql
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0190-JpaPolicyAuditIndex_timestamp.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0200-JpaPolicyAuditIndex_timestamp.sql
index d789d118..d789d118 100644
--- a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0190-JpaPolicyAuditIndex_timestamp.sql
+++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0200-JpaPolicyAuditIndex_timestamp.sql
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0200-sequence.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0200-sequence.sql
deleted file mode 100644
index 64d6f01b..00000000
--- a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0200-sequence.sql
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-CREATE TABLE IF NOT EXISTS sequence (SEQ_NAME VARCHAR(50) NOT NULL, SEQ_COUNT DECIMAL(38) DEFAULT NULL NULL, CONSTRAINT PK_SEQUENCE PRIMARY KEY (SEQ_NAME));
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 c90905ef..64d6f01b 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', (SELECT IFNULL(max(id),0) FROM pdpstatistics));
+CREATE TABLE IF NOT EXISTS sequence (SEQ_NAME VARCHAR(50) NOT NULL, SEQ_COUNT DECIMAL(38) DEFAULT NULL NULL, CONSTRAINT PK_SEQUENCE PRIMARY KEY (SEQ_NAME));
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0120-pdp.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0220-sequence.sql
index 57a551da..c90905ef 100644
--- a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0120-pdp.sql
+++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0220-sequence.sql
@@ -17,4 +17,4 @@
* ============LICENSE_END=========================================================
*/
-ALTER TABLE pdp ADD COLUMN LASTUPDATE datetime DEFAULT NULL NULL AFTER HEALTHY;
+INSERT INTO sequence(SEQ_NAME, SEQ_COUNT) VALUES('SEQ_GEN', (SELECT IFNULL(max(id),0) FROM pdpstatistics));
diff --git a/policy-db-migrator/src/main/docker/db-migrator b/policy-db-migrator/src/main/docker/db-migrator
index 1d3fe4a3..dd29dfaa 100755
--- a/policy-db-migrator/src/main/docker/db-migrator
+++ b/policy-db-migrator/src/main/docker/db-migrator
@@ -55,7 +55,7 @@
source ${POLICY_HOME}/etc/profile.d/env.sh
METADATA_DB=migration
-METADATA_TABLE=${METADATA_DB}.db_metadata_versions
+METADATA_TABLE=${METADATA_DB}.schema_versions
MIGRATION_DIR=${POLICY_HOME}/etc/db/migration
ZERO_VERSION="0"
BASE_VERSION="0800"
@@ -700,7 +700,7 @@ for dbPath in ${SCHEMA_S}; do
SCHEMA_DB="\`${SCHEMA}\`"
UPGRADE_DIR="${MIGRATION_DIR}"/"${SCHEMA}"/sql
DOWNGRADE_DIR=${UPGRADE_DIR}
- METADATA_HISTORY="${METADATA_DB}.\`${SCHEMA}_change_history\`"
+ METADATA_HISTORY="${METADATA_DB}.\`${SCHEMA}_schema_changelog\`"
TARGET_RELEASE=${INPUT_TARGET_RELEASE}
if is_upgrade && is_downgrade; then