aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoradheli.tavares <adheli.tavares@est.tech>2021-08-12 16:51:19 +0100
committerAdheli Tavares <adheli.tavares@est.tech>2021-08-18 14:29:41 +0000
commit65619e9e6ea8c03978fe2fee1580024b76acf1fa (patch)
treeb188e20f3ab638ab75b96489f75044f49e400d0a
parent19ea8c41d6539a602a8f09a357b662723cccae12 (diff)
Upgrade/downgrade on existent tables and indexes.
Issue-ID: POLICY-3535 Change-Id: I755bb0f279f4255eb9c452b9f569a88de69e14f2 Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0110-jpapdpstatistics_enginestats.sql2
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0480-pdpstatistics.sql2
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0100-jpapdpstatistics_enginestats.sql20
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0110-jpapdpstatistics_enginestats.sql (renamed from policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0120-JpaPolicyAuditIndex_timestamp.sql)2
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0120-pdp.sql20
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0130-idx_tsidx1.sql (renamed from policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/0930-IDX_TSIDX1.sql)0
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0140-pk_pdpstatistics.sql20
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0150-pdpstatistics.sql20
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0160-pk_pdpstatistics.sql20
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0170-pdpstatistics.sql20
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0180-jpapolicyaudit.sql (renamed from policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0100-jpapolicyaudit.sql)2
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0190-JpaPolicyAuditIndex_timestamp.sql20
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0200-sequence.sql (renamed from policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0110-sequence.sql)2
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0210-sequence.sql20
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0100-jpapdpstatistics_enginestats.sql20
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0110-jpapdpstatistics_enginestats.sql20
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0120-pdp.sql20
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0130-idx_tsidx1.sql (renamed from policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0930-IDX_TSIDX1.sql)2
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0140-pk_pdpstatistics.sql20
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0150-pdpstatistics.sql20
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0160-pk_pdpstatistics.sql20
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0170-pdpstatistics.sql20
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0180-jpapolicyaudit.sql (renamed from policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0100-jpapolicyaudit.sql)0
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0190-JpaPolicyAuditIndex_timestamp.sql (renamed from policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0120-JpaPolicyAuditIndex_timestamp.sql)0
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0200-sequence.sql (renamed from policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0110-sequence.sql)0
-rw-r--r--policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0210-sequence.sql20
-rwxr-xr-xpolicy-db-migrator/src/main/docker/db-migrator82
27 files changed, 340 insertions, 74 deletions
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0110-jpapdpstatistics_enginestats.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0110-jpapdpstatistics_enginestats.sql
index 0fe67f4f..6be5cf60 100644
--- a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0110-jpapdpstatistics_enginestats.sql
+++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0110-jpapdpstatistics_enginestats.sql
@@ -17,4 +17,4 @@
* ============LICENSE_END=========================================================
*/
-CREATE TABLE IF NOT EXISTS jpapdpstatistics_enginestats (AVERAGEEXECUTIONTIME DOUBLE DEFAULT NULL NULL, ENGINEID VARCHAR(255) NULL, ENGINETIMESTAMP BIGINT DEFAULT NULL NULL, ENGINEWORKERSTATE INT DEFAULT NULL NULL, EVENTCOUNT BIGINT DEFAULT NULL NULL, LASTENTERTIME BIGINT DEFAULT NULL NULL, LASTEXECUTIONTIME BIGINT DEFAULT NULL NULL, LASTSTART BIGINT DEFAULT NULL NULL, UPTIME BIGINT DEFAULT NULL NULL, ID BIGINT DEFAULT NULL NULL, name VARCHAR(120) NULL, version VARCHAR(20) NULL);
+CREATE TABLE IF NOT EXISTS jpapdpstatistics_enginestats (AVERAGEEXECUTIONTIME DOUBLE DEFAULT NULL NULL, ENGINEID VARCHAR(255) NULL, ENGINETIMESTAMP BIGINT DEFAULT NULL NULL, ENGINEWORKERSTATE INT DEFAULT NULL NULL, EVENTCOUNT BIGINT DEFAULT NULL NULL, LASTENTERTIME BIGINT DEFAULT NULL NULL, LASTEXECUTIONTIME BIGINT DEFAULT NULL NULL, LASTSTART BIGINT DEFAULT NULL NULL, UPTIME BIGINT DEFAULT NULL NULL, timeStamp datetime DEFAULT NULL NULL, name VARCHAR(120) NULL, version VARCHAR(20) NULL);
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0480-pdpstatistics.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0480-pdpstatistics.sql
index 79e7b95b..8f67e6b8 100644
--- a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0480-pdpstatistics.sql
+++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0480-pdpstatistics.sql
@@ -17,4 +17,4 @@
* ============LICENSE_END=========================================================
*/
-CREATE TABLE IF NOT EXISTS pdpstatistics (PDPGROUPNAME VARCHAR(120) NULL, PDPSUBGROUPNAME VARCHAR(120) NULL, POLICYDEPLOYCOUNT BIGINT DEFAULT NULL NULL, POLICYDEPLOYFAILCOUNT BIGINT DEFAULT NULL NULL, POLICYDEPLOYSUCCESSCOUNT BIGINT DEFAULT NULL NULL, POLICYEXECUTEDCOUNT BIGINT DEFAULT NULL NULL, POLICYEXECUTEDFAILCOUNT BIGINT DEFAULT NULL NULL, POLICYEXECUTEDSUCCESSCOUNT BIGINT DEFAULT NULL NULL, TIMESTAMP datetime DEFAULT NULL NULL, ID BIGINT NOT NULL, name VARCHAR(120) NOT NULL, version VARCHAR(20) NOT NULL, CONSTRAINT PK_PDPSTATISTICS PRIMARY KEY (ID, name, version));
+CREATE TABLE IF NOT EXISTS pdpstatistics (PDPGROUPNAME VARCHAR(120) NULL, PDPSUBGROUPNAME VARCHAR(120) NULL, POLICYDEPLOYCOUNT BIGINT DEFAULT NULL NULL, POLICYDEPLOYFAILCOUNT BIGINT DEFAULT NULL NULL, POLICYDEPLOYSUCCESSCOUNT BIGINT DEFAULT NULL NULL, POLICYEXECUTEDCOUNT BIGINT DEFAULT NULL NULL, POLICYEXECUTEDFAILCOUNT BIGINT DEFAULT NULL NULL, POLICYEXECUTEDSUCCESSCOUNT BIGINT DEFAULT NULL NULL, timeStamp datetime NOT NULL, name VARCHAR(120) NOT NULL, version VARCHAR(20) NOT NULL, CONSTRAINT PK_PDPSTATISTICS PRIMARY KEY (timeStamp, name, version));
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/0100-jpapdpstatistics_enginestats.sql
new file mode 100644
index 00000000..64b1ad54
--- /dev/null
+++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0100-jpapdpstatistics_enginestats.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 jpapdpstatistics_enginestats ADD COLUMN timeStamp datetime DEFAULT NULL NULL AFTER UPTIME;
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0120-JpaPolicyAuditIndex_timestamp.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0110-jpapdpstatistics_enginestats.sql
index 8b94f2df..e3b5a487 100644
--- a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0120-JpaPolicyAuditIndex_timestamp.sql
+++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0110-jpapdpstatistics_enginestats.sql
@@ -17,4 +17,4 @@
* ============LICENSE_END=========================================================
*/
-DROP INDEX JpaPolicyAuditIndex_timestamp ON jpapolicyaudit;
+ALTER TABLE jpapdpstatistics_enginestats DROP COLUMN ID;
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/0120-pdp.sql
new file mode 100644
index 00000000..f10c8501
--- /dev/null
+++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0120-pdp.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 pdp DROP COLUMN LASTUPDATE;
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/0930-IDX_TSIDX1.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0130-idx_tsidx1.sql
index bf9927a3..bf9927a3 100644
--- a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/0930-IDX_TSIDX1.sql
+++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0130-idx_tsidx1.sql
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
new file mode 100644
index 00000000..b3d4767d
--- /dev/null
+++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0140-pk_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 CONSTRAINT PK_PDPSTATISTICS PRIMARY KEY (timeStamp, name, version);
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
new file mode 100644
index 00000000..461f147b
--- /dev/null
+++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0150-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/0160-pk_pdpstatistics.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0160-pk_pdpstatistics.sql
new file mode 100644
index 00000000..98fecd2f
--- /dev/null
+++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0160-pk_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 CONSTRAINT PRIMARY KEY;
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/0170-pdpstatistics.sql
new file mode 100644
index 00000000..4bf55e84
--- /dev/null
+++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0170-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 MODIFY COLUMN timeStamp datetime NOT NULL;
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0100-jpapolicyaudit.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0180-jpapolicyaudit.sql
index 7eb7b9c1..b51d8769 100644
--- a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0100-jpapolicyaudit.sql
+++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0180-jpapolicyaudit.sql
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2021 Nordix Foundation
* ================================================================================
- * Licensed under the Apache License, Version 2.0;the "License");
+ * 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
*
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/0190-JpaPolicyAuditIndex_timestamp.sql
new file mode 100644
index 00000000..68265c5b
--- /dev/null
+++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0190-JpaPolicyAuditIndex_timestamp.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 jpapolicyaudit DROP INDEX JpaPolicyAuditIndex_timestamp;
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0110-sequence.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0200-sequence.sql
index 8043289c..553b1f16 100644
--- a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0110-sequence.sql
+++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0200-sequence.sql
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2021 Nordix Foundation
* ================================================================================
- * Licensed under the Apache License, Version 2.0;the "License");
+ * 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
*
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
new file mode 100644
index 00000000..6e3eb083
--- /dev/null
+++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0210-sequence.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=========================================================
+ */
+
+DELETE from sequence;
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/0100-jpapdpstatistics_enginestats.sql
new file mode 100644
index 00000000..16825f4f
--- /dev/null
+++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0100-jpapdpstatistics_enginestats.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 jpapdpstatistics_enginestats DROP COLUMN timeStamp;
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/0110-jpapdpstatistics_enginestats.sql
new file mode 100644
index 00000000..6e5bfecd
--- /dev/null
+++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0110-jpapdpstatistics_enginestats.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 jpapdpstatistics_enginestats ADD COLUMN ID BIGINT DEFAULT NULL NULL AFTER UPTIME;
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/0120-pdp.sql
new file mode 100644
index 00000000..57a551da
--- /dev/null
+++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0120-pdp.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 pdp ADD COLUMN LASTUPDATE datetime DEFAULT NULL NULL AFTER HEALTHY;
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0930-IDX_TSIDX1.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0130-idx_tsidx1.sql
index ba63f55c..864e4f03 100644
--- a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0930-IDX_TSIDX1.sql
+++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0130-idx_tsidx1.sql
@@ -17,4 +17,4 @@
* ============LICENSE_END=========================================================
*/
-CREATE INDEX IDX_TSIDX1 ON pdpstatistics(TIMESTAMP, name, version);
+CREATE INDEX IDX_TSIDX1 ON pdpstatistics(timeStamp, name, version);
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
new file mode 100644
index 00000000..4066c012
--- /dev/null
+++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0140-pk_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 PRIMARY KEY;
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
new file mode 100644
index 00000000..c4a1123e
--- /dev/null
+++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0150-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/0160-pk_pdpstatistics.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0160-pk_pdpstatistics.sql
new file mode 100644
index 00000000..e0987223
--- /dev/null
+++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0160-pk_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 CONSTRAINT PK_PDPSTATISTICS PRIMARY KEY (ID, name, version);
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/0170-pdpstatistics.sql
new file mode 100644
index 00000000..98e26993
--- /dev/null
+++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0170-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 MODIFY COLUMN timeStamp datetime NULL;
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0100-jpapolicyaudit.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0180-jpapolicyaudit.sql
index a31d2421..a31d2421 100644
--- a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0100-jpapolicyaudit.sql
+++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0180-jpapolicyaudit.sql
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0120-JpaPolicyAuditIndex_timestamp.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0190-JpaPolicyAuditIndex_timestamp.sql
index d789d118..d789d118 100644
--- a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0120-JpaPolicyAuditIndex_timestamp.sql
+++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0190-JpaPolicyAuditIndex_timestamp.sql
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0110-sequence.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0200-sequence.sql
index 64d6f01b..64d6f01b 100644
--- a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0110-sequence.sql
+++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0200-sequence.sql
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
new file mode 100644
index 00000000..8b1a0c22
--- /dev/null
+++ b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/upgrade/0210-sequence.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=========================================================
+ */
+
+INSERT INTO sequence(SEQ_NAME, SEQ_COUNT) VALUES('SEQ_GEN', 0);
diff --git a/policy-db-migrator/src/main/docker/db-migrator b/policy-db-migrator/src/main/docker/db-migrator
index d66797c1..1d3fe4a3 100755
--- a/policy-db-migrator/src/main/docker/db-migrator
+++ b/policy-db-migrator/src/main/docker/db-migrator
@@ -323,52 +323,6 @@ function previous_release
return 0
}
-#####################################################
-# object_exists
-#####################################################
-
-function object_exists
-{
- if [ "${DEBUG}" = "y" ]; then
- echo "-- object_exists --"
- set -x
- fi
-
- local sqlFile="${1}"
- local query rc objectType objectName
-
- objectName=$(basename ${sqlFile} .sql | cut -f2 -d-)
-
- rc=$(cat ${sqlFile} | awk '/ALTER/ && /CONSTRAINT/' | wc -l)
- if [ $rc -gt 0 ]; then
- objectType="constraint"
- else
- rc=$(cat ${sqlFile} | awk '/INDEX/' | wc -l)
- if [ $rc -gt 0 ]; then
- objectType="index"
- else
- objectType="table"
- fi
- fi
-
- if [ "${objectType}" == "constraint" ]; then
- query="SELECT IF (constraint_count>0, TRUE, FALSE) as constraint_exists FROM "
- query=${query}"(SELECT count(1) as constraint_count from INFORMATION_SCHEMA.TABLE_CONSTRAINTS "
- query=${query}"WHERE lower(constraint_name)=lower('${objectName}') AND table_schema='${SCHEMA}') t"
- elif [ "${objectType}" == "index" ]; then
- query="SELECT IF (index_count>0, TRUE, FALSE) as index_exists FROM "
- query=${query}"(SELECT count(1) as index_count FROM INFORMATION_SCHEMA.STATISTICS "
- query=${query}"WHERE lower(index_name)=lower('${objectName}') AND index_schema='${SCHEMA}') t"
- else
- query="SELECT IF (table_count>0, TRUE, FALSE) as table_exists FROM "
- query=${query}"(SELECT count(1) as table_count FROM INFORMATION_SCHEMA.TABLES "
- query=${query}"WHERE lower(table_name)=lower('${objectName}') AND table_schema='${SCHEMA}') t"
- fi
-
- rc=$(${MYSQL} --skip-column-names --silent --execute "${query}")
-
- return $rc;
-}
#####################################################
# last_operation_status
@@ -508,17 +462,13 @@ function upgrade
rc=0
fi
if [ ${rc} -eq 0 ]; then
- object_exists ${sqlFile}
- rc=$?
- if [ ${rc} -eq 0 ]; then
- run_script "upgrade" "${sqlName}" "${sqlFile}" "${PREVIOUS_RELEASE}" "${schemaVersion}" "${tag}"
- rc=$?
- if [ ${rc} -ne 0 ]; then
- echo "${SCHEMA}: upgrade aborted at ${schemaVersion} by script ${sqlName}"
- set_current_release "${schemaVersion}"
- return ${rc}
- fi
- fi
+ run_script "upgrade" "${sqlName}" "${sqlFile}" "${PREVIOUS_RELEASE}" "${schemaVersion}" "${tag}"
+ rc=$?
+ if [ ${rc} -ne 0 ]; then
+ echo "${SCHEMA}: upgrade aborted at ${schemaVersion} by script ${sqlName}"
+ set_current_release "${schemaVersion}"
+ return ${rc}
+ fi
fi
fi
done
@@ -579,17 +529,13 @@ function downgrade
rc=0
fi
if [ ${rc} -eq 0 ]; then
- object_exists ${sqlFile}
- rc=$?
- if [ ${rc} -eq 1 ]; then
- run_script "downgrade" "${sqlName}" "${sqlFile}" "${schemaVersion}" "${PREVIOUS_RELEASE}" ${tag}
- rc=$?
- if [ ${rc} -ne 0 ]; then
- echo "${SCHEMA}: downgrade aborted at ${schemaVersion} by script ${sqlName}"
- set_current_release "${schemaVersion}"
- return ${rc}
- fi
- fi
+ run_script "downgrade" "${sqlName}" "${sqlFile}" "${schemaVersion}" "${PREVIOUS_RELEASE}" ${tag}
+ rc=$?
+ if [ ${rc} -ne 0 ]; then
+ echo "${SCHEMA}: downgrade aborted at ${schemaVersion} by script ${sqlName}"
+ set_current_release "${schemaVersion}"
+ return ${rc}
+ fi
fi
fi
done