Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe Commits: bf41e7c3 by Tony Chemit at 2023-11-13T11:09:58+01:00 Erreur de migration sur bases AZTI locales - Closes #2800 - - - - - 4 changed files: - core/persistence/migration/src/main/java/fr/ird/observe/spi/migration/v9/DataSourceMigrationForVersion_9_1.java - + core/persistence/migration/src/main/resources/db/migration/v9/9.1/10_2_add_referential_common_Country_22-common.sql - + core/persistence/migration/src/main/resources/db/migration/v9/9.1/10_2_add_referential_common_Country_72-common.sql - + core/persistence/migration/src/main/resources/db/migration/v9/9.1/10_2_add_referential_common_Country_finalize-common.sql Changes: ===================================== core/persistence/migration/src/main/java/fr/ird/observe/spi/migration/v9/DataSourceMigrationForVersion_9_1.java ===================================== @@ -302,6 +302,10 @@ public class DataSourceMigrationForVersion_9_1 extends ByMajorMigrationVersionRe executor.addScript("09", "adapt_table-common_vessel-add-fields"); // See https://gitlab.com/ultreiaio/ird-observe/-/issues/2646 executor.addScript("10", "adapt_table-common_vessel-rename-field"); + if (withIds) { + // See https://gitlab.com/ultreiaio/ird-observe/-/issues/2800 + addCountries(executor); + } // See https://gitlab.com/ultreiaio/ird-observe/-/issues/2659 executor.addScript("11", "adapt_table-common_fpazone-add-fields"); if (withIds) { @@ -367,6 +371,22 @@ public class DataSourceMigrationForVersion_9_1 extends ByMajorMigrationVersionRe } } + private void addCountries(MigrationVersionResourceExecutor executor) { + Set<String> existingCodes = executor.findMultipleResultAstSet(SqlQuery.wrap("SELECT topiaId FROM common.Country", resultSet -> resultSet.getString(1))); + Set<String> newCodes = new LinkedHashSet<>(); + if (!existingCodes.contains("fr.ird.referential.common.Country#1239832675593#0.24921769452411147")) { + executor.addScript("10_2", "add_referential_common_Country_22"); + newCodes.add("22"); + } + if (!existingCodes.contains("fr.ird.referential.common.Country#1464000000000#0.00072")) { + executor.addScript("10_2", "add_referential_common_Country_72"); + newCodes.add("72"); + } + if (!newCodes.isEmpty()) { + executor.addScript("10_2", "add_referential_common_Country_finalize"); + } + } + private Map<String, List<WellPlanStructure>> splitByTrip(List<WellPlanStructure> existingWellPlan) { String tripId = null; List<WellPlanStructure> forTrip = null; ===================================== core/persistence/migration/src/main/resources/db/migration/v9/9.1/10_2_add_referential_common_Country_22-common.sql ===================================== @@ -0,0 +1,22 @@ +--- +-- #%L +-- ObServe Core :: Persistence :: Migration +-- %% +-- Copyright (C) 2008 - 2023 IRD, Ultreia.io +-- %% +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as +-- published by the Free Software Foundation, either version 3 of the +-- License, or (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public +-- License along with this program. If not, see +-- <http://www.gnu.org/licenses/gpl-3.0.html>. +-- #L% +--- +INSERT INTO common.country (topiaid, topiaversion, topiacreatedate, lastupdatedate, code, uri, homeid, needcomment, status, label1, label2, label3, label4, label5, label6, label7, label8, iso2code, iso3code) VALUES ('fr.ird.referential.common.Country#1239832675593#0.24921769452411147', 22, '2009-04-15 00:00:00.014000', '2020-03-06 16:01:25.630000', '22', null, null, false, 1, 'Mauritius', 'Maurice', 'Mauricio', null, null, null, null, null, 'MU', 'MUS'); \ No newline at end of file ===================================== core/persistence/migration/src/main/resources/db/migration/v9/9.1/10_2_add_referential_common_Country_72-common.sql ===================================== @@ -0,0 +1,22 @@ +--- +-- #%L +-- ObServe Core :: Persistence :: Migration +-- %% +-- Copyright (C) 2008 - 2023 IRD, Ultreia.io +-- %% +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as +-- published by the Free Software Foundation, either version 3 of the +-- License, or (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public +-- License along with this program. If not, see +-- <http://www.gnu.org/licenses/gpl-3.0.html>. +-- #L% +--- +INSERT INTO common.country (topiaid, topiaversion, topiacreatedate, lastupdatedate, code, uri, homeid, needcomment, status, label1, label2, label3, label4, label5, label6, label7, label8, iso2code, iso3code) VALUES ('fr.ird.referential.common.Country#1464000000000#0.00072', 3, '2018-06-13 18:31:03.000000', '2020-03-06 16:21:07.403000', '72', null, null, false, 1, 'Namibia', 'Namibie', 'Namibia', null, null, null, null, null, 'NA', 'NAM'); \ No newline at end of file ===================================== core/persistence/migration/src/main/resources/db/migration/v9/9.1/10_2_add_referential_common_Country_finalize-common.sql ===================================== @@ -0,0 +1,22 @@ +--- +-- #%L +-- ObServe Core :: Persistence :: Migration +-- %% +-- Copyright (C) 2008 - 2023 IRD, Ultreia.io +-- %% +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as +-- published by the Free Software Foundation, either version 3 of the +-- License, or (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public +-- License along with this program. If not, see +-- <http://www.gnu.org/licenses/gpl-3.0.html>. +-- #L% +--- +UPDATE common.LastUpdateDate SET lastUpdateDate = ${CURRENT_TIMESTAMP} WHERE type ='fr.ird.observe.entities.referential.common.Country'; View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/commit/bf41e7c3772e26fcdd2184dae2... -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/commit/bf41e7c3772e26fcdd2184dae2... You're receiving this email because of your account on gitlab.com.