Update db-migrator to include ability to deal with partial installs 60/122860/3
authorktimoney <kevin.timoney@est.tech>
Thu, 22 Jul 2021 13:25:50 +0000 (14:25 +0100)
committerktimoney <kevin.timoney@est.tech>
Tue, 27 Jul 2021 14:46:31 +0000 (15:46 +0100)
Allow user to upgrade or downgrade form a release that did not complete successfully

Issue-ID: POLICY-3490
Change-Id: Ie14a744246f26a9036066b9f4064bca0c23290be
Signed-off-by: ktimoney <kevin.timoney@est.tech>
68 files changed:
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/0830-FK_ToscaNodeTemplate_capabilitiesName.sql
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/0840-FK_ToscaNodeTemplate_requirementsName.sql
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/0850-FK_ToscaNodeType_requirementsName.sql
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/0860-FK_ToscaServiceTemplate_capabilityTypesName.sql
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/0870-FK_ToscaServiceTemplate_dataTypesName.sql
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/0880-FK_ToscaServiceTemplate_nodeTypesName.sql
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/0890-FK_ToscaServiceTemplate_policyTypesName.sql
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/0900-FK_ToscaServiceTemplate_relationshipTypesName.sql
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/0910-FK_ToscaTopologyTemplate_nodeTemplatesName.sql
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/0920-FK_ToscaTopologyTemplate_policyName.sql
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/0930-IDX_TSIDX1.sql [moved from policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/1040-IDX_TSIDX1.sql with 94% similarity]
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/0940-PdpPolicyStatus_PdpGroup.sql [moved from policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/1050-PdpPolicyStatus_PdpGroup.sql with 94% similarity]
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/0950-TscaServiceTemplatetopologyTemplateParentLocalName.sql [moved from policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/0930-TscaServiceTemplatetopologyTemplateParentLocalName.sql with 90% similarity]
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/0960-FK_ToscaNodeTemplate_capabilitiesName.sql [new file with mode: 0644]
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/0970-FK_ToscaNodeTemplate_requirementsName.sql [new file with mode: 0644]
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/0970-FK_ToscaServiceTemplate_capabilityTypesName.sql [deleted file]
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/0980-FK_ToscaNodeType_requirementsName.sql [new file with mode: 0644]
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/0980-FK_ToscaServiceTemplate_dataTypesName.sql [deleted file]
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/0990-FK_ToscaServiceTemplate_capabilityTypesName.sql [new file with mode: 0644]
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/0990-FK_ToscaServiceTemplate_nodeTypesName.sql [deleted file]
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/1000-FK_ToscaServiceTemplate_dataTypesName.sql [new file with mode: 0644]
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/1000-FK_ToscaServiceTemplate_policyTypesName.sql [deleted file]
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/1010-FK_ToscaServiceTemplate_nodeTypesName.sql [new file with mode: 0644]
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/1010-FK_ToscaServiceTemplate_relationshipTypesName.sql [deleted file]
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/1020-FK_ToscaServiceTemplate_policyTypesName.sql [new file with mode: 0644]
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/1020-FK_ToscaTopologyTemplate_nodeTemplatesName.sql [deleted file]
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/1030-FK_ToscaServiceTemplate_relationshipTypesName.sql [new file with mode: 0644]
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/1030-FK_ToscaTopologyTemplate_policyName.sql [deleted file]
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/1040-FK_ToscaTopologyTemplate_nodeTemplatesName.sql [new file with mode: 0644]
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/1050-FK_ToscaTopologyTemplate_policyName.sql [new file with mode: 0644]
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/1060-TscaServiceTemplatetopologyTemplateParentLocalName.sql
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0830-FK_ToscaNodeTemplate_capabilitiesName.sql
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0840-FK_ToscaNodeTemplate_requirementsName.sql
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0850-FK_ToscaNodeType_requirementsName.sql
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0860-FK_ToscaServiceTemplate_capabilityTypesName.sql
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0870-FK_ToscaServiceTemplate_dataTypesName.sql
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0880-FK_ToscaServiceTemplate_nodeTypesName.sql
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0890-FK_ToscaServiceTemplate_policyTypesName.sql
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0900-FK_ToscaServiceTemplate_relationshipTypesName.sql
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0910-FK_ToscaTopologyTemplate_nodeTemplatesName.sql
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0920-FK_ToscaTopologyTemplate_policyName.sql
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0930-IDX_TSIDX1.sql [moved from policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/1040-IDX_TSIDX1.sql with 100% similarity]
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0930-TscaServiceTemplatetopologyTemplateParentLocalName.sql [deleted file]
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0940-FK_ToscaNodeTemplate_capabilitiesName.sql [deleted file]
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0940-PdpPolicyStatus_PdpGroup.sql [moved from policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/1050-PdpPolicyStatus_PdpGroup.sql with 100% similarity]
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0950-FK_ToscaNodeTemplate_requirementsName.sql [deleted file]
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0950-TscaServiceTemplatetopologyTemplateParentLocalName.sql [new file with mode: 0644]
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0960-FK_ToscaNodeTemplate_capabilitiesName.sql [new file with mode: 0644]
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0960-FK_ToscaNodeType_requirementsName.sql [deleted file]
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0970-FK_ToscaNodeTemplate_requirementsName.sql [new file with mode: 0644]
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0970-FK_ToscaServiceTemplate_capabilityTypesName.sql [deleted file]
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0980-FK_ToscaNodeType_requirementsName.sql [moved from policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/0950-FK_ToscaNodeTemplate_requirementsName.sql with 81% similarity]
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0980-FK_ToscaServiceTemplate_dataTypesName.sql [deleted file]
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0990-FK_ToscaServiceTemplate_capabilityTypesName.sql [new file with mode: 0644]
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0990-FK_ToscaServiceTemplate_nodeTypesName.sql [deleted file]
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/1000-FK_ToscaServiceTemplate_dataTypesName.sql [moved from policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/0960-FK_ToscaNodeType_requirementsName.sql with 81% similarity]
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/1000-FK_ToscaServiceTemplate_policyTypesName.sql [deleted file]
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/1010-FK_ToscaServiceTemplate_nodeTypesName.sql [new file with mode: 0644]
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/1010-FK_ToscaServiceTemplate_relationshipTypesName.sql [deleted file]
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/1020-FK_ToscaServiceTemplate_policyTypesName.sql [new file with mode: 0644]
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/1020-FK_ToscaTopologyTemplate_nodeTemplatesName.sql [deleted file]
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/1030-FK_ToscaServiceTemplate_relationshipTypesName.sql [new file with mode: 0644]
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/1030-FK_ToscaTopologyTemplate_policyName.sql [deleted file]
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/1040-FK_ToscaTopologyTemplate_nodeTemplatesName.sql [new file with mode: 0644]
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/1050-FK_ToscaTopologyTemplate_policyName.sql [moved from policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/0940-FK_ToscaNodeTemplate_capabilitiesName.sql with 81% similarity]
policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/1060-TscaServiceTemplatetopologyTemplateParentLocalName.sql
policy-db-migrator/src/main/docker/config/policyadmin/sql/0900/downgrade/0120-JpaPolicyAuditIndex_timestamp.sql
policy-db-migrator/src/main/docker/db-migrator

