From: FrancescoFioraEst Date: Tue, 4 Jun 2024 13:53:23 +0000 (+0100) Subject: Add a new replica table in clampacm database in db migrator X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=HEAD;p=policy%2Fdocker.git Add a new replica table in clampacm database in db migrator Issue-ID: POLICY-5033 Change-Id: Ifaf43686c9784a211806058433ecb69f0d7e1ca9 Signed-off-by: FrancescoFioraEst --- diff --git a/policy-db-migrator/src/main/docker/config/clampacm/postgres/1500/downgrade/0300-participantreplica.sql b/policy-db-migrator/src/main/docker/config/clampacm/postgres/1500/downgrade/0300-participantreplica.sql new file mode 100644 index 00000000..d5f7871b --- /dev/null +++ b/policy-db-migrator/src/main/docker/config/clampacm/postgres/1500/downgrade/0300-participantreplica.sql @@ -0,0 +1,20 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2024 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========================================================= + */ + +DROP TABLE participantreplica; diff --git a/policy-db-migrator/src/main/docker/config/clampacm/postgres/1500/downgrade/0300-participant.sql b/policy-db-migrator/src/main/docker/config/clampacm/postgres/1500/downgrade/0400-participant.sql similarity index 100% rename from policy-db-migrator/src/main/docker/config/clampacm/postgres/1500/downgrade/0300-participant.sql rename to policy-db-migrator/src/main/docker/config/clampacm/postgres/1500/downgrade/0400-participant.sql diff --git a/policy-db-migrator/src/main/docker/config/clampacm/postgres/1500/downgrade/0500-participant_replica_fk_index.sql b/policy-db-migrator/src/main/docker/config/clampacm/postgres/1500/downgrade/0500-participant_replica_fk_index.sql new file mode 100644 index 00000000..ab9012c5 --- /dev/null +++ b/policy-db-migrator/src/main/docker/config/clampacm/postgres/1500/downgrade/0500-participant_replica_fk_index.sql @@ -0,0 +1,20 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2024 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========================================================= + */ + +DROP INDEX IF EXISTS participant_replica_fk; diff --git a/policy-db-migrator/src/main/docker/config/clampacm/postgres/1500/downgrade/0600-participant_replica_fk.sql b/policy-db-migrator/src/main/docker/config/clampacm/postgres/1500/downgrade/0600-participant_replica_fk.sql new file mode 100644 index 00000000..36709b10 --- /dev/null +++ b/policy-db-migrator/src/main/docker/config/clampacm/postgres/1500/downgrade/0600-participant_replica_fk.sql @@ -0,0 +1,20 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2024 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 participantreplica DROP CONSTRAINT IF EXISTS participant_replica_fk; diff --git a/policy-db-migrator/src/main/docker/config/clampacm/postgres/1500/upgrade/0300-participantreplica.sql b/policy-db-migrator/src/main/docker/config/clampacm/postgres/1500/upgrade/0300-participantreplica.sql new file mode 100644 index 00000000..4543272b --- /dev/null +++ b/policy-db-migrator/src/main/docker/config/clampacm/postgres/1500/upgrade/0300-participantreplica.sql @@ -0,0 +1,20 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2024 Nordix Foundation + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +CREATE TABLE participantreplica (replicaId varchar(255) NOT NULL, lastMsg timestamp without time zone DEFAULT Now(), participantId varchar(255) DEFAULT NULL, participantState SMALLINT DEFAULT NULL, CONSTRAINT PK_PARTICIPANT_REPLICA PRIMARY KEY (replicaId)); diff --git a/policy-db-migrator/src/main/docker/config/clampacm/postgres/1500/upgrade/0300-participant.sql b/policy-db-migrator/src/main/docker/config/clampacm/postgres/1500/upgrade/0400-participant.sql similarity index 100% rename from policy-db-migrator/src/main/docker/config/clampacm/postgres/1500/upgrade/0300-participant.sql rename to policy-db-migrator/src/main/docker/config/clampacm/postgres/1500/upgrade/0400-participant.sql diff --git a/policy-db-migrator/src/main/docker/config/clampacm/postgres/1500/upgrade/0500-participant_replica_fk_index.sql b/policy-db-migrator/src/main/docker/config/clampacm/postgres/1500/upgrade/0500-participant_replica_fk_index.sql new file mode 100644 index 00000000..bc506e99 --- /dev/null +++ b/policy-db-migrator/src/main/docker/config/clampacm/postgres/1500/upgrade/0500-participant_replica_fk_index.sql @@ -0,0 +1,20 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2024 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 participant_replica_fk ON participantreplica(participantId); diff --git a/policy-db-migrator/src/main/docker/config/clampacm/postgres/1500/upgrade/0600-participant_replica_fk.sql b/policy-db-migrator/src/main/docker/config/clampacm/postgres/1500/upgrade/0600-participant_replica_fk.sql new file mode 100644 index 00000000..3341d8e0 --- /dev/null +++ b/policy-db-migrator/src/main/docker/config/clampacm/postgres/1500/upgrade/0600-participant_replica_fk.sql @@ -0,0 +1,20 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2024 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 participantreplica ADD CONSTRAINT participant_replica_fk FOREIGN KEY (participantId) REFERENCES participant (participantId) ON UPDATE RESTRICT ON DELETE RESTRICT; diff --git a/policy-db-migrator/src/main/docker/config/clampacm/sql/1500/downgrade/0300-participantreplica.sql b/policy-db-migrator/src/main/docker/config/clampacm/sql/1500/downgrade/0300-participantreplica.sql new file mode 100644 index 00000000..d5f7871b --- /dev/null +++ b/policy-db-migrator/src/main/docker/config/clampacm/sql/1500/downgrade/0300-participantreplica.sql @@ -0,0 +1,20 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2024 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========================================================= + */ + +DROP TABLE participantreplica; diff --git a/policy-db-migrator/src/main/docker/config/clampacm/sql/1500/downgrade/0300-participant.sql b/policy-db-migrator/src/main/docker/config/clampacm/sql/1500/downgrade/0400-participant.sql similarity index 100% rename from policy-db-migrator/src/main/docker/config/clampacm/sql/1500/downgrade/0300-participant.sql rename to policy-db-migrator/src/main/docker/config/clampacm/sql/1500/downgrade/0400-participant.sql diff --git a/policy-db-migrator/src/main/docker/config/clampacm/sql/1500/downgrade/0500-participant_replica_fk_index.sql b/policy-db-migrator/src/main/docker/config/clampacm/sql/1500/downgrade/0500-participant_replica_fk_index.sql new file mode 100644 index 00000000..61a5454c --- /dev/null +++ b/policy-db-migrator/src/main/docker/config/clampacm/sql/1500/downgrade/0500-participant_replica_fk_index.sql @@ -0,0 +1,20 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2024 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========================================================= + */ + +DROP INDEX participant_replica_fk ON participantreplica; diff --git a/policy-db-migrator/src/main/docker/config/clampacm/sql/1500/downgrade/0600-participant_replica_fk.sql b/policy-db-migrator/src/main/docker/config/clampacm/sql/1500/downgrade/0600-participant_replica_fk.sql new file mode 100644 index 00000000..6c5f30ee --- /dev/null +++ b/policy-db-migrator/src/main/docker/config/clampacm/sql/1500/downgrade/0600-participant_replica_fk.sql @@ -0,0 +1,20 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2024 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 participantreplica DROP FOREIGN KEY participant_replica_fk; diff --git a/policy-db-migrator/src/main/docker/config/clampacm/sql/1500/upgrade/0300-participantreplica.sql b/policy-db-migrator/src/main/docker/config/clampacm/sql/1500/upgrade/0300-participantreplica.sql new file mode 100644 index 00000000..cb5969d5 --- /dev/null +++ b/policy-db-migrator/src/main/docker/config/clampacm/sql/1500/upgrade/0300-participantreplica.sql @@ -0,0 +1,20 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2024 Nordix Foundation + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +CREATE TABLE participantreplica (replicaId varchar(255) NOT NULL, lastMsg datetime(6) DEFAULT NULL, participantId varchar(255) DEFAULT NULL, participantState int(11) DEFAULT NULL, CONSTRAINT PK_PARTICIPANT_REPLICA PRIMARY KEY (replicaId)); diff --git a/policy-db-migrator/src/main/docker/config/clampacm/sql/1500/upgrade/0300-participant.sql b/policy-db-migrator/src/main/docker/config/clampacm/sql/1500/upgrade/0400-participant.sql similarity index 100% rename from policy-db-migrator/src/main/docker/config/clampacm/sql/1500/upgrade/0300-participant.sql rename to policy-db-migrator/src/main/docker/config/clampacm/sql/1500/upgrade/0400-participant.sql diff --git a/policy-db-migrator/src/main/docker/config/clampacm/sql/1500/upgrade/0500-participant_replica_fk_index.sql b/policy-db-migrator/src/main/docker/config/clampacm/sql/1500/upgrade/0500-participant_replica_fk_index.sql new file mode 100644 index 00000000..bc506e99 --- /dev/null +++ b/policy-db-migrator/src/main/docker/config/clampacm/sql/1500/upgrade/0500-participant_replica_fk_index.sql @@ -0,0 +1,20 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2024 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 participant_replica_fk ON participantreplica(participantId); diff --git a/policy-db-migrator/src/main/docker/config/clampacm/sql/1500/upgrade/0600-participant_replica_fk.sql b/policy-db-migrator/src/main/docker/config/clampacm/sql/1500/upgrade/0600-participant_replica_fk.sql new file mode 100644 index 00000000..3341d8e0 --- /dev/null +++ b/policy-db-migrator/src/main/docker/config/clampacm/sql/1500/upgrade/0600-participant_replica_fk.sql @@ -0,0 +1,20 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2024 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 participantreplica ADD CONSTRAINT participant_replica_fk FOREIGN KEY (participantId) REFERENCES participant (participantId) ON UPDATE RESTRICT ON DELETE RESTRICT;