From 1e928ccfb7573a135a6fed4bd3309b8ca520a693 Mon Sep 17 00:00:00 2001 From: waynedunican Date: Fri, 4 Feb 2022 08:36:13 +0000 Subject: Add upgrade/downgrade scripts for postgres in db-migrator - Jakarta upgrade scripts - Jakarta downgrade scripts Issue-ID: POLICY-2715 Change-Id: I1dbe902644ce392ef0823022a256cf37cc499a3e Signed-off-by: Wayne Dunican --- .../1000/downgrade/0100-jpatoscapolicy_targets.sql | 20 ++++++++++++++++++++ .../downgrade/0110-jpatoscapolicytype_targets.sql | 20 ++++++++++++++++++++ .../postgres/1000/downgrade/0120-toscatrigger.sql | 20 ++++++++++++++++++++ .../downgrade/0130-jpatoscapolicytype_triggers.sql | 20 ++++++++++++++++++++ .../1000/downgrade/0140-toscaparameter.sql | 20 ++++++++++++++++++++ .../postgres/1000/downgrade/0150-toscaproperty.sql | 22 ++++++++++++++++++++++ .../1000/upgrade/0100-jpatoscapolicy_targets.sql | 20 ++++++++++++++++++++ .../upgrade/0110-jpatoscapolicytype_targets.sql | 20 ++++++++++++++++++++ .../postgres/1000/upgrade/0120-toscatrigger.sql | 20 ++++++++++++++++++++ .../upgrade/0130-jpatoscapolicytype_triggers.sql | 20 ++++++++++++++++++++ .../postgres/1000/upgrade/0140-toscaparameter.sql | 20 ++++++++++++++++++++ .../postgres/1000/upgrade/0150-toscaproperty.sql | 22 ++++++++++++++++++++++ 12 files changed, 244 insertions(+) create mode 100644 policy-db-migrator/src/main/docker/config/policyadmin/postgres/1000/downgrade/0100-jpatoscapolicy_targets.sql create mode 100644 policy-db-migrator/src/main/docker/config/policyadmin/postgres/1000/downgrade/0110-jpatoscapolicytype_targets.sql create mode 100644 policy-db-migrator/src/main/docker/config/policyadmin/postgres/1000/downgrade/0120-toscatrigger.sql create mode 100644 policy-db-migrator/src/main/docker/config/policyadmin/postgres/1000/downgrade/0130-jpatoscapolicytype_triggers.sql create mode 100644 policy-db-migrator/src/main/docker/config/policyadmin/postgres/1000/downgrade/0140-toscaparameter.sql create mode 100644 policy-db-migrator/src/main/docker/config/policyadmin/postgres/1000/downgrade/0150-toscaproperty.sql create mode 100644 policy-db-migrator/src/main/docker/config/policyadmin/postgres/1000/upgrade/0100-jpatoscapolicy_targets.sql create mode 100644 policy-db-migrator/src/main/docker/config/policyadmin/postgres/1000/upgrade/0110-jpatoscapolicytype_targets.sql create mode 100644 policy-db-migrator/src/main/docker/config/policyadmin/postgres/1000/upgrade/0120-toscatrigger.sql create mode 100644 policy-db-migrator/src/main/docker/config/policyadmin/postgres/1000/upgrade/0130-jpatoscapolicytype_triggers.sql create mode 100644 policy-db-migrator/src/main/docker/config/policyadmin/postgres/1000/upgrade/0140-toscaparameter.sql create mode 100644 policy-db-migrator/src/main/docker/config/policyadmin/postgres/1000/upgrade/0150-toscaproperty.sql diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/postgres/1000/downgrade/0100-jpatoscapolicy_targets.sql b/policy-db-migrator/src/main/docker/config/policyadmin/postgres/1000/downgrade/0100-jpatoscapolicy_targets.sql new file mode 100644 index 00000000..49172830 --- /dev/null +++ b/policy-db-migrator/src/main/docker/config/policyadmin/postgres/1000/downgrade/0100-jpatoscapolicy_targets.sql @@ -0,0 +1,20 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2022 Nordix Foundation. All rights reserved. + * ================================================================================ + * 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 jpatoscapolicy_targets DROP COLUMN toscaPolicyName, DROP COLUMN toscaPolicyVersion; diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/postgres/1000/downgrade/0110-jpatoscapolicytype_targets.sql b/policy-db-migrator/src/main/docker/config/policyadmin/postgres/1000/downgrade/0110-jpatoscapolicytype_targets.sql new file mode 100644 index 00000000..09b49bb2 --- /dev/null +++ b/policy-db-migrator/src/main/docker/config/policyadmin/postgres/1000/downgrade/0110-jpatoscapolicytype_targets.sql @@ -0,0 +1,20 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2022 Nordix Foundation. All rights reserved. + * ================================================================================ + * 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 jpatoscapolicytype_targets DROP COLUMN toscaPolicyTypeName, DROP COLUMN toscaPolicyTypeVersion; diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/postgres/1000/downgrade/0120-toscatrigger.sql b/policy-db-migrator/src/main/docker/config/policyadmin/postgres/1000/downgrade/0120-toscatrigger.sql new file mode 100644 index 00000000..b1764ea0 --- /dev/null +++ b/policy-db-migrator/src/main/docker/config/policyadmin/postgres/1000/downgrade/0120-toscatrigger.sql @@ -0,0 +1,20 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2022 Nordix Foundation. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +CREATE TABLE IF NOT EXISTS toscatrigger (ACTION VARCHAR(255) NULL, toscaCondition BYTEA DEFAULT NULL NULL, toscaConstraint BYTEA DEFAULT NULL NULL, DESCRIPTION VARCHAR(255) NULL, EVALUATIONS INT DEFAULT NULL NULL, EVENTTYPE VARCHAR(255) NULL, METHOD VARCHAR(255) NULL, PERIOD BYTEA DEFAULT NULL NULL, SCHEDULE BYTEA DEFAULT NULL NULL, TARGETFILTER BYTEA DEFAULT NULL NULL, parentLocalName VARCHAR(120) NOT NULL, localName VARCHAR(120) NOT NULL, parentKeyVersion VARCHAR(15) NOT NULL, parentKeyName VARCHAR(120) NOT NULL, CONSTRAINT PK_TOSCATRIGGER PRIMARY KEY (parentLocalName, localName, parentKeyVersion, parentKeyName)); diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/postgres/1000/downgrade/0130-jpatoscapolicytype_triggers.sql b/policy-db-migrator/src/main/docker/config/policyadmin/postgres/1000/downgrade/0130-jpatoscapolicytype_triggers.sql new file mode 100644 index 00000000..16207f26 --- /dev/null +++ b/policy-db-migrator/src/main/docker/config/policyadmin/postgres/1000/downgrade/0130-jpatoscapolicytype_triggers.sql @@ -0,0 +1,20 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2022 Nordix Foundation. All rights reserved. + * ================================================================================ + * 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 jpatoscapolicytype_triggers ALTER COLUMN triggers TYPE VARCHAR(255); diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/postgres/1000/downgrade/0140-toscaparameter.sql b/policy-db-migrator/src/main/docker/config/policyadmin/postgres/1000/downgrade/0140-toscaparameter.sql new file mode 100644 index 00000000..7ab89c19 --- /dev/null +++ b/policy-db-migrator/src/main/docker/config/policyadmin/postgres/1000/downgrade/0140-toscaparameter.sql @@ -0,0 +1,20 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2022 Nordix Foundation. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +CREATE TABLE IF NOT EXISTS toscaparameter (VALUE VARCHAR(255) NULL, parentLocalName VARCHAR(120) NOT NULL, localName VARCHAR(120) NOT NULL, parentKeyVersion VARCHAR(15) NOT NULL, parentKeyName VARCHAR(120) NOT NULL, name VARCHAR(120) NULL, version VARCHAR(20) NULL, CONSTRAINT PK_TOSCAPARAMETER PRIMARY KEY (parentLocalName, localName, parentKeyVersion, parentKeyName)); diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/postgres/1000/downgrade/0150-toscaproperty.sql b/policy-db-migrator/src/main/docker/config/policyadmin/postgres/1000/downgrade/0150-toscaproperty.sql new file mode 100644 index 00000000..e1abf28f --- /dev/null +++ b/policy-db-migrator/src/main/docker/config/policyadmin/postgres/1000/downgrade/0150-toscaproperty.sql @@ -0,0 +1,22 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2022 Nordix Foundation. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +CREATE TABLE IF NOT EXISTS jpatoscaproperty_constraints (parentLocalName VARCHAR(120) NULL, localName VARCHAR(120) NULL, parentKeyVersion VARCHAR(15) NULL, parentKeyName VARCHAR(120) NULL, CONSTRAINTS VARCHAR(255) NULL); +CREATE TABLE IF NOT EXISTS jpatoscaproperty_metadata (parentLocalName VARCHAR(120) NULL, localName VARCHAR(120) NULL, parentKeyVersion VARCHAR(15) NULL, parentKeyName VARCHAR(120) NULL, METADATA VARCHAR(255) NULL, METADATA_KEY VARCHAR(255) NULL); +CREATE TABLE IF NOT EXISTS toscaproperty (DEFAULTVALUE VARCHAR(255) NULL, DESCRIPTION VARCHAR(255) NULL, ENTRYSCHEMA BYTEA DEFAULT NULL NULL, REQUIRED BIT DEFAULT 0 NULL, STATUS INT DEFAULT NULL NULL, parentLocalName VARCHAR(120) NOT NULL, localName VARCHAR(120) NOT NULL, parentKeyVersion VARCHAR(15) NOT NULL, parentKeyName VARCHAR(120) NOT NULL, name VARCHAR(120) NULL, version VARCHAR(20) NULL, CONSTRAINT PK_TOSCAPROPERTY PRIMARY KEY (parentLocalName, localName, parentKeyVersion, parentKeyName)); diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/postgres/1000/upgrade/0100-jpatoscapolicy_targets.sql b/policy-db-migrator/src/main/docker/config/policyadmin/postgres/1000/upgrade/0100-jpatoscapolicy_targets.sql new file mode 100644 index 00000000..5a338d6f --- /dev/null +++ b/policy-db-migrator/src/main/docker/config/policyadmin/postgres/1000/upgrade/0100-jpatoscapolicy_targets.sql @@ -0,0 +1,20 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2022 Nordix Foundation. All rights reserved. + * ================================================================================ + * 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 jpatoscapolicy_targets ADD COLUMN toscaPolicyName VARCHAR(120) NOT NULL, ADD COLUMN toscaPolicyVersion VARCHAR(20) NOT NULL, ADD CONSTRAINT PK_JPATOSCAPOLICY_TARGETS PRIMARY KEY (toscaPolicyName, toscaPolicyVersion); diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/postgres/1000/upgrade/0110-jpatoscapolicytype_targets.sql b/policy-db-migrator/src/main/docker/config/policyadmin/postgres/1000/upgrade/0110-jpatoscapolicytype_targets.sql new file mode 100644 index 00000000..6ded7259 --- /dev/null +++ b/policy-db-migrator/src/main/docker/config/policyadmin/postgres/1000/upgrade/0110-jpatoscapolicytype_targets.sql @@ -0,0 +1,20 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2022 Nordix Foundation. All rights reserved. + * ================================================================================ + * 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 jpatoscapolicytype_targets ADD COLUMN toscaPolicyTypeName VARCHAR(120) NOT NULL, ADD COLUMN toscaPolicyTypeVersion VARCHAR(20) NOT NULL, ADD CONSTRAINT PK_JPATOSCAPOLICYTYPE_TARGETS PRIMARY KEY (toscaPolicyTypeName, toscaPolicyTypeVersion); diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/postgres/1000/upgrade/0120-toscatrigger.sql b/policy-db-migrator/src/main/docker/config/policyadmin/postgres/1000/upgrade/0120-toscatrigger.sql new file mode 100644 index 00000000..6fc5e99b --- /dev/null +++ b/policy-db-migrator/src/main/docker/config/policyadmin/postgres/1000/upgrade/0120-toscatrigger.sql @@ -0,0 +1,20 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2022 Nordix Foundation. All rights reserved. + * ================================================================================ + * 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========================================================= + */ + +DROP TABLE IF EXISTS toscatrigger; diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/postgres/1000/upgrade/0130-jpatoscapolicytype_triggers.sql b/policy-db-migrator/src/main/docker/config/policyadmin/postgres/1000/upgrade/0130-jpatoscapolicytype_triggers.sql new file mode 100644 index 00000000..a8d4a552 --- /dev/null +++ b/policy-db-migrator/src/main/docker/config/policyadmin/postgres/1000/upgrade/0130-jpatoscapolicytype_triggers.sql @@ -0,0 +1,20 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2022 Nordix Foundation. All rights reserved. + * ================================================================================ + * 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 jpatoscapolicytype_triggers ALTER COLUMN triggers TYPE BYTEA USING triggers::bytea; diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/postgres/1000/upgrade/0140-toscaparameter.sql b/policy-db-migrator/src/main/docker/config/policyadmin/postgres/1000/upgrade/0140-toscaparameter.sql new file mode 100644 index 00000000..ac03efb4 --- /dev/null +++ b/policy-db-migrator/src/main/docker/config/policyadmin/postgres/1000/upgrade/0140-toscaparameter.sql @@ -0,0 +1,20 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2022 Nordix Foundation. All rights reserved. + * ================================================================================ + * 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========================================================= + */ + +DROP TABLE IF EXISTS toscaparameter; diff --git a/policy-db-migrator/src/main/docker/config/policyadmin/postgres/1000/upgrade/0150-toscaproperty.sql b/policy-db-migrator/src/main/docker/config/policyadmin/postgres/1000/upgrade/0150-toscaproperty.sql new file mode 100644 index 00000000..c482243a --- /dev/null +++ b/policy-db-migrator/src/main/docker/config/policyadmin/postgres/1000/upgrade/0150-toscaproperty.sql @@ -0,0 +1,22 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2022 Nordix Foundation. All rights reserved. + * ================================================================================ + * 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========================================================= + */ + +DROP TABLE IF EXISTS jpatoscaproperty_constraints; +DROP TABLE IF EXISTS jpatoscaproperty_metadata; +DROP TABLE IF EXISTS toscaproperty; -- cgit 1.2.3-korg