index fa180f2..d431072 100644 (file)
@@ -1,4 +1,4 @@
-/*
+ /*
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2021 Nordix Foundation
  *  ================================================================================
@@ -17,4 +17,4 @@
  *  ============LICENSE_END=========================================================
  */
 
-ALTER TABLE toscanodetemplate DROP CONSTRAINT FK_ToscaNodeTemplate_capabilitiesName;
+DROP INDEX FK_ToscaNodeTemplate_capabilitiesName ON toscanodetemplate;
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/0960-FK_ToscaNodeTemplate_capabilitiesName.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/0960-FK_ToscaNodeTemplate_capabilitiesName.sql
new file mode 100644 (file)
index 0000000..fa180f2
--- /dev/null
@@ -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 toscanodetemplate DROP CONSTRAINT FK_ToscaNodeTemplate_capabilitiesName;
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/0970-FK_ToscaNodeTemplate_requirementsName.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/0970-FK_ToscaNodeTemplate_requirementsName.sql
new file mode 100644 (file)
index 0000000..7677f00
--- /dev/null
@@ -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 toscanodetemplate DROP CONSTRAINT FK_ToscaNodeTemplate_requirementsName;
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/0970-FK_ToscaServiceTemplate_capabilityTypesName.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/0970-FK_ToscaServiceTemplate_capabilityTypesName.sql
deleted file mode 100644 (file)
index a7e7159..0000000
+++ /dev/null
@@ -1,24 +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=========================================================
- */
-
-SET FOREIGN_KEY_CHECKS = 0;
-
-DROP INDEX FK_ToscaServiceTemplate_capabilityTypesName ON toscaservicetemplate;
-
-SET FOREIGN_KEY_CHECKS = 1;
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/0980-FK_ToscaNodeType_requirementsName.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/0980-FK_ToscaNodeType_requirementsName.sql
new file mode 100644 (file)
index 0000000..29e7ba6
--- /dev/null
@@ -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 toscanodetype DROP CONSTRAINT FK_ToscaNodeType_requirementsName;
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/0980-FK_ToscaServiceTemplate_dataTypesName.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/0980-FK_ToscaServiceTemplate_dataTypesName.sql
deleted file mode 100644 (file)
index 6d59083..0000000
+++ /dev/null
@@ -1,24 +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=========================================================
- */
-
-SET FOREIGN_KEY_CHECKS = 0;
-
-DROP INDEX FK_ToscaServiceTemplate_dataTypesName ON toscaservicetemplate;
-
-SET FOREIGN_KEY_CHECKS = 1;
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/0990-FK_ToscaServiceTemplate_capabilityTypesName.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/0990-FK_ToscaServiceTemplate_capabilityTypesName.sql
new file mode 100644 (file)
index 0000000..4a13c70
--- /dev/null
@@ -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 toscaservicetemplate DROP CONSTRAINT FK_ToscaServiceTemplate_capabilityTypesName;
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/0990-FK_ToscaServiceTemplate_nodeTypesName.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/0990-FK_ToscaServiceTemplate_nodeTypesName.sql
deleted file mode 100644 (file)
index 4919907..0000000
+++ /dev/null
@@ -1,24 +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=========================================================
- */
-
-SET FOREIGN_KEY_CHECKS = 0;
-
-DROP INDEX FK_ToscaServiceTemplate_nodeTypesName ON toscaservicetemplate;
-
-SET FOREIGN_KEY_CHECKS = 1;
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/1000-FK_ToscaServiceTemplate_dataTypesName.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/1000-FK_ToscaServiceTemplate_dataTypesName.sql
new file mode 100644 (file)
index 0000000..0f5f67a
--- /dev/null
@@ -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 toscaservicetemplate DROP CONSTRAINT FK_ToscaServiceTemplate_dataTypesName;
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/1000-FK_ToscaServiceTemplate_policyTypesName.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/1000-FK_ToscaServiceTemplate_policyTypesName.sql
deleted file mode 100644 (file)
index 970669a..0000000
+++ /dev/null
@@ -1,24 +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=========================================================
- */
-
-SET FOREIGN_KEY_CHECKS = 0;
-
-DROP INDEX FK_ToscaServiceTemplate_policyTypesName ON toscaservicetemplate;
-
-SET FOREIGN_KEY_CHECKS = 1;
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/1010-FK_ToscaServiceTemplate_nodeTypesName.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/1010-FK_ToscaServiceTemplate_nodeTypesName.sql
new file mode 100644 (file)
index 0000000..49ab306
--- /dev/null
@@ -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 toscaservicetemplate DROP CONSTRAINT FK_ToscaServiceTemplate_nodeTypesName;
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/1010-FK_ToscaServiceTemplate_relationshipTypesName.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/1010-FK_ToscaServiceTemplate_relationshipTypesName.sql
deleted file mode 100644 (file)
index b43d414..0000000
+++ /dev/null
@@ -1,24 +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=========================================================
- */
-
-SET FOREIGN_KEY_CHECKS = 0;
-
-DROP INDEX FK_ToscaServiceTemplate_relationshipTypesName ON toscaservicetemplate;
-
-SET FOREIGN_KEY_CHECKS = 1;
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/1020-FK_ToscaServiceTemplate_policyTypesName.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/1020-FK_ToscaServiceTemplate_policyTypesName.sql
new file mode 100644 (file)
index 0000000..63a233c
--- /dev/null
@@ -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 toscaservicetemplate DROP CONSTRAINT FK_ToscaServiceTemplate_policyTypesName;
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/1020-FK_ToscaTopologyTemplate_nodeTemplatesName.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/1020-FK_ToscaTopologyTemplate_nodeTemplatesName.sql
deleted file mode 100644 (file)
index c8aa8e6..0000000
+++ /dev/null
@@ -1,24 +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=========================================================
- */
-
-SET FOREIGN_KEY_CHECKS = 0;
-
-DROP INDEX FK_ToscaTopologyTemplate_nodeTemplatesName ON toscatopologytemplate;
-
-SET FOREIGN_KEY_CHECKS = 1;
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/1030-FK_ToscaServiceTemplate_relationshipTypesName.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/1030-FK_ToscaServiceTemplate_relationshipTypesName.sql
new file mode 100644 (file)
index 0000000..eca7ac6
--- /dev/null
@@ -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 toscaservicetemplate DROP CONSTRAINT FK_ToscaServiceTemplate_relationshipTypesName;
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/1030-FK_ToscaTopologyTemplate_policyName.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/1030-FK_ToscaTopologyTemplate_policyName.sql
deleted file mode 100644 (file)
index e0b73a2..0000000
+++ /dev/null
@@ -1,24 +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=========================================================
- */
-
-SET FOREIGN_KEY_CHECKS = 0;
-
-DROP INDEX FK_ToscaTopologyTemplate_policyName ON toscatopologytemplate;
-
-SET FOREIGN_KEY_CHECKS = 1;
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/1040-FK_ToscaTopologyTemplate_nodeTemplatesName.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/1040-FK_ToscaTopologyTemplate_nodeTemplatesName.sql
new file mode 100644 (file)
index 0000000..427435d
--- /dev/null
@@ -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 toscatopologytemplate DROP CONSTRAINT FK_ToscaTopologyTemplate_nodeTemplatesName;
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/1050-FK_ToscaTopologyTemplate_policyName.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/downgrade/1050-FK_ToscaTopologyTemplate_policyName.sql
new file mode 100644 (file)
index 0000000..8d9627c
--- /dev/null
@@ -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 toscatopologytemplate DROP CONSTRAINT FK_ToscaTopologyTemplate_policyName;
index 96ddf0e..8b9f863 100644 (file)
@@ -17,8 +17,4 @@
  *  ============LICENSE_END=========================================================
  */
 
