From e2ad7bfa29d60b725b45917397a61a74453a1b97 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Thu, 19 Oct 2017 14:28:44 +0200 Subject: SONAR-9880 Fix missing migrations --- ...ulateAnalysisUuidColumnOnWebhookDeliveries.java | 56 ---------------------- ...askUuidColumnToNullableOnWebhookDeliveries.java | 47 ------------------ .../db/migration/version/v67/DbVersion67.java | 2 + ...ulateAnalysisUuidColumnOnWebhookDeliveries.java | 56 ++++++++++++++++++++++ ...askUuidColumnToNullableOnWebhookDeliveries.java | 47 ++++++++++++++++++ 5 files changed, 105 insertions(+), 103 deletions(-) delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/PopulateAnalysisUuidColumnOnWebhookDeliveries.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/UpdateCeTaskUuidColumnToNullableOnWebhookDeliveries.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/PopulateAnalysisUuidColumnOnWebhookDeliveries.java create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/UpdateCeTaskUuidColumnToNullableOnWebhookDeliveries.java (limited to 'server/sonar-db-migration/src/main/java/org/sonar') diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/PopulateAnalysisUuidColumnOnWebhookDeliveries.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/PopulateAnalysisUuidColumnOnWebhookDeliveries.java deleted file mode 100644 index 05b4bd7f1bf..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/PopulateAnalysisUuidColumnOnWebhookDeliveries.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.platform.db.migration.version.v66; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.DataChange; -import org.sonar.server.platform.db.migration.step.MassUpdate; -import org.sonar.server.platform.db.migration.step.Select; -import org.sonar.server.platform.db.migration.step.SqlStatement; - -public class PopulateAnalysisUuidColumnOnWebhookDeliveries extends DataChange { - - public PopulateAnalysisUuidColumnOnWebhookDeliveries(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("SELECT wd.uuid, ca.analysis_uuid " + - " FROM webhook_deliveries wd " + - " INNER JOIN ce_activity ca ON ca.uuid=wd.ce_task_uuid " + - " WHERE wd.analysis_uuid IS NULL AND ca.analysis_uuid IS NOT NULL"); - massUpdate.update("UPDATE webhook_deliveries SET analysis_uuid=? WHERE uuid=?"); - massUpdate.rowPluralName("webhook_deliveries"); - massUpdate.execute(PopulateAnalysisUuidColumnOnWebhookDeliveries::handle); - } - - private static boolean handle(Select.Row row, SqlStatement update) throws SQLException { - String uuid = row.getString(1); - String analysisUuid = row.getString(2); - - update.setString(1, analysisUuid); - update.setString(2, uuid); - - return true; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/UpdateCeTaskUuidColumnToNullableOnWebhookDeliveries.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/UpdateCeTaskUuidColumnToNullableOnWebhookDeliveries.java deleted file mode 100644 index 236b3cb61be..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/UpdateCeTaskUuidColumnToNullableOnWebhookDeliveries.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonar.server.platform.db.migration.version.v66; - -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.def.VarcharColumnDef; -import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -public class UpdateCeTaskUuidColumnToNullableOnWebhookDeliveries extends DdlChange { - - public static final String TABLE_WEBHOOK_DELIVERIES = "webhook_deliveries"; - - public UpdateCeTaskUuidColumnToNullableOnWebhookDeliveries(Database db) { - super(db); - } - - @Override - public void execute(Context context) throws SQLException { - context.execute(new AlterColumnsBuilder(getDialect(), TABLE_WEBHOOK_DELIVERIES) - .updateColumn(VarcharColumnDef.newVarcharColumnDefBuilder() - .setColumnName("ce_task_uuid") - .setLimit(40) - .setIsNullable(true) - .build()) - .build()); - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/DbVersion67.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/DbVersion67.java index 0a367054e18..c6eddef0eda 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/DbVersion67.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/DbVersion67.java @@ -30,6 +30,8 @@ public class DbVersion67 implements DbVersion { .add(1831, "Add webhook_deliveries.analysis_uuid", AddAnalysisUuidToWebhookDeliveries.class) .add(1832, "Create table ANALYSIS_PROPERTIES", CreateTableAnalysisProperties.class) .add(1833, "Cleanup disabled users", CleanupDisabledUsers.class) + .add(1834, "Set WEBHOOK_DELIVERIES.CE_TASK_UUID as nullable", UpdateCeTaskUuidColumnToNullableOnWebhookDeliveries.class) + .add(1835, "Populate WEBHOOK_DELIVERIES.ANALYSIS_UUID", PopulateAnalysisUuidColumnOnWebhookDeliveries.class) ; } } diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/PopulateAnalysisUuidColumnOnWebhookDeliveries.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/PopulateAnalysisUuidColumnOnWebhookDeliveries.java new file mode 100644 index 00000000000..7e7881cf220 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/PopulateAnalysisUuidColumnOnWebhookDeliveries.java @@ -0,0 +1,56 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version.v67; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; +import org.sonar.server.platform.db.migration.step.Select; +import org.sonar.server.platform.db.migration.step.SqlStatement; + +public class PopulateAnalysisUuidColumnOnWebhookDeliveries extends DataChange { + + public PopulateAnalysisUuidColumnOnWebhookDeliveries(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + massUpdate.select("SELECT wd.uuid, ca.analysis_uuid " + + " FROM webhook_deliveries wd " + + " INNER JOIN ce_activity ca ON ca.uuid=wd.ce_task_uuid " + + " WHERE wd.analysis_uuid IS NULL AND ca.analysis_uuid IS NOT NULL"); + massUpdate.update("UPDATE webhook_deliveries SET analysis_uuid=? WHERE uuid=?"); + massUpdate.rowPluralName("webhook_deliveries"); + massUpdate.execute(PopulateAnalysisUuidColumnOnWebhookDeliveries::handle); + } + + private static boolean handle(Select.Row row, SqlStatement update) throws SQLException { + String uuid = row.getString(1); + String analysisUuid = row.getString(2); + + update.setString(1, analysisUuid); + update.setString(2, uuid); + + return true; + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/UpdateCeTaskUuidColumnToNullableOnWebhookDeliveries.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/UpdateCeTaskUuidColumnToNullableOnWebhookDeliveries.java new file mode 100644 index 00000000000..a53ffdc8195 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/UpdateCeTaskUuidColumnToNullableOnWebhookDeliveries.java @@ -0,0 +1,47 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.sonar.server.platform.db.migration.version.v67; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class UpdateCeTaskUuidColumnToNullableOnWebhookDeliveries extends DdlChange { + + public static final String TABLE_WEBHOOK_DELIVERIES = "webhook_deliveries"; + + public UpdateCeTaskUuidColumnToNullableOnWebhookDeliveries(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AlterColumnsBuilder(getDialect(), TABLE_WEBHOOK_DELIVERIES) + .updateColumn(VarcharColumnDef.newVarcharColumnDefBuilder() + .setColumnName("ce_task_uuid") + .setLimit(40) + .setIsNullable(true) + .build()) + .build()); + } +} -- cgit v1.2.3