-SET FOREIGN_KEY_CHECKS = 0;
-
-DROP INDEX TscaServiceTemplatetopologyTemplateParentLocalName ON toscaservicetemplate;
-
-SET FOREIGN_KEY_CHECKS = 1;
+ALTER TABLE toscaservicetemplate DROP CONSTRAINT TscaServiceTemplatetopologyTemplateParentLocalName;
index d96393d..e3597b4 100644 (file)
@@ -17,4 +17,4 @@
  *  ============LICENSE_END=========================================================
  */
 
-ALTER TABLE toscanodetemplate ADD CONSTRAINT FK_ToscaNodeTemplate_capabilitiesName FOREIGN KEY (capabilitiesName, capabilitiesVersion) REFERENCES toscacapabilityassignments (name, version) ON UPDATE RESTRICT ON DELETE RESTRICT;
+CREATE INDEX FK_ToscaNodeTemplate_capabilitiesName ON toscanodetemplate(capabilitiesName, capabilitiesVersion);
index 491a6b7..06c389c 100644 (file)
@@ -17,4 +17,4 @@
  *  ============LICENSE_END=========================================================
  */
 
-ALTER TABLE toscanodetemplate ADD CONSTRAINT FK_ToscaNodeTemplate_requirementsName FOREIGN KEY (requirementsName, requirementsVersion) REFERENCES toscarequirements (name, version) ON UPDATE RESTRICT ON DELETE RESTRICT;
+CREATE INDEX FK_ToscaNodeTemplate_requirementsName ON toscanodetemplate(requirementsName, requirementsVersion);
index c6f37f5..1ee32de 100644 (file)
@@ -17,4 +17,4 @@
  *  ============LICENSE_END=========================================================
  */
 
-ALTER TABLE toscanodetype ADD CONSTRAINT FK_ToscaNodeType_requirementsName FOREIGN KEY (requirementsName, requirementsVersion) REFERENCES toscarequirements (name, version) ON UPDATE RESTRICT ON DELETE RESTRICT;
+CREATE INDEX FK_ToscaNodeType_requirementsName ON toscanodetype(requirementsName, requirementsVersion);
index 2942032..89d0a95 100644 (file)
@@ -17,4 +17,4 @@
  *  ============LICENSE_END=========================================================
  */
 
-ALTER TABLE toscaservicetemplate ADD CONSTRAINT FK_ToscaServiceTemplate_capabilityTypesName FOREIGN KEY (capabilityTypesName, capabilityTypesVersion) REFERENCES toscacapabilitytypes (name, version) ON UPDATE RESTRICT ON DELETE RESTRICT;
+CREATE INDEX FK_ToscaServiceTemplate_capabilityTypesName ON toscaservicetemplate(capabilityTypesName, capabilityTypesVersion);
index 42d1b16..23b1d8c 100644 (file)
@@ -17,4 +17,4 @@
  *  ============LICENSE_END=========================================================
  */
 
-ALTER TABLE toscaservicetemplate ADD CONSTRAINT FK_ToscaServiceTemplate_dataTypesName FOREIGN KEY (dataTypesName, dataTypesVersion) REFERENCES toscadatatypes (name, version) ON UPDATE RESTRICT ON DELETE RESTRICT;
+CREATE INDEX FK_ToscaServiceTemplate_dataTypesName ON toscaservicetemplate(dataTypesName, dataTypesVersion);
index ff40a80..b870126 100644 (file)
@@ -17,4 +17,4 @@
  *  ============LICENSE_END=========================================================
  */
 
-ALTER TABLE toscaservicetemplate ADD CONSTRAINT FK_ToscaServiceTemplate_nodeTypesName FOREIGN KEY (nodeTypesName, nodeTypesVersion) REFERENCES toscanodetypes (name, version) ON UPDATE RESTRICT ON DELETE RESTRICT;
+CREATE INDEX FK_ToscaServiceTemplate_nodeTypesName ON toscaservicetemplate(nodeTypesName, nodeTypesVersion);
index ac0aad0..247cd81 100644 (file)
@@ -17,4 +17,4 @@
  *  ============LICENSE_END=========================================================
  */
 
-ALTER TABLE toscaservicetemplate ADD CONSTRAINT FK_ToscaServiceTemplate_policyTypesName FOREIGN KEY (policyTypesName, policyTypesVersion) REFERENCES toscapolicytypes (name, version) ON UPDATE RESTRICT ON DELETE RESTRICT;
+CREATE INDEX FK_ToscaServiceTemplate_policyTypesName ON toscaservicetemplate(policyTypesName, policyTypesVersion);
index a752667..f9ca8b9 100644 (file)
@@ -17,4 +17,4 @@
  *  ============LICENSE_END=========================================================
  */
 
-ALTER TABLE toscaservicetemplate ADD CONSTRAINT FK_ToscaServiceTemplate_relationshipTypesName FOREIGN KEY (relationshipTypesName, relationshipTypesVersion) REFERENCES toscarelationshiptypes (name, version) ON UPDATE RESTRICT ON DELETE RESTRICT;
+CREATE INDEX FK_ToscaServiceTemplate_relationshipTypesName ON toscaservicetemplate(relationshipTypesName, relationshipTypesVersion);
index 97bf345..b538f8e 100644 (file)
@@ -17,4 +17,4 @@
  *  ============LICENSE_END=========================================================
  */
 
-ALTER TABLE toscatopologytemplate ADD CONSTRAINT FK_ToscaTopologyTemplate_nodeTemplatesName FOREIGN KEY (nodeTemplatesName, nodeTemplatessVersion) REFERENCES toscanodetemplates (name, version) ON UPDATE RESTRICT ON DELETE RESTRICT;
+CREATE INDEX FK_ToscaTopologyTemplate_nodeTemplatesName ON toscatopologytemplate(nodeTemplatesName, nodeTemplatessVersion);
index 3a97349..bd25f3a 100644 (file)
@@ -17,4 +17,4 @@
  *  ============LICENSE_END=========================================================
  */
 
-ALTER TABLE toscatopologytemplate ADD CONSTRAINT FK_ToscaTopologyTemplate_policyName FOREIGN KEY (policyName, policyVersion) REFERENCES toscapolicies (name, version) ON UPDATE RESTRICT ON DELETE RESTRICT;
+CREATE INDEX FK_ToscaTopologyTemplate_policyName ON toscatopologytemplate(policyName, policyVersion);
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0930-TscaServiceTemplatetopologyTemplateParentLocalName.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0930-TscaServiceTemplatetopologyTemplateParentLocalName.sql
deleted file mode 100644 (file)
index ca03af8..0000000
+++ /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=========================================================
- */
-
-ALTER TABLE toscaservicetemplate ADD CONSTRAINT TscaServiceTemplatetopologyTemplateParentLocalName FOREIGN KEY (topologyTemplateParentLocalName, topologyTemplateLocalName, topologyTemplateParentKeyVersion, topologyTemplateParentKeyName) REFERENCES toscatopologytemplate (parentLocalName, localName, parentKeyVersion, parentKeyName) ON UPDATE RESTRICT ON DELETE RESTRICT;
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0940-FK_ToscaNodeTemplate_capabilitiesName.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0940-FK_ToscaNodeTemplate_capabilitiesName.sql
deleted file mode 100644 (file)
index e3597b4..0000000
+++ /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 INDEX FK_ToscaNodeTemplate_capabilitiesName ON toscanodetemplate(capabilitiesName, capabilitiesVersion);
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0950-FK_ToscaNodeTemplate_requirementsName.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0950-FK_ToscaNodeTemplate_requirementsName.sql
deleted file mode 100644 (file)
index 06c389c..0000000
+++ /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 INDEX FK_ToscaNodeTemplate_requirementsName ON toscanodetemplate(requirementsName, requirementsVersion);
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0950-TscaServiceTemplatetopologyTemplateParentLocalName.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0950-TscaServiceTemplatetopologyTemplateParentLocalName.sql
new file mode 100644 (file)
index 0000000..0fe5197
--- /dev/null
@@ -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=========================================================
+ */
+
+CREATE INDEX TscaServiceTemplatetopologyTemplateParentLocalName ON toscaservicetemplate(topologyTemplateParentLocalName, topologyTemplateLocalName, topologyTemplateParentKeyVersion, topologyTemplateParentKeyName);
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0960-FK_ToscaNodeTemplate_capabilitiesName.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0960-FK_ToscaNodeTemplate_capabilitiesName.sql
new file mode 100644 (file)
index 0000000..d96393d
--- /dev/null
@@ -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 toscanodetemplate ADD CONSTRAINT FK_ToscaNodeTemplate_capabilitiesName FOREIGN KEY (capabilitiesName, capabilitiesVersion) REFERENCES toscacapabilityassignments (name, version) ON UPDATE RESTRICT ON DELETE RESTRICT;
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0960-FK_ToscaNodeType_requirementsName.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0960-FK_ToscaNodeType_requirementsName.sql
deleted file mode 100644 (file)
index 1ee32de..0000000
+++ /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 INDEX FK_ToscaNodeType_requirementsName ON toscanodetype(requirementsName, requirementsVersion);
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0970-FK_ToscaNodeTemplate_requirementsName.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0970-FK_ToscaNodeTemplate_requirementsName.sql
new file mode 100644 (file)
index 0000000..491a6b7
--- /dev/null
@@ -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 toscanodetemplate ADD CONSTRAINT FK_ToscaNodeTemplate_requirementsName FOREIGN KEY (requirementsName, requirementsVersion) REFERENCES toscarequirements (name, version) ON UPDATE RESTRICT ON DELETE RESTRICT;
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0970-FK_ToscaServiceTemplate_capabilityTypesName.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0970-FK_ToscaServiceTemplate_capabilityTypesName.sql
deleted file mode 100644 (file)
index 89d0a95..0000000
+++ /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 INDEX FK_ToscaServiceTemplate_capabilityTypesName ON toscaservicetemplate(capabilityTypesName, capabilityTypesVersion);
@@ -17,8 +17,4 @@
  *  ============LICENSE_END=========================================================
  */
 
-SET FOREIGN_KEY_CHECKS = 0;
-
-DROP INDEX FK_ToscaNodeTemplate_requirementsName ON toscanodetemplate;
-
-SET FOREIGN_KEY_CHECKS = 1;
+ALTER TABLE toscanodetype ADD CONSTRAINT FK_ToscaNodeType_requirementsName FOREIGN KEY (requirementsName, requirementsVersion) REFERENCES toscarequirements (name, version) ON UPDATE RESTRICT ON DELETE RESTRICT;
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0980-FK_ToscaServiceTemplate_dataTypesName.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0980-FK_ToscaServiceTemplate_dataTypesName.sql
deleted file mode 100644 (file)
index 23b1d8c..0000000
+++ /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 INDEX FK_ToscaServiceTemplate_dataTypesName ON toscaservicetemplate(dataTypesName, dataTypesVersion);
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0990-FK_ToscaServiceTemplate_capabilityTypesName.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0990-FK_ToscaServiceTemplate_capabilityTypesName.sql
new file mode 100644 (file)
index 0000000..2942032
--- /dev/null
@@ -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 toscaservicetemplate ADD CONSTRAINT FK_ToscaServiceTemplate_capabilityTypesName FOREIGN KEY (capabilityTypesName, capabilityTypesVersion) REFERENCES toscacapabilitytypes (name, version) ON UPDATE RESTRICT ON DELETE RESTRICT;
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0990-FK_ToscaServiceTemplate_nodeTypesName.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/0990-FK_ToscaServiceTemplate_nodeTypesName.sql
deleted file mode 100644 (file)
index b870126..0000000
+++ /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 INDEX FK_ToscaServiceTemplate_nodeTypesName ON toscaservicetemplate(nodeTypesName, nodeTypesVersion);
@@ -17,8 +17,4 @@
  *  ============LICENSE_END=========================================================
  */
 
-SET FOREIGN_KEY_CHECKS = 0;
-
-DROP INDEX FK_ToscaNodeType_requirementsName ON toscanodetype;
-
-SET FOREIGN_KEY_CHECKS = 1;
+ALTER TABLE toscaservicetemplate ADD CONSTRAINT FK_ToscaServiceTemplate_dataTypesName FOREIGN KEY (dataTypesName, dataTypesVersion) REFERENCES toscadatatypes (name, version) ON UPDATE RESTRICT ON DELETE RESTRICT;
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/1000-FK_ToscaServiceTemplate_policyTypesName.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/1000-FK_ToscaServiceTemplate_policyTypesName.sql
deleted file mode 100644 (file)
index 247cd81..0000000
+++ /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 INDEX FK_ToscaServiceTemplate_policyTypesName ON toscaservicetemplate(policyTypesName, policyTypesVersion);
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/1010-FK_ToscaServiceTemplate_nodeTypesName.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/1010-FK_ToscaServiceTemplate_nodeTypesName.sql
new file mode 100644 (file)
index 0000000..ff40a80
--- /dev/null
@@ -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 toscaservicetemplate ADD CONSTRAINT FK_ToscaServiceTemplate_nodeTypesName FOREIGN KEY (nodeTypesName, nodeTypesVersion) REFERENCES toscanodetypes (name, version) ON UPDATE RESTRICT ON DELETE RESTRICT;
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/1010-FK_ToscaServiceTemplate_relationshipTypesName.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/1010-FK_ToscaServiceTemplate_relationshipTypesName.sql
deleted file mode 100644 (file)
index f9ca8b9..0000000
+++ /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 INDEX FK_ToscaServiceTemplate_relationshipTypesName ON toscaservicetemplate(relationshipTypesName, relationshipTypesVersion);
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/1020-FK_ToscaServiceTemplate_policyTypesName.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/1020-FK_ToscaServiceTemplate_policyTypesName.sql
new file mode 100644 (file)
index 0000000..ac0aad0
--- /dev/null
@@ -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 toscaservicetemplate ADD CONSTRAINT FK_ToscaServiceTemplate_policyTypesName FOREIGN KEY (policyTypesName, policyTypesVersion) REFERENCES toscapolicytypes (name, version) ON UPDATE RESTRICT ON DELETE RESTRICT;
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/1020-FK_ToscaTopologyTemplate_nodeTemplatesName.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/1020-FK_ToscaTopologyTemplate_nodeTemplatesName.sql
deleted file mode 100644 (file)
index b538f8e..0000000
+++ /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 INDEX FK_ToscaTopologyTemplate_nodeTemplatesName ON toscatopologytemplate(nodeTemplatesName, nodeTemplatessVersion);
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/1030-FK_ToscaServiceTemplate_relationshipTypesName.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/1030-FK_ToscaServiceTemplate_relationshipTypesName.sql
new file mode 100644 (file)
index 0000000..a752667
--- /dev/null
@@ -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 toscaservicetemplate ADD CONSTRAINT FK_ToscaServiceTemplate_relationshipTypesName FOREIGN KEY (relationshipTypesName, relationshipTypesVersion) REFERENCES toscarelationshiptypes (name, version) ON UPDATE RESTRICT ON DELETE RESTRICT;
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/1030-FK_ToscaTopologyTemplate_policyName.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/1030-FK_ToscaTopologyTemplate_policyName.sql
deleted file mode 100644 (file)
index bd25f3a..0000000
+++ /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 INDEX FK_ToscaTopologyTemplate_policyName ON toscatopologytemplate(policyName, policyVersion);
diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/1040-FK_ToscaTopologyTemplate_nodeTemplatesName.sql b/policy-db-migrator/src/main/docker/config/policyadmin/sql/0800/upgrade/1040-FK_ToscaTopologyTemplate_nodeTemplatesName.sql
new file mode 100644 (file)
index 0000000..97bf345
--- /dev/null
@@ -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 toscatopologytemplate ADD CONSTRAINT FK_ToscaTopologyTemplate_nodeTemplatesName FOREIGN KEY (nodeTemplatesName, nodeTemplatessVersion) REFERENCES toscanodetemplates (name, version) ON UPDATE RESTRICT ON DELETE RESTRICT;
@@ -17,8 +17,4 @@
  *  ============LICENSE_END=========================================================
  */
 
-SET FOREIGN_KEY_CHECKS = 0;
-
-DROP INDEX FK_ToscaNodeTemplate_capabilitiesName ON toscanodetemplate;
-
-SET FOREIGN_KEY_CHECKS = 1;
+ALTER TABLE toscatopologytemplate ADD CONSTRAINT FK_ToscaTopologyTemplate_policyName FOREIGN KEY (policyName, policyVersion) REFERENCES toscapolicies (name, version) ON UPDATE RESTRICT ON DELETE RESTRICT;
index 0fe5197..ca03af8 100644 (file)
@@ -17,4 +17,4 @@
  *  ============LICENSE_END=========================================================
  */
 
-CREATE INDEX TscaServiceTemplatetopologyTemplateParentLocalName ON toscaservicetemplate(topologyTemplateParentLocalName, topologyTemplateLocalName, topologyTemplateParentKeyVersion, topologyTemplateParentKeyName);
+ALTER TABLE toscaservicetemplate ADD CONSTRAINT TscaServiceTemplatetopologyTemplateParentLocalName FOREIGN KEY (topologyTemplateParentLocalName, topologyTemplateLocalName, topologyTemplateParentKeyVersion, topologyTemplateParentKeyName) REFERENCES toscatopologytemplate (parentLocalName, localName, parentKeyVersion, parentKeyName) ON UPDATE RESTRICT ON DELETE RESTRICT;
index 7eced0e..d66797c 100644 (file)
@@ -323,6 +323,87 @@ 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
+#####################################################
+
+function last_operation_status
+{
+    if [ "${DEBUG}" = "y" ]; then
+        echo "-- last_operation_status --"
+        set -x
+    fi
+
+    local query rc row
+
+    query="SELECT script, operation, from_version, to_version, success FROM  "
+    query=${query}"${METADATA_HISTORY} WHERE id="
+    query=${query}"(SELECT MAX(id) from ${METADATA_HISTORY}) "
+    query=${query}"AND success=0"
+
+    row=$(${MYSQL} --skip-column-names --silent --execute "${query}")
+
+    if [ "${row}" != "" ]; then
+        LAST_SCRIPT=$(echo $row | awk '{print $1}')
+        LAST_OPERATION=$(echo $row | awk '{print $2}')
+        LAST_FROM_VERSION=$(echo $row | awk '{print $3}')
+        LAST_TO_VERSION=$(echo $row | awk '{print $4}')
+        LAST_STATUS=$(echo $row | awk '{print $5}')
+        rc=0
+    else
+        rc=1
+    fi
+
+    return $rc;
+}
+
 #####################################################
 # execute sql script history
 #####################################################
@@ -387,10 +468,28 @@ function upgrade
         set -x
     fi
 
-    local sqlName sqlFile schemaVersion upgradeSqls rc tagDate tag
+    local sqlName sqlFile schemaVersion upgradeSqls rc tagDate tag retry compare
     tagDate=$(date +%d%m%y%H%M%S)
+    retry=0
 
     echo "upgrade: ${CURRENT_RELEASE} -> ${TARGET_UPGRADE_RELEASE}"
+    last_operation_status
+    rc=$?
+    if [ $rc -eq 0 ]; then
+         echo "Partial $LAST_OPERATION detected"
+         retry=1
+         if [ "${LAST_OPERATION}" == 'upgrade' ]; then
+              CURRENT_RELEASE="${LAST_FROM_VERSION}"
+              # less than
+              compare="lt"
+              echo "Upgrade will attempt to resume at $LAST_SCRIPT"
+         else
+              CURRENT_RELEASE="${LAST_TO_VERSION}"
+              # less than or equal
+              compare="le"
+              echo "Upgrade will attempt to resume after $LAST_SCRIPT"
+         fi
+    fi
 
     if [ ${CURRENT_RELEASE} \< ${TARGET_UPGRADE_RELEASE} ]; then
         upgradeSqls=$(ls -v "${UPGRADE_DIR}"/*/upgrade/*.sql 2> /dev/null)
@@ -401,12 +500,25 @@ function upgrade
             if [ "${schemaVersion}" -gt "${CURRENT_RELEASE}" ] && \
                 [ "${schemaVersion}" -le "${TARGET_UPGRADE_RELEASE}" ]; then
                 tag=${tagDate}"${schemaVersion}u"
-                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}
+                if [ $retry -eq 1 ] && \
+                    # Compare the numeric portion of the filename because shell doesn't support string comparison
+                    [ $(echo ${sqlName}| awk -F- '{print $1}') -${compare} $(echo ${LAST_SCRIPT}| awk -F- '{print $1}') ]; then
+                     rc=1
+                else
+                     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
                 fi
             fi
         done
@@ -428,10 +540,28 @@ function downgrade
         set -x
     fi
 
-    local sqlName sqlFile schemaVersion downgradeSqls rc tagDate tag
+    local sqlName sqlFile schemaVersion downgradeSqls rc tagDate tag retry compare
     tagDate=$(date +%d%m%y%H%M%S)
+    retry=0
 
     echo "downgrade: ${CURRENT_RELEASE} -> ${TARGET_DOWNGRADE_RELEASE}"
+    last_operation_status
+    rc=$?
+    if [ $rc -eq 0 ]; then
+         echo "Partial $LAST_OPERATION detected"
+         retry=1
+         if [ "${LAST_OPERATION}" == 'downgrade' ]; then
+              CURRENT_RELEASE="${LAST_FROM_VERSION}"
+              # greater than
+              compare="gt"
+              echo "Downgrade will attempt to resume at $LAST_SCRIPT"
+         else
+              CURRENT_RELEASE="${LAST_TO_VERSION}"
+              # greater than or equal to
+              compare="ge"
+              echo "Downgrade will attempt to resume before $LAST_SCRIPT"
+         fi
+    fi
 
     if [ ${CURRENT_RELEASE} \> ${TARGET_DOWNGRADE_RELEASE} ]; then
         downgradeSqls=$(ls -v -r "${DOWNGRADE_DIR}"/*/downgrade/*.sql 2> /dev/null)
@@ -441,12 +571,25 @@ function downgrade
             if [ "${schemaVersion}" -le "${CURRENT_RELEASE}" ] && \
                 [ "${schemaVersion}" -gt "${TARGET_DOWNGRADE_RELEASE}" ]; then
                 tag=${tagDate}"${schemaVersion}d"
-                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}
+                if [ $retry -eq 1 ] && \
+                    # Compare the numeric portion of the filename because shell doesn't support string comparison
+                    [ $(echo ${sqlName}| awk -F- '{print $1}') -${compare} $(echo ${LAST_SCRIPT}| awk -F- '{print $1}') ]; then
+                     rc=1
+                else
+                     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
                 fi
             fi
         done