diff options
author | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2016-12-14 11:41:42 +0100 |
---|---|---|
committer | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2016-12-14 12:11:53 +0100 |
commit | fcd81766036e4ec7a7ebedaf0bb96e1e59904ee8 (patch) | |
tree | 7e6a4e63f4153eba0183aff0aeef1d0417f17dad /server | |
parent | 4ff133235967c094e486f472c06ac2b625fbca90 (diff) | |
download | sonarqube-fcd81766036e4ec7a7ebedaf0bb96e1e59904ee8.tar.gz sonarqube-fcd81766036e4ec7a7ebedaf0bb96e1e59904ee8.zip |
SONAR-8445 move SQ 6.0 migrations out of Ruby
Diffstat (limited to 'server')
270 files changed, 12247 insertions, 2208 deletions
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/DbVersionModule.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/DbVersionModule.java index cf081cb5a4b..cde9590db53 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/DbVersionModule.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/DbVersionModule.java @@ -20,6 +20,7 @@ package org.sonar.server.platform.db.migration.version; import org.sonar.core.platform.Module; +import org.sonar.server.platform.db.migration.version.v60.DbVersion60; import org.sonar.server.platform.db.migration.version.v61.DbVersion61; import org.sonar.server.platform.db.migration.version.v62.DbVersion62; import org.sonar.server.platform.db.migration.version.v63.DbVersion63; @@ -28,6 +29,7 @@ public class DbVersionModule extends Module { @Override protected void configureModule() { add( + DbVersion60.class, DbVersion61.class, DbVersion62.class, DbVersion63.class); diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToCeActivity.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToCeActivity.java new file mode 100644 index 00000000000..c2c0f5f106c --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToCeActivity.java @@ -0,0 +1,45 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.AddColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.db.version.VarcharColumnDef.UUID_VARCHAR_SIZE; +import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddAnalysisUuidColumnToCeActivity extends DdlChange { + + private static final String TABLE_CE_ACTIVITY = "ce_activity"; + + public AddAnalysisUuidColumnToCeActivity(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddColumnsBuilder(getDatabase().getDialect(), TABLE_CE_ACTIVITY) + .addColumn(newVarcharColumnDefBuilder().setColumnName("analysis_uuid").setLimit(UUID_VARCHAR_SIZE).setIgnoreOracleUnit(true).build()) + .build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToEvents.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToEvents.java new file mode 100644 index 00000000000..997537af395 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToEvents.java @@ -0,0 +1,45 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.AddColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.db.version.VarcharColumnDef.UUID_VARCHAR_SIZE; +import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddAnalysisUuidColumnToEvents extends DdlChange { + + private static final String TABLE_EVENTS = "events"; + + public AddAnalysisUuidColumnToEvents(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddColumnsBuilder(getDatabase().getDialect(), TABLE_EVENTS) + .addColumn(newVarcharColumnDefBuilder().setColumnName("analysis_uuid").setLimit(UUID_VARCHAR_SIZE).setIgnoreOracleUnit(true).build()) + .build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToMeasures.java new file mode 100644 index 00000000000..ba46106db69 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToMeasures.java @@ -0,0 +1,45 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.AddColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.db.version.VarcharColumnDef.UUID_VARCHAR_SIZE; +import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddAnalysisUuidColumnToMeasures extends DdlChange { + + private static final String TABLE_MEASURES = "project_measures"; + + public AddAnalysisUuidColumnToMeasures(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddColumnsBuilder(getDatabase().getDialect(), TABLE_MEASURES) + .addColumn(newVarcharColumnDefBuilder().setColumnName("analysis_uuid").setLimit(UUID_VARCHAR_SIZE).setIgnoreOracleUnit(true).build()) + .build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddBColumnsToProjects.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddBColumnsToProjects.java new file mode 100644 index 00000000000..d732e1979fe --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddBColumnsToProjects.java @@ -0,0 +1,55 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.AddColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.db.version.BooleanColumnDef.newBooleanColumnDefBuilder; +import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddBColumnsToProjects extends DdlChange { + + private static final String TABLE_PROJECTS = "projects"; + + public AddBColumnsToProjects(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddColumnsBuilder(getDatabase().getDialect(), TABLE_PROJECTS) + .addColumn(newBooleanColumnDefBuilder().setColumnName("b_changed").build()) + .addColumn(newVarcharColumnDefBuilder().setColumnName("b_copy_component_uuid").setLimit(50).setIgnoreOracleUnit(true).build()) + .addColumn(newVarcharColumnDefBuilder().setColumnName("b_description").setLimit(2000).setIgnoreOracleUnit(true).build()) + .addColumn(newBooleanColumnDefBuilder().setColumnName("b_enabled").build()) + .addColumn(newVarcharColumnDefBuilder().setColumnName("b_language").setLimit(20).setIgnoreOracleUnit(true).build()) + .addColumn(newVarcharColumnDefBuilder().setColumnName("b_long_name").setLimit(500).setIgnoreOracleUnit(true).build()) + .addColumn(newVarcharColumnDefBuilder().setColumnName("b_module_uuid").setLimit(50).setIgnoreOracleUnit(true).build()) + .addColumn(newVarcharColumnDefBuilder().setColumnName("b_module_uuid_path").setLimit(1500).setIgnoreOracleUnit(true).build()) + .addColumn(newVarcharColumnDefBuilder().setColumnName("b_name").setLimit(500).setIgnoreOracleUnit(true).build()) + .addColumn(newVarcharColumnDefBuilder().setColumnName("b_path").setLimit(2000).setIgnoreOracleUnit(true).build()) + .addColumn(newVarcharColumnDefBuilder().setColumnName("b_qualifier").setLimit(10).setIgnoreOracleUnit(true).build()) + .build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndex.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndex.java new file mode 100644 index 00000000000..6b4cec7969a --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndex.java @@ -0,0 +1,46 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.AddColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.db.version.VarcharColumnDef.UUID_VARCHAR_SIZE; +import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndex extends DdlChange { + + private static final String TABLE_PUBLICATIONS_INDEX = "duplications_index"; + + public AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndex(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddColumnsBuilder(getDatabase().getDialect(), TABLE_PUBLICATIONS_INDEX) + .addColumn(newVarcharColumnDefBuilder().setColumnName("component_uuid").setLimit(UUID_VARCHAR_SIZE).setIgnoreOracleUnit(true).build()) + .addColumn(newVarcharColumnDefBuilder().setColumnName("analysis_uuid").setLimit(UUID_VARCHAR_SIZE).setIgnoreOracleUnit(true).build()) + .build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnToMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnToMeasures.java new file mode 100644 index 00000000000..50bce535743 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnToMeasures.java @@ -0,0 +1,45 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.AddColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.db.version.VarcharColumnDef.UUID_VARCHAR_SIZE; +import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddComponentUuidColumnToMeasures extends DdlChange { + + private static final String TABLE_MEASURES = "project_measures"; + + public AddComponentUuidColumnToMeasures(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddColumnsBuilder(getDatabase().getDialect(), TABLE_MEASURES) + .addColumn(newVarcharColumnDefBuilder().setColumnName("component_uuid").setLimit(UUID_VARCHAR_SIZE).setIgnoreOracleUnit(true).build()) + .build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnsToSnapshots.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnsToSnapshots.java new file mode 100644 index 00000000000..3ebcbd9c5c0 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnsToSnapshots.java @@ -0,0 +1,46 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.AddColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.db.version.VarcharColumnDef.UUID_VARCHAR_SIZE; +import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddComponentUuidColumnsToSnapshots extends DdlChange { + + private static final String TABLE_SNAPSHOTS = "snapshots"; + + public AddComponentUuidColumnsToSnapshots(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddColumnsBuilder(getDatabase().getDialect(), TABLE_SNAPSHOTS) + .addColumn(newVarcharColumnDefBuilder().setColumnName("component_uuid").setLimit(UUID_VARCHAR_SIZE).setIgnoreOracleUnit(true).build()) + .addColumn(newVarcharColumnDefBuilder().setColumnName("root_component_uuid").setLimit(UUID_VARCHAR_SIZE).setIgnoreOracleUnit(true).build()) + .build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddIndexOnAnalysisUuidOfMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddIndexOnAnalysisUuidOfMeasures.java new file mode 100644 index 00000000000..1650a209653 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddIndexOnAnalysisUuidOfMeasures.java @@ -0,0 +1,46 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.CreateIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.db.version.IntegerColumnDef.newIntegerColumnDefBuilder; +import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddIndexOnAnalysisUuidOfMeasures extends DdlChange { + + public AddIndexOnAnalysisUuidOfMeasures(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + // this index must be present for the performance of next migration + context.execute(new CreateIndexBuilder(getDialect()) + .setTable("project_measures") + .setName("measures_analysis_metric") + .addColumn(newVarcharColumnDefBuilder().setColumnName("analysis_uuid").setLimit(50).setIgnoreOracleUnit(true).build()) + .addColumn(newIntegerColumnDefBuilder().setColumnName("metric_id").build()) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddIndexOnComponentUuidOfMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddIndexOnComponentUuidOfMeasures.java new file mode 100644 index 00000000000..8af98e444e6 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddIndexOnComponentUuidOfMeasures.java @@ -0,0 +1,44 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.CreateIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddIndexOnComponentUuidOfMeasures extends DdlChange { + + public AddIndexOnComponentUuidOfMeasures(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new CreateIndexBuilder(getDialect()) + .setTable("project_measures") + .setName("measures_component_uuid") + .addColumn(newVarcharColumnDefBuilder().setColumnName("component_uuid").setLimit(50).setIgnoreOracleUnit(true).build()) + .build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddLastUsedColumnToRulesProfiles.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddLastUsedColumnToRulesProfiles.java new file mode 100644 index 00000000000..3b289a0a34f --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddLastUsedColumnToRulesProfiles.java @@ -0,0 +1,45 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.AddColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.db.version.BigIntegerColumnDef.newBigIntegerColumnDefBuilder; + +public class AddLastUsedColumnToRulesProfiles extends DdlChange { + + private static final String TABLE_QUALITY_PROFILES = "rules_profiles"; + + public AddLastUsedColumnToRulesProfiles(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddColumnsBuilder(getDatabase().getDialect(), TABLE_QUALITY_PROFILES) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("last_used").setIsNullable(true).build()) + .build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddProfileKeyToActivities.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddProfileKeyToActivities.java new file mode 100644 index 00000000000..8c4e24762f7 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddProfileKeyToActivities.java @@ -0,0 +1,45 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.AddColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddProfileKeyToActivities extends DdlChange { + + private static final String TABLE_ACTIVITIES = "activities"; + + public AddProfileKeyToActivities(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddColumnsBuilder(getDatabase().getDialect(), TABLE_ACTIVITIES) + .addColumn(newVarcharColumnDefBuilder().setColumnName("profile_key").setLimit(255).setIgnoreOracleUnit(true).build()) + .build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddUniqueIndexOnUuidOfSnapshots.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddUniqueIndexOnUuidOfSnapshots.java new file mode 100644 index 00000000000..a90e024c317 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddUniqueIndexOnUuidOfSnapshots.java @@ -0,0 +1,44 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.CreateIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddUniqueIndexOnUuidOfSnapshots extends DdlChange { + + public AddUniqueIndexOnUuidOfSnapshots(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new CreateIndexBuilder(getDialect()) + .setTable("snapshots") + .setName("analyses_uuid") + .addColumn(newVarcharColumnDefBuilder().setColumnName("uuid").setLimit(50).setIgnoreOracleUnit(true).build()) + .setUnique(true) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddUserUpdatedAtToRulesProfiles.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddUserUpdatedAtToRulesProfiles.java new file mode 100644 index 00000000000..14d3f91f0cd --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddUserUpdatedAtToRulesProfiles.java @@ -0,0 +1,45 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.AddColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.db.version.BigIntegerColumnDef.newBigIntegerColumnDefBuilder; + +public class AddUserUpdatedAtToRulesProfiles extends DdlChange { + + private static final String TABLE_QUALITY_PROFILES = "rules_profiles"; + + public AddUserUpdatedAtToRulesProfiles(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddColumnsBuilder(getDatabase().getDialect(), TABLE_QUALITY_PROFILES) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("user_updated_at").setIsNullable(true).build()) + .build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnToSnapshots.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnToSnapshots.java new file mode 100644 index 00000000000..aa99605cc16 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnToSnapshots.java @@ -0,0 +1,45 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.AddColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.db.version.VarcharColumnDef.UUID_VARCHAR_SIZE; +import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddUuidColumnToSnapshots extends DdlChange { + + private static final String TABLE_SNAPSHOTS = "snapshots"; + + public AddUuidColumnToSnapshots(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddColumnsBuilder(getDialect(), TABLE_SNAPSHOTS) + .addColumn(newVarcharColumnDefBuilder().setColumnName("uuid").setLimit(UUID_VARCHAR_SIZE).setIgnoreOracleUnit(true).build()) + .build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnsToProjects.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnsToProjects.java new file mode 100644 index 00000000000..a19323af4a4 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnsToProjects.java @@ -0,0 +1,47 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.AddColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.db.version.VarcharColumnDef.UUID_VARCHAR_SIZE; +import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddUuidColumnsToProjects extends DdlChange { + + private static final String TABLE_PROJECTS = "projects"; + + public AddUuidColumnsToProjects(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddColumnsBuilder(getDialect(), TABLE_PROJECTS) + .addColumn(newVarcharColumnDefBuilder().setColumnName("root_uuid").setLimit(UUID_VARCHAR_SIZE).setIgnoreOracleUnit(true).build()) + .addColumn(newVarcharColumnDefBuilder().setColumnName("copy_component_uuid").setLimit(UUID_VARCHAR_SIZE).setIgnoreOracleUnit(true).build()) + .addColumn(newVarcharColumnDefBuilder().setColumnName("developer_uuid").setLimit(UUID_VARCHAR_SIZE).setIgnoreOracleUnit(true).build()) + .build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnsToResourceIndex.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnsToResourceIndex.java new file mode 100644 index 00000000000..ae003ab6569 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnsToResourceIndex.java @@ -0,0 +1,46 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.AddColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.db.version.VarcharColumnDef.UUID_VARCHAR_SIZE; +import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddUuidColumnsToResourceIndex extends DdlChange { + + private static final String TABLE_RESOURCE_INDEX = "resource_index"; + + public AddUuidColumnsToResourceIndex(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddColumnsBuilder(getDialect(), TABLE_RESOURCE_INDEX) + .addColumn(newVarcharColumnDefBuilder().setColumnName("component_uuid").setLimit(UUID_VARCHAR_SIZE).setIgnoreOracleUnit(true).build()) + .addColumn(newVarcharColumnDefBuilder().setColumnName("root_component_uuid").setLimit(UUID_VARCHAR_SIZE).setIgnoreOracleUnit(true).build()) + .build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddUuidPathColumnToProjects.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddUuidPathColumnToProjects.java new file mode 100644 index 00000000000..1d127ac2931 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/AddUuidPathColumnToProjects.java @@ -0,0 +1,44 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.AddColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddUuidPathColumnToProjects extends DdlChange { + + private static final String TABLE_PROJECTS = "projects"; + + public AddUuidPathColumnToProjects(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddColumnsBuilder(getDialect(), TABLE_PROJECTS) + .addColumn(newVarcharColumnDefBuilder().setColumnName("uuid_path").setLimit(1500).setIgnoreOracleUnit(true).build()) + .build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutAnalysisUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutAnalysisUuid.java new file mode 100644 index 00000000000..6a66c534278 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutAnalysisUuid.java @@ -0,0 +1,45 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.MassUpdate; +import org.sonar.server.platform.db.migration.step.DataChange; + +public class CleanEventsWithoutAnalysisUuid extends DataChange { + + public CleanEventsWithoutAnalysisUuid(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + massUpdate.select("SELECT distinct snapshot_id from events e where e.snapshot_id is not null and e.analysis_uuid is null"); + massUpdate.update("DELETE from events WHERE snapshot_id=?"); + massUpdate.rowPluralName("no analysis uuid events"); + massUpdate.execute((row, update) -> { + update.setLong(1, row.getLong(1)); + return true; + }); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutSnapshotId.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutSnapshotId.java new file mode 100644 index 00000000000..5bf9cc47eba --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutSnapshotId.java @@ -0,0 +1,45 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.MassUpdate; +import org.sonar.server.platform.db.migration.step.DataChange; + +public class CleanEventsWithoutSnapshotId extends DataChange { + + public CleanEventsWithoutSnapshotId(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + massUpdate.select("SELECT e.id from events e where e.snapshot_id is null"); + massUpdate.update("DELETE from events WHERE id=?"); + massUpdate.rowPluralName("no snapshot id events"); + massUpdate.execute((row, update) -> { + update.setLong(1, row.getLong(1)); + return true; + }); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CleanMeasuresWithNullAnalysisUuid.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CleanMeasuresWithNullAnalysisUuid.java new file mode 100644 index 00000000000..8e51247db5d --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CleanMeasuresWithNullAnalysisUuid.java @@ -0,0 +1,45 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.MassUpdate; +import org.sonar.server.platform.db.migration.step.DataChange; + +public class CleanMeasuresWithNullAnalysisUuid extends DataChange { + + public CleanMeasuresWithNullAnalysisUuid(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + massUpdate.select("select id from project_measures where analysis_uuid is null"); + massUpdate.update("delete from project_measures where id=?"); + massUpdate.rowPluralName("measures"); + massUpdate.execute((row, update) -> { + update.setLong(1, row.getLong(1)); + return true; + }); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CleanOrphanRowsInProjects.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CleanOrphanRowsInProjects.java new file mode 100644 index 00000000000..fd2d4b37213 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CleanOrphanRowsInProjects.java @@ -0,0 +1,48 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.MassUpdate; +import org.sonar.server.platform.db.migration.step.DataChange; + +public class CleanOrphanRowsInProjects extends DataChange { + + public CleanOrphanRowsInProjects(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + massUpdate.select("SELECT p.id from projects p where p.root_uuid is null" + + " or (p.copy_resource_id is not null and p.copy_component_uuid is null)" + + " or (p.person_id is not null and p.developer_uuid is null)"); + massUpdate.update("DELETE from projects WHERE id=?"); + massUpdate.rowPluralName("orphan projects"); + massUpdate.execute((row, update) -> { + long projectId = row.getLong(1); + update.setLong(1, projectId); + return true; + }); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CleanOrphanRowsInResourceIndex.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CleanOrphanRowsInResourceIndex.java new file mode 100644 index 00000000000..c098ccf2045 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CleanOrphanRowsInResourceIndex.java @@ -0,0 +1,45 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.MassUpdate; +import org.sonar.server.platform.db.migration.step.DataChange; + +public class CleanOrphanRowsInResourceIndex extends DataChange { + + public CleanOrphanRowsInResourceIndex(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + massUpdate.select("SELECT ri.id, ri.resource_id, ri.root_project_id from resource_index ri where ri.component_uuid is null or ri.root_component_uuid is null"); + massUpdate.update("DELETE from resource_index WHERE id=?"); + massUpdate.rowPluralName("resource index entries"); + massUpdate.execute((row, update) -> { + update.setLong(1, row.getLong(1)); + return true; + }); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CleanOrphanRowsInSnapshots.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CleanOrphanRowsInSnapshots.java new file mode 100644 index 00000000000..749c2f584df --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CleanOrphanRowsInSnapshots.java @@ -0,0 +1,62 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.MassUpdate; +import org.sonar.server.platform.db.migration.step.DataChange; + +public class CleanOrphanRowsInSnapshots extends DataChange { + + public CleanOrphanRowsInSnapshots(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + massUpdate.select("SELECT sn.id, sn.project_id, sn.root_project_id from snapshots sn where sn.component_uuid is null or sn.root_component_uuid is null"); + massUpdate.update("DELETE from duplications_index WHERE snapshot_id=? or project_snapshot_id=?"); + massUpdate.update("DELETE from project_measures WHERE snapshot_id=?"); + massUpdate.update("DELETE from ce_activity WHERE snapshot_id=?"); + massUpdate.update("DELETE from events WHERE snapshot_id=?"); + massUpdate.update("DELETE from snapshots WHERE id=?"); + massUpdate.rowPluralName("snapshots"); + massUpdate.execute((row, update, updateIndex) -> { + long snapshotId = row.getLong(1); + switch (updateIndex) { + case 0: + update.setLong(1, snapshotId); + update.setLong(2, snapshotId); + return true; + case 1: + case 2: + case 3: + case 4: + update.setLong(1, snapshotId); + return true; + default: + throw new IllegalArgumentException("Unsupported update index " + updateIndex); + } + }); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CleanUsurperRootComponents.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CleanUsurperRootComponents.java new file mode 100644 index 00000000000..6b8889d42ea --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CleanUsurperRootComponents.java @@ -0,0 +1,156 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.MassUpdate; +import org.sonar.server.platform.db.migration.step.DataChange; + +public class CleanUsurperRootComponents extends DataChange { + + public CleanUsurperRootComponents(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + // fix snapshots which don't have the scope and/or qualifier of their associated component + fixSnapshotScopeAndQualifier(context); + // delete components declaring themselves as root in table PROJECTS but which don't have a root scope and/or qualifier + cleanUsurperRootComponents(context); + // components which has snapshots reference a component as root which is not a root + cleanSnapshotWithIncorrectRoot(context); + } + + private static void fixSnapshotScopeAndQualifier(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + massUpdate.select("select" + + " sn.id,p.scope,p.qualifier" + + " from" + + " snapshots sn, projects p" + + " where" + + " p.uuid = sn.component_uuid" + + " and (p.qualifier<>sn.qualifier or p.scope<>sn.scope)"); + massUpdate.update("update snapshots set scope=?,qualifier=? where id=?"); + massUpdate.rowPluralName("snapshots with inconsistent scope or qualifier"); + massUpdate.execute((row, update) -> { + long snapshotId = row.getLong(1); + String scope = row.getString(2); + String qualifier = row.getString(3); + + update.setString(1, scope); + update.setString(2, qualifier); + update.setLong(3, snapshotId); + + return true; + }); + } + + private static void cleanUsurperRootComponents(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + massUpdate.select("select p.id,p.uuid from projects p " + + " where" + + " p.project_uuid = p.uuid" + + " and not (" + + " p.scope = 'PRJ'" + + " and p.qualifier in ('TRK', 'VW', 'DEV')" + + " )"); + massUpdate.update("delete from duplications_index where snapshot_id in (select id from snapshots where component_uuid=?)"); + massUpdate.update("delete from project_measures where component_uuid=?"); + massUpdate.update("delete from ce_activity where component_uuid=?"); + massUpdate.update("delete from events where component_uuid=?"); + massUpdate.update("delete from project_links where component_uuid=?"); + massUpdate.update("delete from snapshots where component_uuid=? or root_component_uuid=?"); + massUpdate.update("delete from issues where component_uuid=? or project_uuid=?"); + massUpdate.update("delete from file_sources where file_uuid=? or project_uuid=?"); + massUpdate.update("delete from group_roles where resource_id=?"); + massUpdate.update("delete from user_roles where resource_id=?"); + massUpdate.update("delete from properties where resource_id=?"); + massUpdate.update("delete from widgets where resource_id=?"); + massUpdate.update("delete from projects where uuid=?"); + massUpdate.rowPluralName("usurper root components"); + massUpdate.execute((row, update, updateIndex) -> { + long componentId = row.getLong(1); + String componentUuid = row.getString(2); + switch (updateIndex) { + case 0: + case 1: + case 2: + case 3: + case 4: + update.setString(1, componentUuid); + return true; + case 5: + case 6: + case 7: + update.setString(1, componentUuid); + update.setString(2, componentUuid); + return true; + case 8: + case 9: + case 10: + case 11: + update.setLong(1, componentId); + return true; + case 12: + update.setString(1, componentUuid); + return true; + default: + throw new IllegalArgumentException("Unsupported update index " + updateIndex); + } + }); + } + + private static void cleanSnapshotWithIncorrectRoot(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + massUpdate.select("select" + + " sn.id" + + " from " + + " projects p, snapshots sn" + + " where" + + " p.uuid = sn.root_component_uuid" + + " and not (" + + " p.scope = 'PRJ'" + + " and p.qualifier in ('TRK', 'VW', 'DEV')" + + " )"); + massUpdate.update("DELETE from ce_activity WHERE snapshot_id=?"); + massUpdate.update("DELETE from events WHERE snapshot_id=?"); + massUpdate.update("DELETE from project_measures WHERE snapshot_id=?"); + massUpdate.update("DELETE from duplications_index WHERE project_snapshot_id=?"); + massUpdate.update("DELETE from snapshots WHERE id=?"); + massUpdate.rowPluralName("snapshots with incorrect root"); + massUpdate.execute((row, update, updateIndex) -> { + long snapshotId = row.getLong(1); + switch (updateIndex) { + case 0: + case 1: + case 2: + case 3: + case 4: + update.setLong(1, snapshotId); + return true; + default: + throw new IllegalArgumentException("Unsupported update index " + updateIndex); + } + }); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CreatePermTemplatesCharacteristics.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CreatePermTemplatesCharacteristics.java new file mode 100644 index 00000000000..1db6e771a26 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CreatePermTemplatesCharacteristics.java @@ -0,0 +1,66 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.CreateIndexBuilder; +import org.sonar.db.version.CreateTableBuilder; +import org.sonar.db.version.IntegerColumnDef; +import org.sonar.db.version.VarcharColumnDef; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.db.version.BigIntegerColumnDef.newBigIntegerColumnDefBuilder; +import static org.sonar.db.version.BooleanColumnDef.newBooleanColumnDefBuilder; +import static org.sonar.db.version.CreateTableBuilder.ColumnFlag.AUTO_INCREMENT; +import static org.sonar.db.version.IntegerColumnDef.newIntegerColumnDefBuilder; +import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class CreatePermTemplatesCharacteristics extends DdlChange { + + private static final String TABLE_NAME = "perm_tpl_characteristics"; + + public CreatePermTemplatesCharacteristics(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + IntegerColumnDef templateIdColumn = newIntegerColumnDefBuilder().setColumnName("template_id").setIsNullable(false).build(); + VarcharColumnDef permissionKeyColumn = newVarcharColumnDefBuilder().setColumnName("permission_key").setLimit(64).setIsNullable(false).setIgnoreOracleUnit(true).build(); + context.execute( + new CreateTableBuilder(getDialect(), TABLE_NAME) + .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT) + .addColumn(templateIdColumn) + .addColumn(permissionKeyColumn) + .addColumn(newBooleanColumnDefBuilder().setColumnName("with_project_creator").setIsNullable(false).setDefaultValue(false).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build()) + .addColumn(newBigIntegerColumnDefBuilder().setColumnName("updated_at").setIsNullable(false).build()) + .build()); + + context.execute(new CreateIndexBuilder(getDialect()) + .setTable(TABLE_NAME) + .setName("uniq_perm_tpl_charac") + .setUnique(true) + .addColumn(templateIdColumn) + .addColumn(permissionKeyColumn) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CreateTemporaryIndicesFor1211.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CreateTemporaryIndicesFor1211.java new file mode 100644 index 00000000000..f591285f484 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/CreateTemporaryIndicesFor1211.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.CreateIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.db.version.IntegerColumnDef.newIntegerColumnDefBuilder; + +public class CreateTemporaryIndicesFor1211 extends DdlChange { + + static final String INDEX_ON_CE_ACTIVITY = "ce_activity_snapshot_id"; + static final String INDEX_ON_DUPLICATIONS_INDEX = "dup_index_psid"; + + public CreateTemporaryIndicesFor1211(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new CreateIndexBuilder(getDialect()) + .setTable("ce_activity") + .setName(INDEX_ON_CE_ACTIVITY) + .addColumn(newIntegerColumnDefBuilder().setColumnName("snapshot_id").build()) + .build()); + context.execute(new CreateIndexBuilder(getDialect()) + .setTable("duplications_index") + .setName(INDEX_ON_DUPLICATIONS_INDEX) + .addColumn(newIntegerColumnDefBuilder().setColumnName("project_snapshot_id").build()) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DbVersion60.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DbVersion60.java new file mode 100644 index 00000000000..46a559aae1d --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DbVersion60.java @@ -0,0 +1,115 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.util.stream.Stream; +import org.sonar.server.platform.db.migration.step.MigrationStepRegistry; +import org.sonar.server.platform.db.migration.version.DbVersion; + +public class DbVersion60 implements DbVersion { + @Override + public Stream<Object> getSupportComponents() { + return Stream.of( + // Migration1223 + FixProjectUuidOfDeveloperProjects.class, + CleanUsurperRootComponents.class); + } + + @Override + public void addSteps(MigrationStepRegistry registry) { + registry + .add(1200, "Create table PERM_TPL_CHARACTERISTICS", CreatePermTemplatesCharacteristics.class) + .add(1201, "Add columns RESOURCE_INDEX.*_UUID", AddUuidColumnsToResourceIndex.class) + .add(1202, "Populate columns RESOURCE_INDEX.*_UUID", PopulateUuidColumnsOfResourceIndex.class) + .add(1203, "Clean orphan rows in RESOURCE_INDEX", CleanOrphanRowsInResourceIndex.class) + .add(1204, "Make columns RESOURCE_INDEX.*_UUID not nullable", MakeUuidColumnsNotNullOnResourceIndex.class) + .add(1205, "Make column RESOURCE_INDEX.resource_index_rid", DropResourceIndexRidFromResourceIndex.class) + .add(1206, "Drop columns RESOURCE_INDEX.*_ID", DropIdColumnsFromResourceIndex.class) + .add(1207, "Drop unused columns on PROJECT_MEASURES", DropUnusedMeasuresColumns.class) + .add(1208, "Add columns SNAPSHOTS.*COMPONENT_UUID", AddComponentUuidColumnsToSnapshots.class) + .add(1209, "Populate column SNAPSHOTS.*COMPONENT_UUID", PopulateComponentUuidColumnsOfSnapshots.class) + .add(1210, "Create temporary indices for migration 1211", CreateTemporaryIndicesFor1211.class) + .add(1211, "Clean orphan rows in SNAPSHOTS", CleanOrphanRowsInSnapshots.class) + .add(1212, "Drop temporary indices for migration 1211", DropTemporaryIndicesOf1210.class) + .add(1213, "Make column SNAPSHOTS.UUID not nullable", MakeComponentUuidColumnsNotNullOnSnapshots.class) + .add(1214, "Drop columns SNAPSHOTS.SNAPSHOT_*_ID", DropSnapshotProjectIdFromSnapshots.class) + .add(1215, "Drop columns SNAPSHOTS.*_ID", DropIdColumnsFromSnapshots.class) + .add(1216, "Add column PROJECT_MEASURES.COMPONENT_UUID", AddComponentUuidColumnToMeasures.class) + .add(1217, "Populate column PROJECT_MEASURES.COMPONENT_UUID", PopulateComponentUuidOfMeasures.class) + .add(1218, "Delete orphan measures without component", DeleteOrphanMeasuresWithoutComponent.class) + .add(1219, "Make column PROJECT_MEASURES.COMPONENT_UUID not nullable", MakeComponentUuidNotNullOnMeasures.class) + .add(1220, "Drop column PROJECT_MEASURES.PROJECT_ID", DropProjectIdColumnFromMeasures.class) + .add(1221, "Add index measures_component_uuid", AddIndexOnComponentUuidOfMeasures.class) + .add(1222, "Drop columns USERS.REMEMBER_TOKEN_*", DropRememberMeColumnsFromUsers.class) + .add(1223, "Clean orphan rows and fix incorrect data in table PROJECTS", Migration1223.class) + .add(1224, "Add columns PROJECTS.*_UUID", AddUuidColumnsToProjects.class) + .add(1225, "Populate columns PROJECTS.*_UUID", PopulateUuidColumnsOfProjects.class) + .add(1226, "Clean orphan rows in table PROJECTS", CleanOrphanRowsInProjects.class) + .add(1227, "Drop index projects_uuid", DropIndexProjectsUuidFromProjects.class) + .add(1228, "Make columns PROJECTS.*_UUID not nullable", MakeUuidColumnsNotNullOnProjects.class) + .add(1229, "Recreate index projects_uuid", RecreateIndexProjectsUuidFromProjects.class) + .add(1230, "Drop index projects_root_id", DropIndexProjectsRootIdFromProjects.class) + .add(1231, "Drop columns PROJECTS.*_ID", DropIdColumnsFromProjects.class) + .add(1232, "Add column SNAPSHOTS.UUID", AddUuidColumnToSnapshots.class) + .add(1233, "Populate column SNAPSHOTS.UUID", PopulateUuidColumnOnSnapshots.class) + .add(1234, "Make column SNAPSHOTS.UUID not nullable", MakeUuidColumnNotNullOnSnapshots.class) + .add(1235, "Add unique index analyses_uuid", AddUniqueIndexOnUuidOfSnapshots.class) + .add(1236, "Add column CE_ACTIVITY.ANALYSIS_UUID", AddAnalysisUuidColumnToCeActivity.class) + .add(1237, "Populate column CE_ACTIVITY.ANALYSIS_UUID", PopulateAnalysisUuidColumnOnCeActivity.class) + .add(1238, "Drop column CE_ACTIVITY.SNAPSHOT_ID", DropSnapshotIdColumnFromCeActivity.class) + .add(1239, "Add columns DUPLICATION_INDEX.*_UUID", AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndex.class) + .add(1240, "Populate columns DUPLICATION_INDEX.*_UUID", PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndex.class) + .add(1241, "Clean orphan rows in table DUPLICATION_INDEX", DeleteOrphanDuplicationsIndexRowsWithoutComponentOrAnalysis.class) + .add(1242, "Make columns DUPLICATION_INDEX.*_UUID not nullable", MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndex.class) + .add(1243, "Drop index duplications_index_sid", DropIndexDuplicationsIndexSidFromDuplicationsIndex.class) + .add(1244, "Drop columns DUPLICATION_INDEX.*SNAPSHOT_ID", DropSnapshotIdColumnsFromDuplicationsIndex.class) + .add(1246, "Add column RULES_PROFILES.LAST_USED", AddLastUsedColumnToRulesProfiles.class) + .add(1247, "Populate column RULES_PROFILES.LAST_USED", PopulateLastUsedColumnOfRulesProfiles.class) + .add(1248, "Add column EVENTS.ANALYSIS_UUID", AddAnalysisUuidColumnToEvents.class) + .add(1249, "Populate column EVENTS.ANALYSIS_UUID", PopulateAnalysisUuidOnEvents.class) + .add(1250, "Clean events without analysis_uuid", CleanEventsWithoutAnalysisUuid.class) + .add(1251, "Clean events without snapshot_id", CleanEventsWithoutSnapshotId.class) + .add(1252, "Make column EVENTS.ANALYSIS_UUID not nullable", MakeAnalysisUuidNotNullOnEvents.class) + .add(1253, "Drop index events_snapshot_id", DropIndexEventsSnapshotIdFromEvents.class) + .add(1254, "Drop columns EVENTS.SNAPSHOT_ID", DropSnapshotIdColumnFromEvents.class) + .add(1256, "Add column PROJECTS.UUID_PATH", AddUuidPathColumnToProjects.class) + .add(1257, "Populate column PROJECTS.UUID_PATH", PopulateUuidPathColumnOnProjects.class) + .add(1258, "Make column PROJECTS.UUID_PATH not nullable", MakeUuidPathColumnNotNullOnProjects.class) + .add(1259, "Remove password of non local users", RemoveUsersPasswordWhenNotLocal.class) + .add(1260, "Add column ACTIVITIES.PROFILE_KEY", AddProfileKeyToActivities.class) + .add(1261, "Populate column ACTIVITIES.PROFILE_KEY", PopulateProfileKeyOfActivities.class) + .add(1262, "Make column ACTIVITIES.PROFILE_KEY not nullable", MakeProfileKeyNotNullOnActivities.class) + .add(1263, "Add column RULES_PROFILES.USER_UPDATED_AT", AddUserUpdatedAtToRulesProfiles.class) + .add(1264, "Populate column RULES_PROFILES.USER_UPDATED_AT", PopulateUserUpdatedAtOfRulesProfiles.class) + .add(1265, "Add column PROJECT_MEASURES.ANALYSIS_UUID", AddAnalysisUuidColumnToMeasures.class) + .add(1266, "Add index measures_analysis_metric", AddIndexOnAnalysisUuidOfMeasures.class) + .add(1267, "Populate column PROJECT_MEASURES.ANALYSIS_UUID", PopulateAnalysisUuidOnMeasures.class) + .add(1268, "Clean orphan measures", CleanMeasuresWithNullAnalysisUuid.class) + .add(1269, "Temporary drop of index measures_analysis_metric", TemporarilyDropIndexOfAnalysisUuidOnMeasures.class) + .add(1270, "Make column PROJECT_MEASURES.ANALYSIS_UUID not nullable", MakeAnalysisUuidNotNullOnMeasures.class) + .add(1271, "Restore index measures_analysis_metric", AddIndexOnAnalysisUuidOfMeasures.class) + .add(1272, "Delete snapshots but the one of root components", DropTreesOfSnapshots.class) + .add(1273, "Drop indices on tree columns of table SNAPSHOTS", DropIndicesOnTreeColumnsOfSnapshots.class) + .add(1274, "Drop tree columns of table SNAPSHOTS", DropTreeColumnsFromSnapshots.class) + .add(1275, "Drop index measures_sid_metric", DropIndexOnSnapshotIdOfMeasures.class) + .add(1276, "Drop column PROJECT_MEASURES.SNAPSHOT_ID", DropSnapshotIdColumnFromMeasures.class) + .add(1277, "Add columns PROJECTS.B_*", AddBColumnsToProjects.class); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DeleteOrphanDuplicationsIndexRowsWithoutComponentOrAnalysis.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DeleteOrphanDuplicationsIndexRowsWithoutComponentOrAnalysis.java new file mode 100644 index 00000000000..1691c384514 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DeleteOrphanDuplicationsIndexRowsWithoutComponentOrAnalysis.java @@ -0,0 +1,61 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.MassUpdate; +import org.sonar.server.platform.db.migration.step.DataChange; + +public class DeleteOrphanDuplicationsIndexRowsWithoutComponentOrAnalysis extends DataChange { + + public DeleteOrphanDuplicationsIndexRowsWithoutComponentOrAnalysis(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + deleteRowsWithoutComponentUuid(context); + deleteRowsWithoutAnalysisUuid(context); + } + + private static void deleteRowsWithoutComponentUuid(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + massUpdate.select("SELECT id from duplications_index where component_uuid is null"); + massUpdate.update("DELETE from duplications_index WHERE id=?"); + massUpdate.rowPluralName("duplications index rows without component"); + massUpdate.execute((row, update) -> { + update.setLong(1, row.getLong(1)); + return true; + }); + } + + private static void deleteRowsWithoutAnalysisUuid(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + massUpdate.select("SELECT distinct project_snapshot_id from duplications_index where analysis_uuid is null"); + massUpdate.update("DELETE from duplications_index WHERE project_snapshot_id=?"); + massUpdate.rowPluralName("duplications index rows without analysis"); + massUpdate.execute((row, update) -> { + update.setLong(1, row.getLong(1)); + return true; + }); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DeleteOrphanMeasuresWithoutComponent.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DeleteOrphanMeasuresWithoutComponent.java new file mode 100644 index 00000000000..1812edb8e2c --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DeleteOrphanMeasuresWithoutComponent.java @@ -0,0 +1,45 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.MassUpdate; +import org.sonar.server.platform.db.migration.step.DataChange; + +public class DeleteOrphanMeasuresWithoutComponent extends DataChange { + + public DeleteOrphanMeasuresWithoutComponent(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + massUpdate.select("SELECT id from project_measures where component_uuid is null"); + massUpdate.update("DELETE from project_measures WHERE id=?"); + massUpdate.rowPluralName("measures"); + massUpdate.execute((row, update) -> { + update.setLong(1, row.getLong(1)); + return true; + }); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIdColumnsFromProjects.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIdColumnsFromProjects.java new file mode 100644 index 00000000000..05a0eb32bec --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIdColumnsFromProjects.java @@ -0,0 +1,44 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropIdColumnsFromProjects extends DdlChange { + + private static final String TABLE_PROJECTS = "projects"; + + public DropIdColumnsFromProjects(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute( + new DropColumnsBuilder( + getDialect(), TABLE_PROJECTS, + "root_id", "copy_resource_id", "person_id") + .build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIdColumnsFromResourceIndex.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIdColumnsFromResourceIndex.java new file mode 100644 index 00000000000..43cec60ca59 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIdColumnsFromResourceIndex.java @@ -0,0 +1,44 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropIdColumnsFromResourceIndex extends DdlChange { + + private static final String TABLE_RESOURCE_INDEX = "resource_index"; + + public DropIdColumnsFromResourceIndex(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute( + new DropColumnsBuilder( + getDialect(), TABLE_RESOURCE_INDEX, + "resource_id", "root_project_id") + .build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIdColumnsFromSnapshots.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIdColumnsFromSnapshots.java new file mode 100644 index 00000000000..d53c22f93ab --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIdColumnsFromSnapshots.java @@ -0,0 +1,44 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropIdColumnsFromSnapshots extends DdlChange { + + private static final String TABLE_SNAPSHOTS = "snapshots"; + + public DropIdColumnsFromSnapshots(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute( + new DropColumnsBuilder( + getDatabase().getDialect(), TABLE_SNAPSHOTS, + "project_id", "root_project_id") + .build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIndexDuplicationsIndexSidFromDuplicationsIndex.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIndexDuplicationsIndexSidFromDuplicationsIndex.java new file mode 100644 index 00000000000..12db9932baf --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIndexDuplicationsIndexSidFromDuplicationsIndex.java @@ -0,0 +1,39 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.DropIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropIndexDuplicationsIndexSidFromDuplicationsIndex extends DdlChange { + public DropIndexDuplicationsIndexSidFromDuplicationsIndex(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropIndexBuilder(getDialect()) + .setTable("duplications_index") + .setName("duplications_index_sid") + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIndexEventsSnapshotIdFromEvents.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIndexEventsSnapshotIdFromEvents.java new file mode 100644 index 00000000000..4b1e0bdf177 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIndexEventsSnapshotIdFromEvents.java @@ -0,0 +1,39 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.DropIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropIndexEventsSnapshotIdFromEvents extends DdlChange { + public DropIndexEventsSnapshotIdFromEvents(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropIndexBuilder(getDialect()) + .setTable("events") + .setName("events_snapshot_id") + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIndexOnSnapshotIdOfMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIndexOnSnapshotIdOfMeasures.java new file mode 100644 index 00000000000..22ef746c73e --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIndexOnSnapshotIdOfMeasures.java @@ -0,0 +1,39 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.DropIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropIndexOnSnapshotIdOfMeasures extends DdlChange { + public DropIndexOnSnapshotIdOfMeasures(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropIndexBuilder(getDialect()) + .setTable("project_measures") + .setName("measures_sid_metric") + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIndexProjectsRootIdFromProjects.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIndexProjectsRootIdFromProjects.java new file mode 100644 index 00000000000..647b194c752 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIndexProjectsRootIdFromProjects.java @@ -0,0 +1,39 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.DropIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropIndexProjectsRootIdFromProjects extends DdlChange { + public DropIndexProjectsRootIdFromProjects(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropIndexBuilder(getDialect()) + .setTable("projects") + .setName("projects_root_id") + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIndexProjectsUuidFromProjects.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIndexProjectsUuidFromProjects.java new file mode 100644 index 00000000000..1f4dc0c296d --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIndexProjectsUuidFromProjects.java @@ -0,0 +1,39 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.DropIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropIndexProjectsUuidFromProjects extends DdlChange { + public DropIndexProjectsUuidFromProjects(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropIndexBuilder(getDialect()) + .setTable("projects") + .setName("projects_uuid") + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIndicesOnTreeColumnsOfSnapshots.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIndicesOnTreeColumnsOfSnapshots.java new file mode 100644 index 00000000000..5269f796617 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropIndicesOnTreeColumnsOfSnapshots.java @@ -0,0 +1,46 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.DropIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropIndicesOnTreeColumnsOfSnapshots extends DdlChange { + public DropIndicesOnTreeColumnsOfSnapshots(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + dropIndex(context, "snapshots_qualifier"); + dropIndex(context, "snapshots_root"); + dropIndex(context, "snapshots_parent"); + dropIndex(context, "snapshot_root_component"); + } + + private void dropIndex(Context context, String index) throws SQLException { + context.execute(new DropIndexBuilder(getDialect()) + .setTable("snapshots") + .setName(index) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropProjectIdColumnFromMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropProjectIdColumnFromMeasures.java new file mode 100644 index 00000000000..1b20ef3ac7b --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropProjectIdColumnFromMeasures.java @@ -0,0 +1,41 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropProjectIdColumnFromMeasures extends DdlChange { + + private static final String TABLE_MEASURES = "project_measures"; + + public DropProjectIdColumnFromMeasures(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute( + new DropColumnsBuilder(getDatabase().getDialect(), TABLE_MEASURES, "project_id").build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropRememberMeColumnsFromUsers.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropRememberMeColumnsFromUsers.java new file mode 100644 index 00000000000..da23d199f41 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropRememberMeColumnsFromUsers.java @@ -0,0 +1,40 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropRememberMeColumnsFromUsers extends DdlChange { + + private static final String TABLE_USERS = "users"; + + public DropRememberMeColumnsFromUsers(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropColumnsBuilder(getDialect(), TABLE_USERS, "remember_token", "remember_token_expires_at").build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropResourceIndexRidFromResourceIndex.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropResourceIndexRidFromResourceIndex.java new file mode 100644 index 00000000000..35435c8a02e --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropResourceIndexRidFromResourceIndex.java @@ -0,0 +1,41 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.DropIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropResourceIndexRidFromResourceIndex extends DdlChange { + + public DropResourceIndexRidFromResourceIndex(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropIndexBuilder(getDialect()) + .setTable("resource_index") + .setName("resource_index_rid") + .build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotIdColumnFromCeActivity.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotIdColumnFromCeActivity.java new file mode 100644 index 00000000000..4f2c6ad65ad --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotIdColumnFromCeActivity.java @@ -0,0 +1,44 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropSnapshotIdColumnFromCeActivity extends DdlChange { + + private static final String TABLE_CE_ACTIVITY = "ce_activity"; + + public DropSnapshotIdColumnFromCeActivity(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute( + new DropColumnsBuilder( + getDatabase().getDialect(), TABLE_CE_ACTIVITY, + "snapshot_id") + .build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotIdColumnFromEvents.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotIdColumnFromEvents.java new file mode 100644 index 00000000000..976100d3dbb --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotIdColumnFromEvents.java @@ -0,0 +1,40 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropSnapshotIdColumnFromEvents extends DdlChange { + + private static final String TABLE_EVENTS = "events"; + + public DropSnapshotIdColumnFromEvents(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropColumnsBuilder(getDatabase().getDialect(), TABLE_EVENTS, "snapshot_id").build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotIdColumnFromMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotIdColumnFromMeasures.java new file mode 100644 index 00000000000..ca1e91b838f --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotIdColumnFromMeasures.java @@ -0,0 +1,40 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropSnapshotIdColumnFromMeasures extends DdlChange { + + private static final String TABLE = "project_measures"; + + public DropSnapshotIdColumnFromMeasures(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropColumnsBuilder(getDatabase().getDialect(), TABLE, "snapshot_id").build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotIdColumnsFromDuplicationsIndex.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotIdColumnsFromDuplicationsIndex.java new file mode 100644 index 00000000000..b4b7a20ce7a --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotIdColumnsFromDuplicationsIndex.java @@ -0,0 +1,41 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropSnapshotIdColumnsFromDuplicationsIndex extends DdlChange { + + private static final String TABLE_DUPLICATIONS_INDEX = "duplications_index"; + + public DropSnapshotIdColumnsFromDuplicationsIndex(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute( + new DropColumnsBuilder(getDialect(), TABLE_DUPLICATIONS_INDEX, "project_snapshot_id", "snapshot_id").build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotProjectIdFromSnapshots.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotProjectIdFromSnapshots.java new file mode 100644 index 00000000000..782dd38425b --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotProjectIdFromSnapshots.java @@ -0,0 +1,46 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.DropIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropSnapshotProjectIdFromSnapshots extends DdlChange { + + private static final String TABLE_SNAPSHOTS = "snapshots"; + + public DropSnapshotProjectIdFromSnapshots(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropIndexBuilder(getDialect()) + .setTable(TABLE_SNAPSHOTS) + .setName("snapshot_project_id") + .build()); + context.execute(new DropIndexBuilder(getDialect()) + .setTable(TABLE_SNAPSHOTS) + .setName("snapshots_root_project_id") + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropTemporaryIndicesOf1210.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropTemporaryIndicesOf1210.java new file mode 100644 index 00000000000..16e6151087e --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropTemporaryIndicesOf1210.java @@ -0,0 +1,46 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.DropIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropTemporaryIndicesOf1210 extends DdlChange { + + public DropTemporaryIndicesOf1210(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropIndexBuilder(getDialect()) + .setTable("ce_activity") + .setName(CreateTemporaryIndicesFor1211.INDEX_ON_CE_ACTIVITY) + .build()); + + context.execute(new DropIndexBuilder(getDialect()) + .setTable("duplications_index") + .setName(CreateTemporaryIndicesFor1211.INDEX_ON_DUPLICATIONS_INDEX) + .build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropTreeColumnsFromSnapshots.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropTreeColumnsFromSnapshots.java new file mode 100644 index 00000000000..9051c594d0b --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropTreeColumnsFromSnapshots.java @@ -0,0 +1,41 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class DropTreeColumnsFromSnapshots extends DdlChange { + + private static final String TABLE = "snapshots"; + + public DropTreeColumnsFromSnapshots(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + String[] columns = {"parent_snapshot_id", "scope", "qualifier", "root_snapshot_id", "path", "depth", "root_component_uuid"}; + context.execute(new DropColumnsBuilder(getDatabase().getDialect(), TABLE, columns).build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropTreesOfSnapshots.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropTreesOfSnapshots.java new file mode 100644 index 00000000000..f961ccdfe0a --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropTreesOfSnapshots.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.MassUpdate; +import org.sonar.db.version.Select; +import org.sonar.db.version.SqlStatement; +import org.sonar.server.platform.db.migration.step.DataChange; + +public class DropTreesOfSnapshots extends DataChange { + + public DropTreesOfSnapshots(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + massUpdate.select("select id from snapshots where depth > 0"); + massUpdate.update("delete from snapshots where id=?"); + massUpdate.rowPluralName("snapshots"); + massUpdate.execute(DropTreesOfSnapshots::handle); + } + + private static boolean handle(Select.Row row, SqlStatement update) throws SQLException { + long id = row.getLong(1); + update.setLong(1, id); + return true; + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropUnusedMeasuresColumns.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropUnusedMeasuresColumns.java new file mode 100644 index 00000000000..64de75fdb4c --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/DropUnusedMeasuresColumns.java @@ -0,0 +1,57 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import com.google.common.annotations.VisibleForTesting; +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +/** + * Drop the following columns from the project_measures table : + * - rule_category_id + * - tendency + * - url + * - measure_date + * - url + * - rule_priority + * - rule_id + * - Characteristic_id + */ +public class DropUnusedMeasuresColumns extends DdlChange { + + public DropUnusedMeasuresColumns(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(generateSql()); + } + + @VisibleForTesting + String generateSql() { + return new DropColumnsBuilder(getDatabase().getDialect(), "project_measures", + "rules_category_id", "tendency", "measure_date", "url", "rule_priority", "characteristic_id", "rule_id") + .build(); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/FixProjectUuidOfDeveloperProjects.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/FixProjectUuidOfDeveloperProjects.java new file mode 100644 index 00000000000..432399598b4 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/FixProjectUuidOfDeveloperProjects.java @@ -0,0 +1,53 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.MassUpdate; +import org.sonar.db.version.Select; +import org.sonar.db.version.SqlStatement; +import org.sonar.server.platform.db.migration.step.DataChange; + +public class FixProjectUuidOfDeveloperProjects extends DataChange { + + public FixProjectUuidOfDeveloperProjects(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + massUpdate.select("select distinct p.person_id,d.uuid from projects p, projects d where p.qualifier = 'DEV_PRJ' and p.project_uuid != d.uuid and d.id = p.person_id"); + massUpdate.update("update projects set project_uuid = ? where person_id = ? and qualifier = 'DEV_PRJ' and project_uuid != ?"); + massUpdate.rowPluralName("developers with incorrect project_uuid"); + massUpdate.execute(FixProjectUuidOfDeveloperProjects::handleComponent); + } + + private static boolean handleComponent(Select.Row row, SqlStatement update) throws SQLException { + long personId = row.getLong(1); + String developerUuid = row.getString(2); + update.setString(1, developerUuid); + update.setLong(2, personId); + update.setString(3, developerUuid); + + return true; + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeAnalysisUuidNotNullOnEvents.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeAnalysisUuidNotNullOnEvents.java new file mode 100644 index 00000000000..3ffc82dc788 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeAnalysisUuidNotNullOnEvents.java @@ -0,0 +1,59 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.AlterColumnsBuilder; +import org.sonar.db.version.CreateIndexBuilder; +import org.sonar.db.version.VarcharColumnDef; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.db.version.VarcharColumnDef.UUID_VARCHAR_SIZE; +import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class MakeAnalysisUuidNotNullOnEvents extends DdlChange { + + private static final String TABLE_EVENTS = "events"; + + public MakeAnalysisUuidNotNullOnEvents(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + VarcharColumnDef analysisUuidColumn = newVarcharColumnDefBuilder() + .setColumnName("analysis_uuid") + .setLimit(UUID_VARCHAR_SIZE) + .setIsNullable(false) + .setIgnoreOracleUnit(true) + .build(); + context.execute(new AlterColumnsBuilder(getDatabase().getDialect(), TABLE_EVENTS) + .updateColumn(analysisUuidColumn) + .build()); + + context.execute(new CreateIndexBuilder(getDialect()) + .setTable(TABLE_EVENTS) + .setName("events_analysis") + .addColumn(analysisUuidColumn) + .build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeAnalysisUuidNotNullOnMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeAnalysisUuidNotNullOnMeasures.java new file mode 100644 index 00000000000..63b18552c7a --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeAnalysisUuidNotNullOnMeasures.java @@ -0,0 +1,45 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.AlterColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.db.version.VarcharColumnDef.UUID_VARCHAR_SIZE; +import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class MakeAnalysisUuidNotNullOnMeasures extends DdlChange { + + private static final String TABLE_MEASURES = "project_measures"; + + public MakeAnalysisUuidNotNullOnMeasures(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AlterColumnsBuilder(getDatabase().getDialect(), TABLE_MEASURES) + .updateColumn(newVarcharColumnDefBuilder().setColumnName("analysis_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).setIgnoreOracleUnit(true).build()) + .build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndex.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndex.java new file mode 100644 index 00000000000..1604d77d52d --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndex.java @@ -0,0 +1,66 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.AlterColumnsBuilder; +import org.sonar.db.version.CreateIndexBuilder; +import org.sonar.db.version.VarcharColumnDef; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.db.version.VarcharColumnDef.UUID_VARCHAR_SIZE; +import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndex extends DdlChange { + + private static final String TABLE_DUPLICATIONS_INDEX = "duplications_index"; + + public MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndex(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + VarcharColumnDef analysisUuid = newUuidColumn("analysis_uuid"); + VarcharColumnDef componentUuid = newUuidColumn("component_uuid"); + context.execute(new AlterColumnsBuilder(getDatabase().getDialect(), TABLE_DUPLICATIONS_INDEX) + .updateColumn(componentUuid) + .updateColumn(analysisUuid) + .build()); + + context.execute(new CreateIndexBuilder(getDialect()) + .setTable(TABLE_DUPLICATIONS_INDEX) + .setName("duplication_analysis_component") + .addColumn(analysisUuid) + .addColumn(componentUuid) + .build()); + } + + private static VarcharColumnDef newUuidColumn(String columnName) { + return newVarcharColumnDefBuilder() + .setColumnName(columnName) + .setLimit(UUID_VARCHAR_SIZE) + .setIsNullable(false) + .setIgnoreOracleUnit(true) + .build(); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidColumnsNotNullOnSnapshots.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidColumnsNotNullOnSnapshots.java new file mode 100644 index 00000000000..aa85bcb42c3 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidColumnsNotNullOnSnapshots.java @@ -0,0 +1,70 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.AlterColumnsBuilder; +import org.sonar.db.version.CreateIndexBuilder; +import org.sonar.db.version.VarcharColumnDef; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.db.version.VarcharColumnDef.UUID_VARCHAR_SIZE; +import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class MakeComponentUuidColumnsNotNullOnSnapshots extends DdlChange { + + private static final String TABLE_SNAPSHOTS = "snapshots"; + + public MakeComponentUuidColumnsNotNullOnSnapshots(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + VarcharColumnDef componentUuid = newUuidColumn("component_uuid"); + VarcharColumnDef rootComponentUuid = newUuidColumn("root_component_uuid"); + context.execute(new AlterColumnsBuilder(getDatabase().getDialect(), TABLE_SNAPSHOTS) + .updateColumn(componentUuid) + .updateColumn(rootComponentUuid) + .build()); + + context.execute(new CreateIndexBuilder(getDialect()) + .setTable(TABLE_SNAPSHOTS) + .setName("snapshot_component") + .addColumn(componentUuid) + .build()); + context.execute(new CreateIndexBuilder(getDialect()) + .setTable(TABLE_SNAPSHOTS) + .setName("snapshot_root_component") + .addColumn(rootComponentUuid) + .build()); + } + + private static VarcharColumnDef newUuidColumn(String columnName) { + return newVarcharColumnDefBuilder() + .setColumnName(columnName) + .setLimit(UUID_VARCHAR_SIZE) + .setIsNullable(false) + .setIgnoreOracleUnit(true) + .build(); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidNotNullOnMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidNotNullOnMeasures.java new file mode 100644 index 00000000000..7a4b5422000 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidNotNullOnMeasures.java @@ -0,0 +1,45 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.AlterColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.db.version.VarcharColumnDef.UUID_VARCHAR_SIZE; +import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class MakeComponentUuidNotNullOnMeasures extends DdlChange { + + private static final String TABLE_MEASURES = "project_measures"; + + public MakeComponentUuidNotNullOnMeasures(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AlterColumnsBuilder(getDatabase().getDialect(), TABLE_MEASURES) + .updateColumn(newVarcharColumnDefBuilder().setColumnName("component_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).setIgnoreOracleUnit(true).build()) + .build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeProfileKeyNotNullOnActivities.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeProfileKeyNotNullOnActivities.java new file mode 100644 index 00000000000..19c9066588b --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeProfileKeyNotNullOnActivities.java @@ -0,0 +1,45 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.AlterColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class MakeProfileKeyNotNullOnActivities extends DdlChange { + + private static final String TABLE_ACTIVITIES = "activities"; + + public MakeProfileKeyNotNullOnActivities(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AlterColumnsBuilder(getDatabase().getDialect(), TABLE_ACTIVITIES) + .updateColumn(newVarcharColumnDefBuilder().setColumnName("profile_key").setLimit(255).setIsNullable(false).setIgnoreOracleUnit(true).build()) + .build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnNotNullOnSnapshots.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnNotNullOnSnapshots.java new file mode 100644 index 00000000000..b88339fe2d7 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnNotNullOnSnapshots.java @@ -0,0 +1,45 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.AlterColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.db.version.VarcharColumnDef.UUID_VARCHAR_SIZE; +import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class MakeUuidColumnNotNullOnSnapshots extends DdlChange { + + private static final String TABLE_SNAPSHOTS = "snapshots"; + + public MakeUuidColumnNotNullOnSnapshots(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AlterColumnsBuilder(getDatabase().getDialect(), TABLE_SNAPSHOTS) + .updateColumn(newVarcharColumnDefBuilder().setColumnName("uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).setIgnoreOracleUnit(true).build()) + .build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnsNotNullOnProjects.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnsNotNullOnProjects.java new file mode 100644 index 00000000000..f9929ca7988 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnsNotNullOnProjects.java @@ -0,0 +1,55 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.AlterColumnsBuilder; +import org.sonar.db.version.CreateIndexBuilder; +import org.sonar.db.version.VarcharColumnDef; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.db.version.VarcharColumnDef.UUID_VARCHAR_SIZE; +import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class MakeUuidColumnsNotNullOnProjects extends DdlChange { + + private static final String TABLE_PROJECTS = "projects"; + + public MakeUuidColumnsNotNullOnProjects(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + VarcharColumnDef rootUuid = newVarcharColumnDefBuilder().setColumnName("root_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).build(); + context.execute(new AlterColumnsBuilder(getDialect(), TABLE_PROJECTS) + .updateColumn(newVarcharColumnDefBuilder().setColumnName("uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).setIgnoreOracleUnit(true).build()) + .updateColumn(rootUuid) + .build()); + + context.execute(new CreateIndexBuilder(getDialect()) + .setTable(TABLE_PROJECTS) + .setName("projects_root_uuid") + .addColumn(rootUuid) + .build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnsNotNullOnResourceIndex.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnsNotNullOnResourceIndex.java new file mode 100644 index 00000000000..5954af2ab11 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnsNotNullOnResourceIndex.java @@ -0,0 +1,64 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.AlterColumnsBuilder; +import org.sonar.db.version.CreateIndexBuilder; +import org.sonar.db.version.VarcharColumnDef; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.db.version.VarcharColumnDef.UUID_VARCHAR_SIZE; +import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class MakeUuidColumnsNotNullOnResourceIndex extends DdlChange { + + private static final String TABLE_RESOURCE_INDEX = "resource_index"; + + public MakeUuidColumnsNotNullOnResourceIndex(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + VarcharColumnDef componentUuid = newUuidColumn("component_uuid"); + context.execute(new AlterColumnsBuilder(getDialect(), TABLE_RESOURCE_INDEX) + .updateColumn(componentUuid) + .updateColumn(newUuidColumn("root_component_uuid")) + .build()); + + context.execute(new CreateIndexBuilder(getDialect()) + .setTable(TABLE_RESOURCE_INDEX) + .setName("resource_index_component") + .addColumn(componentUuid) + .build()); + } + + private static VarcharColumnDef newUuidColumn(String columnName) { + return newVarcharColumnDefBuilder() + .setColumnName(columnName) + .setLimit(UUID_VARCHAR_SIZE) + .setIsNullable(false) + .setIgnoreOracleUnit(true) + .build(); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidPathColumnNotNullOnProjects.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidPathColumnNotNullOnProjects.java new file mode 100644 index 00000000000..412054e489e --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidPathColumnNotNullOnProjects.java @@ -0,0 +1,44 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.AlterColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class MakeUuidPathColumnNotNullOnProjects extends DdlChange { + + private static final String TABLE_PROJECTS = "projects"; + + public MakeUuidPathColumnNotNullOnProjects(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AlterColumnsBuilder(getDialect(), TABLE_PROJECTS) + .updateColumn(newVarcharColumnDefBuilder().setColumnName("uuid_path").setLimit(1500).setIsNullable(false).setIgnoreOracleUnit(true).build()) + .build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/Migration1223.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/Migration1223.java new file mode 100644 index 00000000000..f2385a69cfd --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/Migration1223.java @@ -0,0 +1,43 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.server.platform.db.migration.step.MigrationStep; + +/** + * This migration step is a substitute for the Ruby migration file which called two java migrations: + * {@link FixProjectUuidOfDeveloperProjects} and {@link CleanUsurperRootComponents}. + */ +public class Migration1223 implements MigrationStep { + private final FixProjectUuidOfDeveloperProjects projectUuidOfDeveloperProjects; + private final CleanUsurperRootComponents cleanUsurperRootComponents; + + public Migration1223(FixProjectUuidOfDeveloperProjects projectUuidOfDeveloperProjects, CleanUsurperRootComponents cleanUsurperRootComponents) { + this.projectUuidOfDeveloperProjects = projectUuidOfDeveloperProjects; + this.cleanUsurperRootComponents = cleanUsurperRootComponents; + } + + @Override + public void execute() throws SQLException { + projectUuidOfDeveloperProjects.execute(); + cleanUsurperRootComponents.execute(); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidColumnOnCeActivity.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidColumnOnCeActivity.java new file mode 100644 index 00000000000..ab09e587eea --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidColumnOnCeActivity.java @@ -0,0 +1,54 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.MassUpdate; +import org.sonar.db.version.Select; +import org.sonar.db.version.SqlStatement; +import org.sonar.server.platform.db.migration.step.DataChange; + +public class PopulateAnalysisUuidColumnOnCeActivity extends DataChange { + + public PopulateAnalysisUuidColumnOnCeActivity(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + massUpdate.select("SELECT a.id, s.uuid from ce_activity a inner join snapshots s on s.id=a.snapshot_id where a.snapshot_id is not null and a.analysis_uuid is null"); + massUpdate.update("UPDATE ce_activity SET analysis_uuid=? WHERE id=?"); + massUpdate.rowPluralName("ce_activity"); + massUpdate.execute(PopulateAnalysisUuidColumnOnCeActivity::handle); + } + + private static boolean handle(Select.Row row, SqlStatement update) throws SQLException { + long id = row.getLong(1); + String analysisUuid = row.getString(2); + + update.setString(1, analysisUuid); + update.setLong(2, id); + + return true; + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnEvents.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnEvents.java new file mode 100644 index 00000000000..17cf6102e02 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnEvents.java @@ -0,0 +1,55 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.MassUpdate; +import org.sonar.db.version.Select; +import org.sonar.db.version.SqlStatement; +import org.sonar.server.platform.db.migration.step.DataChange; + +public class PopulateAnalysisUuidOnEvents extends DataChange { + + public PopulateAnalysisUuidOnEvents(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + massUpdate.select("SELECT distinct e.snapshot_id, s.uuid from events e" + + " inner join snapshots s on s.id=e.snapshot_id and s.scope = 'PRJ' and s.qualifier in ('TRK', 'DEV', 'VW')" + + " where e.snapshot_id is not null and e.analysis_uuid is null"); + massUpdate.update("UPDATE events SET analysis_uuid=? WHERE snapshot_id=? and analysis_uuid is null"); + massUpdate.rowPluralName("analysis uuid of root component events"); + massUpdate.execute(PopulateAnalysisUuidOnEvents::handle); + } + + private static boolean handle(Select.Row row, SqlStatement update) throws SQLException { + long snapshotId = row.getLong(1); + String snapshotUuid = row.getString(2); + + update.setString(1, snapshotUuid); + update.setLong(2, snapshotId); + + return true; + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnMeasures.java new file mode 100644 index 00000000000..9f0d0d47ea0 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnMeasures.java @@ -0,0 +1,58 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.MassUpdate; +import org.sonar.db.version.Select; +import org.sonar.db.version.SqlStatement; +import org.sonar.server.platform.db.migration.step.DataChange; + +public class PopulateAnalysisUuidOnMeasures extends DataChange { + + public PopulateAnalysisUuidOnMeasures(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + massUpdate.select("select distinct m.snapshot_id, root_snapshots.uuid " + + "from project_measures m " + + "inner join snapshots s on m.snapshot_id=s.id " + + "inner join snapshots root_snapshots on s.root_snapshot_id=root_snapshots.id or (s.root_snapshot_id is null and s.id=root_snapshots.id) " + + "where m.analysis_uuid is null"); + massUpdate.update("update project_measures set analysis_uuid=? where snapshot_id=? and analysis_uuid is null"); + massUpdate.rowPluralName("measures"); + massUpdate.execute(PopulateAnalysisUuidOnMeasures::handle); + } + + private static boolean handle(Select.Row row, SqlStatement update) throws SQLException { + long snapshotId = row.getLong(1); + String analysisUuid = row.getString(2); + + update.setString(1, analysisUuid); + update.setLong(2, snapshotId); + + return true; + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndex.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndex.java new file mode 100644 index 00000000000..2061f671f95 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndex.java @@ -0,0 +1,81 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.MassUpdate; +import org.sonar.db.version.Select; +import org.sonar.db.version.SqlStatement; +import org.sonar.server.platform.db.migration.step.DataChange; + +public class PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndex extends DataChange { + + public PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndex(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + populateComponentUuid(context); + populateAnalysisUuid(context); + } + + private static void populateComponentUuid(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + massUpdate.select("select distinct di.snapshot_id, s.component_uuid from duplications_index di" + + " inner join snapshots s on s.id=di.snapshot_id" + + " where di.component_uuid is null"); + massUpdate.update("UPDATE duplications_index SET component_uuid=? WHERE snapshot_id=? and component_uuid is null"); + massUpdate.rowPluralName("component uuid of duplications_index entries"); + massUpdate.execute(PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndex::handleComponentUuid); + } + + private static boolean handleComponentUuid(Select.Row row, SqlStatement update) throws SQLException { + long snapshotId = row.getLong(1); + String componentUuid = row.getString(2); + + update.setString(1, componentUuid); + update.setLong(2, snapshotId); + + return true; + } + + private static void populateAnalysisUuid(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + massUpdate.select("select distinct di.project_snapshot_id, s.uuid from duplications_index di" + + " inner join snapshots s on s.id=di.project_snapshot_id" + + " where di.analysis_uuid is null"); + massUpdate.update("UPDATE duplications_index SET analysis_uuid=? WHERE project_snapshot_id=? and analysis_uuid is null"); + massUpdate.rowPluralName("analysis uuid of duplications_index entries"); + massUpdate.execute(PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndex::handleAnalysisUuid); + } + + private static boolean handleAnalysisUuid(Select.Row row, SqlStatement update) throws SQLException { + long projectSnapshotId = row.getLong(1); + String snapshotUuid = row.getString(2); + + update.setString(1, snapshotUuid); + update.setLong(2, projectSnapshotId); + + return true; + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidColumnsOfSnapshots.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidColumnsOfSnapshots.java new file mode 100644 index 00000000000..97d5532e0a3 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidColumnsOfSnapshots.java @@ -0,0 +1,85 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import java.util.HashMap; +import java.util.Map; +import org.sonar.db.Database; +import org.sonar.db.version.MassUpdate; +import org.sonar.db.version.Select; +import org.sonar.db.version.SqlStatement; +import org.sonar.server.platform.db.migration.step.DataChange; + +public class PopulateComponentUuidColumnsOfSnapshots extends DataChange { + + public PopulateComponentUuidColumnsOfSnapshots(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + Map<Long, String> componentUuidById = buildComponentUuidMap(context); + if (componentUuidById.isEmpty()) { + return; + } + + populateUuidColumns(context, componentUuidById); + } + + private static Map<Long, String> buildComponentUuidMap(Context context) throws SQLException { + Map<Long, String> componentUuidById = new HashMap<>(); + context.prepareSelect("select distinct p.id, p.uuid from projects p" + + " join snapshots sn1 on sn1.project_id = p.id and sn1.component_uuid is null") + .scroll(row -> componentUuidById.put(row.getLong(1), row.getString(2))); + context.prepareSelect("select distinct p.id, p.uuid from projects p" + + " join snapshots sn2 on sn2.root_project_id = p.id and sn2.root_component_uuid is null") + .scroll(row -> componentUuidById.put(row.getLong(1), row.getString(2))); + return componentUuidById; + } + + private static void populateUuidColumns(Context context, Map<Long, String> componentUuidById) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + massUpdate.select("SELECT sn.id, sn.project_id, sn.root_project_id from snapshots sn where sn.component_uuid is null or sn.root_component_uuid is null"); + massUpdate.update("UPDATE snapshots SET component_uuid=?, root_component_uuid=? WHERE id=?"); + massUpdate.rowPluralName("snapshots"); + massUpdate.execute((row, update) -> handle(componentUuidById, row, update)); + } + + private static boolean handle(Map<Long, String> componentUuidById, Select.Row row, SqlStatement update) throws SQLException { + long id = row.getLong(1); + long componentId = row.getLong(2); + long rootProjectId = row.getLong(3); + + String componentUuid = componentUuidById.get(componentId); + String rootComponentUuid = componentUuidById.get(rootProjectId); + + if (componentUuid == null && rootComponentUuid == null) { + return false; + } + + update.setString(1, componentUuid); + update.setString(2, rootComponentUuid); + update.setLong(3, id); + + return true; + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidOfMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidOfMeasures.java new file mode 100644 index 00000000000..a0a1075eac7 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidOfMeasures.java @@ -0,0 +1,54 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.MassUpdate; +import org.sonar.db.version.Select; +import org.sonar.db.version.SqlStatement; +import org.sonar.server.platform.db.migration.step.DataChange; + +public class PopulateComponentUuidOfMeasures extends DataChange { + + public PopulateComponentUuidOfMeasures(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + massUpdate.select("select distinct pm.snapshot_id, s.component_uuid from project_measures pm inner join snapshots s on s.id=pm.snapshot_id where pm.component_uuid is null"); + massUpdate.update("UPDATE project_measures SET component_uuid=? WHERE snapshot_id=? and component_uuid is null"); + massUpdate.rowPluralName("measures"); + massUpdate.execute(this::handle); + } + + public boolean handle(Select.Row row, SqlStatement update) throws SQLException { + long snapshotId = row.getLong(1); + String componentUuid = row.getString(2); + + update.setString(1, componentUuid); + update.setLong(2, snapshotId); + + return true; + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateLastUsedColumnOfRulesProfiles.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateLastUsedColumnOfRulesProfiles.java new file mode 100644 index 00000000000..d245196aaa5 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateLastUsedColumnOfRulesProfiles.java @@ -0,0 +1,91 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import java.util.HashMap; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import org.sonar.db.Database; +import org.sonar.db.version.MassUpdate; +import org.sonar.db.version.Select; +import org.sonar.db.version.SqlStatement; +import org.sonar.server.platform.db.migration.step.DataChange; + +public class PopulateLastUsedColumnOfRulesProfiles extends DataChange { + + private static final Pattern PATTERN_QP_KEY = Pattern.compile("\"key\"\\s*:\\s*\"(.*?)\""); + + public PopulateLastUsedColumnOfRulesProfiles(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + Map<String, Long> lastAnalysisDatesByQualityProfileKey = buildQualityProfilesMap(context); + if (lastAnalysisDatesByQualityProfileKey.isEmpty()) { + return; + } + + populateLastUsedColumn(context, lastAnalysisDatesByQualityProfileKey); + } + + private static Map<String, Long> buildQualityProfilesMap(Context context) throws SQLException { + Map<String, Long> lastAnalysisDatesByQPKeys = new HashMap<>(); + + context.prepareSelect("select s.created_at, pm.text_value " + + "from project_measures pm " + + " inner join snapshots s on pm.snapshot_id = s.id " + + " inner join metrics m on pm.metric_id=m.id " + + "where s.islast=? " + + " and m.name='quality_profiles' " + + "order by s.created_at ") + .setBoolean(1, true) + .scroll(row -> { + long analysisDate = row.getLong(1); + String json = row.getString(2); + Matcher matcher = PATTERN_QP_KEY.matcher(json); + while (matcher.find()) { + lastAnalysisDatesByQPKeys.put(matcher.group(1), analysisDate); + } + }); + return lastAnalysisDatesByQPKeys; + } + + private static void populateLastUsedColumn(Context context, Map<String, Long> lastAnalysisDatesByQualityProfileKey) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + massUpdate.select("select id, kee from rules_profiles where last_used is null"); + massUpdate.update("update rules_profiles set last_used=? where id=?"); + massUpdate.rowPluralName("rules_profiles"); + massUpdate.execute((row, update) -> handle(lastAnalysisDatesByQualityProfileKey, row, update)); + } + + private static boolean handle(Map<String, Long> lastAnalysisDatesByQualityProfileKey, Select.Row row, SqlStatement update) throws SQLException { + int qualityProfileId = row.getInt(1); + String qualityProfileKey = row.getString(2); + + update.setLong(1, lastAnalysisDatesByQualityProfileKey.get(qualityProfileKey)); + update.setInt(2, qualityProfileId); + + return true; + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateProfileKeyOfActivities.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateProfileKeyOfActivities.java new file mode 100644 index 00000000000..c241b04f2a1 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateProfileKeyOfActivities.java @@ -0,0 +1,67 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import java.util.Map; +import org.sonar.api.utils.KeyValueFormat; +import org.sonar.db.Database; +import org.sonar.db.version.MassUpdate; +import org.sonar.db.version.Select; +import org.sonar.db.version.SqlStatement; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static org.apache.commons.lang.StringUtils.isBlank; + +public class PopulateProfileKeyOfActivities extends DataChange { + + public PopulateProfileKeyOfActivities(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + massUpdate.select("select id, data_field from activities where profile_key is null"); + massUpdate.update("update activities set profile_key=?, data_field=? where id=?"); + massUpdate.rowPluralName("activities"); + massUpdate.execute(PopulateProfileKeyOfActivities::handle); + + // SONAR-8534 delete orphans + context.prepareUpsert("delete from activities where profile_key is null") + .execute() + .commit(); + } + + private static boolean handle(Select.Row row, SqlStatement update) throws SQLException { + int id = row.getInt(1); + String data = row.getString(2); + Map<String, String> fields = KeyValueFormat.parse(data); + String profileKey = fields.remove("profileKey"); + if (isBlank(profileKey)) { + return false; + } + update.setString(1, profileKey); + update.setString(2, KeyValueFormat.format(fields)); + update.setInt(3, id); + return true; + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateUserUpdatedAtOfRulesProfiles.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateUserUpdatedAtOfRulesProfiles.java new file mode 100644 index 00000000000..747c9a601a7 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateUserUpdatedAtOfRulesProfiles.java @@ -0,0 +1,92 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import com.google.common.base.Throwables; +import java.sql.SQLException; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.annotation.CheckForNull; +import org.sonar.db.Database; +import org.sonar.db.version.MassUpdate; +import org.sonar.db.version.Select; +import org.sonar.db.version.SqlStatement; +import org.sonar.server.platform.db.migration.step.DataChange; + +public class PopulateUserUpdatedAtOfRulesProfiles extends DataChange { + + private static final String SQL_SELECT_PROFILES_NOT_UPDATED = "select kee from rules_profiles where user_updated_at is null"; + + public PopulateUserUpdatedAtOfRulesProfiles(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + Map<String, Long> userUpdatedAtByProfileKeys = buildUserUpdatedAtMap(context); + populateUserUpdatedAtColumn(context, userUpdatedAtByProfileKeys); + } + + private static Map<String, Long> buildUserUpdatedAtMap(Context context) throws SQLException { + Map<String, Long> lastAnalysisDatesByQPKeys = new HashMap<>(); + List<String> profileKeys = context.prepareSelect(SQL_SELECT_PROFILES_NOT_UPDATED).list(row -> row.getString(1)); + profileKeys.forEach(profileKey -> lastAnalysisDatesByQPKeys.put(profileKey, getUserUpdateAt(context, profileKey))); + + return lastAnalysisDatesByQPKeys; + } + + @CheckForNull + private static Long getUserUpdateAt(Context context, String profileKey) { + try { + return context.prepareSelect("select created_at as \"createdAt\" " + + "from activities " + + "where user_login is not null " + + " and profile_key=? " + + "order by created_at DESC ") + .setString(1, profileKey) + .get(row -> { + Date userUpdatedAt = row.getNullableDate(1); + return userUpdatedAt == null ? null : userUpdatedAt.getTime(); + }); + } catch (SQLException e) { + throw Throwables.propagate(e); + } + } + + private static void populateUserUpdatedAtColumn(Context context, Map<String, Long> userUpdatedAdByProfileKey) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + massUpdate.select(SQL_SELECT_PROFILES_NOT_UPDATED); + massUpdate.update("update rules_profiles set user_updated_at=? where kee=?"); + massUpdate.rowPluralName("quality profiles"); + massUpdate.execute((row, update) -> handle(userUpdatedAdByProfileKey, row, update)); + } + + private static boolean handle(Map<String, Long> userUpdatedAtByProfileKey, Select.Row row, SqlStatement update) throws SQLException { + String profileKey = row.getString(1); + + update.setLong(1, userUpdatedAtByProfileKey.get(profileKey)); + update.setString(2, profileKey); + + return true; + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnOnSnapshots.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnOnSnapshots.java new file mode 100644 index 00000000000..ad8de24bb88 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnOnSnapshots.java @@ -0,0 +1,55 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.core.util.UuidFactory; +import org.sonar.db.Database; +import org.sonar.db.version.MassUpdate; +import org.sonar.db.version.Select; +import org.sonar.db.version.SqlStatement; +import org.sonar.server.platform.db.migration.step.DataChange; + +public class PopulateUuidColumnOnSnapshots extends DataChange { + + private final UuidFactory uuidFactory; + + public PopulateUuidColumnOnSnapshots(Database db, UuidFactory uuidFactory) { + super(db); + this.uuidFactory = uuidFactory; + } + + @Override + public void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + massUpdate.select("SELECT s.id from snapshots s where s.uuid is null"); + massUpdate.update("UPDATE snapshots SET uuid=? WHERE id=?"); + massUpdate.rowPluralName("snapshots"); + massUpdate.execute(this::handle); + } + + private boolean handle(Select.Row row, SqlStatement update) throws SQLException { + long id = row.getLong(1); + update.setString(1, uuidFactory.create()); + update.setLong(2, id); + return true; + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnsOfProjects.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnsOfProjects.java new file mode 100644 index 00000000000..d2e4baea0e1 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnsOfProjects.java @@ -0,0 +1,167 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import java.util.HashMap; +import java.util.Map; +import org.sonar.api.utils.log.Logger; +import org.sonar.api.utils.log.Loggers; +import org.sonar.db.Database; +import org.sonar.db.version.MassUpdate; +import org.sonar.db.version.Select; +import org.sonar.db.version.SqlStatement; +import org.sonar.server.platform.db.migration.step.DataChange; + +public class PopulateUuidColumnsOfProjects extends DataChange { + private static final Logger LOG = Loggers.get(PopulateUuidColumnsOfProjects.class); + + public PopulateUuidColumnsOfProjects(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + + Map<Long, String> componentUuidById = buildComponentUuidMap(context); + if (componentUuidById.isEmpty()) { + return; + } + + populateRootUuidColumnForRoots(context); + populateRootUuidColumnForSubnodes(context, componentUuidById); + populateCopyComponentUuidColumn(context, componentUuidById); + populatePersonUuidColumn(context, componentUuidById); + } + + private static Map<Long, String> buildComponentUuidMap(Context context) throws SQLException { + Map<Long, String> componentUuidById = new HashMap<>(); + // rootId for root nodes (ie. column root_id is null) + context.prepareSelect("select distinct p1.id, p1.uuid from projects p1" + + " where p1.root_id is null and p1.root_uuid is null") + .scroll(row -> componentUuidById.put(row.getLong(1), row.getString(2))); + // rootId for other nodes (ie. column root_id is not null) + context.prepareSelect("select distinct p1.id, p1.uuid from projects p1" + + " join projects p2 on p1.id = p2.root_id" + + " where p2.root_uuid is null") + .scroll(row -> componentUuidById.put(row.getLong(1), row.getString(2))); + // copyResourceId + context.prepareSelect("select distinct p1.id, p1.uuid from projects p1" + + " join projects p2 on p1.id = p2.copy_resource_id" + + " where p2.copy_resource_id is not null and p2.copy_component_uuid is null") + .scroll(row -> componentUuidById.put(row.getLong(1), row.getString(2))); + // person_id + context.prepareSelect("select distinct p1.id, p1.uuid from projects p1" + + " join projects p2 on p1.id = p2.person_id" + + " where p2.person_id is not null and p2.developer_uuid is null") + .scroll(row -> componentUuidById.put(row.getLong(1), row.getString(2))); + return componentUuidById; + } + + private static void populateRootUuidColumnForRoots(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + massUpdate.select("SELECT distinct p.id from projects p where p.root_id is null and p.root_uuid is null"); + massUpdate.update("UPDATE projects SET root_uuid=uuid WHERE id=? and root_id is null and root_uuid is null"); + massUpdate.rowPluralName("root uuid of root components"); + massUpdate.execute(PopulateUuidColumnsOfProjects::handleRootIdUpdateForRootNodes); + } + + private static boolean handleRootIdUpdateForRootNodes(Select.Row row, SqlStatement update) throws SQLException { + long rootId = row.getLong(1); + + update.setLong(1, rootId); + + return true; + } + + private static void populateRootUuidColumnForSubnodes(Context context, Map<Long, String> componentUuidById) throws SQLException { + // update all rows with specific root_id which have no root_uuid yet in a single update + // this will be efficient as root_id is indexed + MassUpdate massUpdate = context.prepareMassUpdate(); + massUpdate.select("SELECT distinct p.root_id from projects p where p.root_id is not null and p.root_uuid is null"); + massUpdate.update("UPDATE projects SET root_uuid=? WHERE root_id=? and root_uuid is null"); + massUpdate.rowPluralName("root uuid of non-root components"); + massUpdate.execute((row, update) -> handleRootIdUpdateForSubNodes(componentUuidById, row, update)); + } + + private static boolean handleRootIdUpdateForSubNodes(Map<Long, String> componentUuidById, Select.Row row, SqlStatement update) throws SQLException { + long rootId = row.getLong(1); + String rootUuid = componentUuidById.get(rootId); + + if (rootUuid == null) { + LOG.trace("No UUID found for rootId={}", rootUuid); + return false; + } + + update.setString(1, rootUuid); + update.setLong(2, rootId); + + return true; + } + + private static void populateCopyComponentUuidColumn(Context context, Map<Long, String> componentUuidById) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + massUpdate.select("SELECT p.id, p.copy_resource_id from projects p where p.copy_resource_id is not null and p.copy_component_uuid is null"); + massUpdate.update("UPDATE projects SET copy_component_uuid=? WHERE id=?"); + massUpdate.rowPluralName("copy component uuid of components"); + massUpdate.execute((row, update) -> handleCopyComponentUuidUpdate(componentUuidById, row, update)); + } + + private static boolean handleCopyComponentUuidUpdate(Map<Long, String> componentUuidById, Select.Row row, SqlStatement update) throws SQLException { + long id = row.getLong(1); + long copyResourceId = row.getLong(2); + + String copyComponentUuid = componentUuidById.get(copyResourceId); + if (copyComponentUuid == null) { + LOG.trace("No UUID found for copyResourceId={}", copyResourceId); + return false; + } + + update.setString(1, copyComponentUuid); + update.setLong(2, id); + + return true; + } + + private static void populatePersonUuidColumn(Context context, Map<Long, String> componentUuidById) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + massUpdate.select("SELECT p.id, p.person_id from projects p where p.person_id is not null and p.developer_uuid is null"); + massUpdate.update("UPDATE projects SET developer_uuid=? WHERE id=?"); + massUpdate.rowPluralName("person uuid of components"); + massUpdate.execute((row, update) -> handleDeveloperUuuidUpdate(componentUuidById, row, update)); + } + + private static boolean handleDeveloperUuuidUpdate(Map<Long, String> componentUuidById, Select.Row row, SqlStatement update) throws SQLException { + long id = row.getLong(1); + long personId = row.getLong(2); + + String developerUuid = componentUuidById.get(personId); + if (developerUuid == null) { + LOG.trace("No UUID found for personId={}", personId); + return false; + } + + update.setString(1, developerUuid); + update.setLong(2, id); + + return true; + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnsOfResourceIndex.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnsOfResourceIndex.java new file mode 100644 index 00000000000..96f5f7a5d88 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnsOfResourceIndex.java @@ -0,0 +1,85 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import java.util.HashMap; +import java.util.Map; +import org.sonar.db.Database; +import org.sonar.db.version.MassUpdate; +import org.sonar.db.version.Select; +import org.sonar.db.version.SqlStatement; +import org.sonar.server.platform.db.migration.step.DataChange; + +public class PopulateUuidColumnsOfResourceIndex extends DataChange { + + public PopulateUuidColumnsOfResourceIndex(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + Map<Long, String> componentUuidById = buildComponentUuidMap(context); + if (componentUuidById.isEmpty()) { + return; + } + + populateUuidColumns(context, componentUuidById); + } + + private static Map<Long, String> buildComponentUuidMap(Context context) throws SQLException { + Map<Long, String> componentUuidById = new HashMap<>(); + context.prepareSelect("select distinct p.id, p.uuid from projects p" + + " join resource_index ri1 on ri1.resource_id = p.id and ri1.component_uuid is null") + .scroll(row -> componentUuidById.put(row.getLong(1), row.getString(2))); + context.prepareSelect("select distinct p.id, p.uuid from projects p" + + " join resource_index ri2 on ri2.root_project_id = p.id and ri2.root_component_uuid is null") + .scroll(row -> componentUuidById.put(row.getLong(1), row.getString(2))); + return componentUuidById; + } + + private void populateUuidColumns(Context context, Map<Long, String> componentUuidById) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + massUpdate.select("SELECT ri.id, ri.resource_id, ri.root_project_id from resource_index ri where ri.component_uuid is null or ri.root_component_uuid is null"); + massUpdate.update("UPDATE resource_index SET component_uuid=?, root_component_uuid=? WHERE id=?"); + massUpdate.rowPluralName("resource index entries"); + massUpdate.execute((row, update) -> this.handle(componentUuidById, row, update)); + } + + public boolean handle(Map<Long, String> componentUuidById, Select.Row row, SqlStatement update) throws SQLException { + long id = row.getLong(1); + long componentId = row.getLong(2); + long rootProjectId = row.getLong(3); + + String componentUuid = componentUuidById.get(componentId); + String rootComponentUuid = componentUuidById.get(rootProjectId); + + if (componentUuid == null && rootComponentUuid == null) { + return false; + } + + update.setString(1, componentUuid); + update.setString(2, rootComponentUuid); + update.setLong(3, id); + + return true; + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidPathColumnOnProjects.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidPathColumnOnProjects.java new file mode 100644 index 00000000000..6fdb03d80dd --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidPathColumnOnProjects.java @@ -0,0 +1,169 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import com.google.common.base.Joiner; +import com.google.common.base.Splitter; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import javax.annotation.Nullable; +import org.sonar.api.utils.log.Logger; +import org.sonar.api.utils.log.Loggers; +import org.sonar.db.Database; +import org.sonar.db.version.MassUpdate; +import org.sonar.db.version.Select; +import org.sonar.db.version.SqlStatement; +import org.sonar.server.platform.db.migration.step.DataChange; + +import static java.util.stream.Collectors.toCollection; + +public class PopulateUuidPathColumnOnProjects extends DataChange { + + private static final Logger LOG = Loggers.get(PopulateUuidPathColumnOnProjects.class); + private static final Joiner PATH_JOINER = Joiner.on('.'); + private static final Splitter PATH_SPLITTER = Splitter.on('.').omitEmptyStrings(); + private static final String PATH_SEPARATOR = "."; + private static final String ROOT_PATH = PATH_SEPARATOR; + + public PopulateUuidPathColumnOnProjects(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + // group upgrades by tree of component + List<String> rootComponentUuids = context + .prepareSelect("select distinct project_uuid from projects where uuid_path is null") + .list(row -> row.getString(1)); + for (String rootUuid : rootComponentUuids) { + handleRoot(rootUuid, context); + } + + handleOrphans(context); + } + + private static void handleRoot(String rootComponentUuid, Context context) throws SQLException { + Relations relations = new Relations(); + context + .prepareSelect("select s.id, s.path, s.component_uuid from snapshots s where s.root_component_uuid=? and s.islast=?") + .setString(1, rootComponentUuid) + .setBoolean(2, true) + .scroll(row -> { + long snapshotId = row.getLong(1); + String snapshotPath = row.getString(2); + String componentUuid = row.getString(3); + relations.add(new Snapshot(snapshotId, snapshotPath, componentUuid)); + }); + + MassUpdate massUpdate = context.prepareMassUpdate(); + massUpdate.select("select p.uuid, p.project_uuid from projects p where p.project_uuid=? and p.uuid_path is null").setString(1, rootComponentUuid); + massUpdate.update("update projects set uuid_path=? where uuid=? and uuid_path is null"); + massUpdate.rowPluralName("components in tree of " + rootComponentUuid); + massUpdate.execute((row, update) -> handleComponent(relations, row, update)); + } + + private static void handleOrphans(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + massUpdate.select("select uuid, project_uuid from projects where uuid_path is null"); + massUpdate.update("update projects set uuid_path=? where uuid=? and uuid_path is null"); + massUpdate.rowPluralName("orphan components"); + massUpdate.execute((row, update, updateIndex) -> { + String uuid = row.getString(1); + String rootUuid = row.getString(2); + String path = uuid.equals(rootUuid) ? ROOT_PATH : (PATH_SEPARATOR + rootUuid + PATH_SEPARATOR); + update.setString(1, path); + update.setString(2, uuid); + return true; + }); + } + + private static boolean handleComponent(Relations relations, Select.Row row, SqlStatement update) throws SQLException { + String componentUuid = row.getString(1); + String rootComponentUuid = row.getString(2); + + if (componentUuid.equals(rootComponentUuid)) { + // Root component, no need to use the table SNAPSHOTS. + // Moreover it allows to support provisioned projects (zero analysis) + update.setString(1, PATH_SEPARATOR); + update.setString(2, componentUuid); + return true; + } + + Snapshot snapshot = relations.snapshotsByComponentUuid.get(componentUuid); + if (snapshot == null) { + LOG.trace("No UUID found for component UUID={}", componentUuid); + return false; + } + + List<String> componentUuidPath = Arrays.stream(snapshot.snapshotPath) + .mapToObj(relations.snapshotsById::get) + .filter(Objects::nonNull) + .map(s -> s.componentUuid) + .collect(toCollection(ArrayList::new)); + if (componentUuidPath.size() != snapshot.snapshotPath.length) { + LOG.trace("Some component UUIDs not found for snapshots [{}]", snapshot.snapshotPath); + return false; + } + + update.setString(1, PATH_SEPARATOR + PATH_JOINER.join(componentUuidPath) + PATH_SEPARATOR); + update.setString(2, componentUuid); + return true; + } + + private static final class Relations { + private final Map<String, Snapshot> snapshotsByComponentUuid = new HashMap<>(); + private final Map<Long, Snapshot> snapshotsById = new HashMap<>(); + + void add(Snapshot snapshot) { + snapshotsByComponentUuid.put(snapshot.componentUuid, snapshot); + snapshotsById.put(snapshot.id, snapshot); + } + } + + private static final class Snapshot { + private static final long[] EMPTY_PATH = new long[0]; + private final long id; + private final long[] snapshotPath; + private final String componentUuid; + + public Snapshot(long id, String snapshotPath, String componentUuid) { + this.id = id; + this.snapshotPath = parsePath(snapshotPath); + this.componentUuid = componentUuid; + } + + // inputs: null (on Oracle), "", "1." or "1.2.3." + private static long[] parsePath(@Nullable String snapshotPath) { + if (snapshotPath == null) { + return EMPTY_PATH; + } + return PATH_SPLITTER + .splitToList(snapshotPath) + .stream() + .mapToLong(Long::parseLong) + .toArray(); + } + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/RecreateIndexProjectsUuidFromProjects.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/RecreateIndexProjectsUuidFromProjects.java new file mode 100644 index 00000000000..1741e273004 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/RecreateIndexProjectsUuidFromProjects.java @@ -0,0 +1,43 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.CreateIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class RecreateIndexProjectsUuidFromProjects extends DdlChange { + + public RecreateIndexProjectsUuidFromProjects(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new CreateIndexBuilder(getDialect()) + .setTable("projects") + .setName("projects_uuid") + .addColumn(newVarcharColumnDefBuilder().setColumnName("uuid").setLimit(50).setIgnoreOracleUnit(true).build()) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/RemoveUsersPasswordWhenNotLocal.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/RemoveUsersPasswordWhenNotLocal.java new file mode 100644 index 00000000000..edca86281ae --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/RemoveUsersPasswordWhenNotLocal.java @@ -0,0 +1,51 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.api.utils.System2; +import org.sonar.db.Database; +import org.sonar.db.version.MassUpdate; +import org.sonar.server.platform.db.migration.step.DataChange; + +public class RemoveUsersPasswordWhenNotLocal extends DataChange { + + private final System2 system2; + + public RemoveUsersPasswordWhenNotLocal(Database db, System2 system2) { + super(db); + this.system2 = system2; + } + + @Override + public void execute(Context context) throws SQLException { + long now = system2.now(); + MassUpdate massUpdate = context.prepareMassUpdate(); + massUpdate.select("SELECT u.id FROM users u WHERE (u.crypted_password IS NOT NULL OR u.salt IS NOT NULL) AND u.user_local=?").setBoolean(1, false); + massUpdate.update("UPDATE users SET crypted_password=null, salt=null, updated_at=? WHERE id=?"); + massUpdate.rowPluralName("none local users with password"); + massUpdate.execute((row, update) -> { + update.setLong(1, now); + update.setLong(2, row.getLong(1)); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/TemporarilyDropIndexOfAnalysisUuidOnMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/TemporarilyDropIndexOfAnalysisUuidOnMeasures.java new file mode 100644 index 00000000000..d54450e323a --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/TemporarilyDropIndexOfAnalysisUuidOnMeasures.java @@ -0,0 +1,44 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.DropIndexBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +/** + * the index must be dropped for the compatibility of migration 1270 + * with MSSQL + */ +public class TemporarilyDropIndexOfAnalysisUuidOnMeasures extends DdlChange { + + public TemporarilyDropIndexOfAnalysisUuidOnMeasures(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new DropIndexBuilder(getDialect()) + .setTable("project_measures") + .setName("measures_analysis_metric") + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/package-info.java new file mode 100644 index 00000000000..7f218037a70 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v60/package-info.java @@ -0,0 +1,23 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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. + */ +@ParametersAreNonnullByDefault +package org.sonar.server.platform.db.migration.version.v60; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/DbVersionModuleTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/DbVersionModuleTest.java index 18d8f2e5c1c..65795e2c0c4 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/DbVersionModuleTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/DbVersionModuleTest.java @@ -36,7 +36,7 @@ public class DbVersionModuleTest { underTest.configure(container); assertThat(container.getPicoContainer().getComponentAdapters()) - .hasSize(COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER + 3); + .hasSize(COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER + 4); } } diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToCeActivityTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToCeActivityTest.java new file mode 100644 index 00000000000..0e8c0326a9b --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToCeActivityTest.java @@ -0,0 +1,84 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.sonar.api.utils.System2; +import org.sonar.db.DbTester; + +import static java.lang.String.valueOf; + +public class AddAnalysisUuidColumnToCeActivityTest { + + private static final long A_DATE = 123_456L; + + @Rule + public DbTester db = DbTester.createForSchema(System2.INSTANCE, AddAnalysisUuidColumnToCeActivityTest.class, "old_ce_activity.sql"); + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + private AddAnalysisUuidColumnToCeActivity underTest = new AddAnalysisUuidColumnToCeActivity(db.database()); + + @Test + public void migration_adds_column_to_empty_table() throws SQLException { + underTest.execute(); + + verifyAddedColumns(); + } + + @Test + public void migration_adds_column_to_populated_table() throws SQLException { + for (int i = 0; i < 9; i++) { + db.executeInsert( + "ce_activity", + "uuid", valueOf(i), + "task_type", "REPORT", + "status", "SUCCESS", + "is_last", valueOf(true), + "is_last_key", valueOf(i + 100), + "created_at", valueOf(A_DATE), + "updated_at", valueOf(A_DATE), + "submitted_at", valueOf(A_DATE)); + } + db.commit(); + + underTest.execute(); + + verifyAddedColumns(); + } + + @Test + public void migration_is_not_reentrant() throws SQLException { + underTest.execute(); + + expectedException.expect(IllegalStateException.class); + expectedException.expectMessage("Fail to execute "); + underTest.execute(); + } + + private void verifyAddedColumns() { + db.assertColumnDefinition("ce_activity", "analysis_uuid", Types.VARCHAR, 50, true); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToEventsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToEventsTest.java new file mode 100644 index 00000000000..90283a688c4 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToEventsTest.java @@ -0,0 +1,79 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.sonar.api.utils.System2; +import org.sonar.db.DbTester; + +import static java.lang.String.valueOf; + +public class AddAnalysisUuidColumnToEventsTest { + + private static final String TABLE_EVENTS = "events"; + + @Rule + public DbTester db = DbTester.createForSchema(System2.INSTANCE, AddAnalysisUuidColumnToEventsTest.class, "events_before_6-0.sql"); + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + private AddAnalysisUuidColumnToEvents underTest = new AddAnalysisUuidColumnToEvents(db.database()); + + @Test + public void migration_adds_columns_to_empty_table() throws SQLException { + underTest.execute(); + + verifyAddedColumns(); + } + + @Test + public void migration_adds_columns_to_populated_table() throws SQLException { + for (int i = 0; i < 9; i++) { + db.executeInsert( + TABLE_EVENTS, + "NAME", valueOf(i), + "EVENT_DATE", valueOf(1 + 100), + "CREATED_AT", valueOf(1 + 300)); + } + db.commit(); + + underTest.execute(); + + verifyAddedColumns(); + } + + private void verifyAddedColumns() { + db.assertColumnDefinition(TABLE_EVENTS, "analysis_uuid", Types.VARCHAR, 50, true); + } + + @Test + public void migration_is_not_reentrant() throws SQLException { + underTest.execute(); + + expectedException.expect(IllegalStateException.class); + expectedException.expectMessage("Fail to execute "); + underTest.execute(); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToMeasuresTest.java new file mode 100644 index 00000000000..0980f7e2ae0 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToMeasuresTest.java @@ -0,0 +1,80 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.sonar.api.utils.System2; +import org.sonar.db.DbTester; + +import static java.lang.String.valueOf; + +public class AddAnalysisUuidColumnToMeasuresTest { + + private static final String TABLE = "project_measures"; + + @Rule + public DbTester db = DbTester.createForSchema(System2.INSTANCE, AddAnalysisUuidColumnToMeasuresTest.class, "old_measures.sql"); + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + private AddAnalysisUuidColumnToMeasures underTest = new AddAnalysisUuidColumnToMeasures(db.database()); + + @Test + public void migration_adds_column_to_empty_table() throws SQLException { + underTest.execute(); + + verifyAddedColumn(); + } + + @Test + public void migration_adds_column_to_populated_table() throws SQLException { + for (int i = 0; i < 9; i++) { + db.executeInsert( + TABLE, + "metric_id", valueOf(i), + "value", valueOf(i + 10), + "snapshot_id", valueOf(i + 100), + "component_uuid", valueOf(i + 1_000)); + } + db.commit(); + + underTest.execute(); + + verifyAddedColumn(); + } + + @Test + public void migration_is_not_reentrant() throws SQLException { + underTest.execute(); + + expectedException.expect(IllegalStateException.class); + expectedException.expectMessage("Fail to execute "); + underTest.execute(); + } + + private void verifyAddedColumn() { + db.assertColumnDefinition(TABLE, "analysis_uuid", Types.VARCHAR, 50, true); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddBColumnsToProjectsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddBColumnsToProjectsTest.java new file mode 100644 index 00000000000..71bc3a03dcc --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddBColumnsToProjectsTest.java @@ -0,0 +1,89 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.sonar.api.utils.System2; +import org.sonar.db.DbTester; + +import static java.lang.String.valueOf; + +public class AddBColumnsToProjectsTest { + + private static final String TABLE = "projects"; + + @Rule + public DbTester db = DbTester.createForSchema(System2.INSTANCE, AddBColumnsToProjectsTest.class, "old_projects.sql"); + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + private AddBColumnsToProjects underTest = new AddBColumnsToProjects(db.database()); + + @Test + public void migration_adds_column_to_empty_table() throws SQLException { + underTest.execute(); + + verifyAddedColumns(); + } + + @Test + public void migration_adds_columns_to_populated_table() throws SQLException { + for (int i = 0; i < 9; i++) { + db.executeInsert( + TABLE, + "uuid", valueOf(i), + "kee", valueOf(i + 10), + "root_uuid", valueOf(i + 20), + "uuid_path", valueOf(i + 30)); + } + db.commit(); + + underTest.execute(); + + verifyAddedColumns(); + } + + @Test + public void migration_is_not_reentrant() throws SQLException { + underTest.execute(); + + expectedException.expect(IllegalStateException.class); + expectedException.expectMessage("Fail to execute "); + underTest.execute(); + } + + private void verifyAddedColumns() { + db.assertColumnDefinition(TABLE, "b_changed", Types.BOOLEAN, null, true); + db.assertColumnDefinition(TABLE, "b_copy_component_uuid", Types.VARCHAR, 50, true); + db.assertColumnDefinition(TABLE, "b_description", Types.VARCHAR, 2000, true); + db.assertColumnDefinition(TABLE, "b_enabled", Types.BOOLEAN, null, true); + db.assertColumnDefinition(TABLE, "b_language", Types.VARCHAR, 20, true); + db.assertColumnDefinition(TABLE, "b_long_name", Types.VARCHAR, 500, true); + db.assertColumnDefinition(TABLE, "b_module_uuid", Types.VARCHAR, 50, true); + db.assertColumnDefinition(TABLE, "b_module_uuid_path", Types.VARCHAR, 1500, true); + db.assertColumnDefinition(TABLE, "b_name", Types.VARCHAR, 500, true); + db.assertColumnDefinition(TABLE, "b_path", Types.VARCHAR, 2000, true); + db.assertColumnDefinition(TABLE, "b_qualifier", Types.VARCHAR, 10, true); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndexTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndexTest.java new file mode 100644 index 00000000000..dc7fb5c4aa3 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndexTest.java @@ -0,0 +1,85 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.sonar.api.utils.System2; +import org.sonar.db.DbTester; + +import static java.lang.String.valueOf; + +public class AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndexTest { + + private static final String TABLE = "duplications_index"; + + @Rule + public DbTester db = DbTester.createForSchema(System2.INSTANCE, AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndexTest.class, + "duplications_index_5.6.sql"); + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + private AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndex underTest = new AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndex(db.database()); + + @Test + public void migration_adds_column_to_empty_table() throws SQLException { + underTest.execute(); + + verifyAddedColumns(); + } + + @Test + public void migration_adds_column_to_populated_table() throws SQLException { + for (int i = 0; i < 9; i++) { + db.executeInsert( + TABLE, + "ID", valueOf(i), + "PROJECT_SNAPSHOT_ID", valueOf(10 + i), + "SNAPSHOT_ID", valueOf(20 + i), + "HASH", "some_hash_" + i, + "INDEX_IN_FILE", "2", + "START_LINE", "3", + "END_LINE", "4"); + } + db.commit(); + + underTest.execute(); + + verifyAddedColumns(); + } + + @Test + public void migration_is_not_reentrant() throws SQLException { + underTest.execute(); + + expectedException.expect(IllegalStateException.class); + expectedException.expectMessage("Fail to execute "); + underTest.execute(); + } + + private void verifyAddedColumns() { + db.assertColumnDefinition(TABLE, "component_uuid", Types.VARCHAR, 50, true); + db.assertColumnDefinition(TABLE, "analysis_uuid", Types.VARCHAR, 50, true); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnToMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnToMeasuresTest.java new file mode 100644 index 00000000000..da5fb6b95e6 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnToMeasuresTest.java @@ -0,0 +1,77 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.sonar.api.utils.System2; +import org.sonar.db.DbTester; + +import static java.lang.String.valueOf; + +public class AddComponentUuidColumnToMeasuresTest { + + @Rule + public DbTester db = DbTester.createForSchema(System2.INSTANCE, AddComponentUuidColumnToMeasuresTest.class, "project_measures_5.6.sql"); + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + private AddComponentUuidColumnToMeasures underTest = new AddComponentUuidColumnToMeasures(db.database()); + + @Test + public void migration_adds_column_to_empty_table() throws SQLException { + underTest.execute(); + + verifyAddedColumns(); + } + + @Test + public void migration_adds_column_to_populated_table() throws SQLException { + for (int i = 0; i < 9; i++) { + db.executeInsert( + "project_measures", + "METRIC_ID", valueOf(i), + "VALUE", valueOf(i), + "SNAPSHOT_ID", valueOf(i)); + } + db.commit(); + + underTest.execute(); + + verifyAddedColumns(); + } + + @Test + public void migration_is_not_reentrant() throws SQLException { + underTest.execute(); + + expectedException.expect(IllegalStateException.class); + expectedException.expectMessage("Fail to execute "); + underTest.execute(); + } + + private void verifyAddedColumns() { + db.assertColumnDefinition("project_measures", "component_uuid", Types.VARCHAR, 50, true); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnsToSnapshotsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnsToSnapshotsTest.java new file mode 100644 index 00000000000..f65814bd68a --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnsToSnapshotsTest.java @@ -0,0 +1,78 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.sonar.api.utils.System2; +import org.sonar.db.DbTester; + +import static java.lang.String.valueOf; + +public class AddComponentUuidColumnsToSnapshotsTest { + + private static final String SNAPSHOTS_TABLE = "snapshots"; + + @Rule + public DbTester db = DbTester.createForSchema(System2.INSTANCE, AddComponentUuidColumnsToSnapshotsTest.class, "old_snapshots.sql"); + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + private AddComponentUuidColumnsToSnapshots underTest = new AddComponentUuidColumnsToSnapshots(db.database()); + + @Test + public void migration_adds_columns_to_empty_table() throws SQLException { + underTest.execute(); + + verifyAddedColumns(); + } + + @Test + public void migration_adds_columns_to_populated_table() throws SQLException { + for (int i = 0; i < 9; i++) { + db.executeInsert( + SNAPSHOTS_TABLE, + "PROJECT_ID", valueOf(i), + "ISLAST", "TRUE"); + } + db.commit(); + + underTest.execute(); + + verifyAddedColumns(); + } + + private void verifyAddedColumns() { + db.assertColumnDefinition(SNAPSHOTS_TABLE, "component_uuid", Types.VARCHAR, 50, true); + db.assertColumnDefinition(SNAPSHOTS_TABLE, "root_component_uuid", Types.VARCHAR, 50, true); + } + + @Test + public void migration_is_not_reentrant() throws SQLException { + underTest.execute(); + + expectedException.expect(IllegalStateException.class); + expectedException.expectMessage("Fail to execute "); + underTest.execute(); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddIndexOnComponentUuidOfMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddIndexOnComponentUuidOfMeasuresTest.java new file mode 100644 index 00000000000..66922e8f025 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddIndexOnComponentUuidOfMeasuresTest.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import org.junit.Test; +import org.mockito.Mockito; +import org.sonar.db.Database; +import org.sonar.db.dialect.H2; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static java.util.Arrays.asList; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.when; + +public class AddIndexOnComponentUuidOfMeasuresTest { + + private Database db = mock(Database.class, Mockito.RETURNS_DEEP_STUBS); + private DdlChange.Context context = mock(DdlChange.Context.class); + + @Test + public void add_index_to_measures() throws Exception { + when(db.getDialect()).thenReturn(new H2()); + AddIndexOnComponentUuidOfMeasures underTest = new AddIndexOnComponentUuidOfMeasures(db); + + underTest.execute(context); + + verify(context).execute(asList("CREATE INDEX measures_component_uuid ON project_measures (component_uuid)")); + verifyNoMoreInteractions(context); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddLastUsedColumnToRulesProfilesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddLastUsedColumnToRulesProfilesTest.java new file mode 100644 index 00000000000..0033f128a87 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddLastUsedColumnToRulesProfilesTest.java @@ -0,0 +1,77 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.sonar.api.utils.System2; +import org.sonar.db.DbTester; + +public class AddLastUsedColumnToRulesProfilesTest { + + @Rule + public DbTester db = DbTester.createForSchema(System2.INSTANCE, AddLastUsedColumnToRulesProfilesTest.class, "rules_profiles.sql"); + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + private AddLastUsedColumnToRulesProfiles underTest = new AddLastUsedColumnToRulesProfiles(db.database()); + + @Test + public void migration_adds_column_to_empty_table() throws SQLException { + underTest.execute(); + + verifyAddedColumns(); + } + + @Test + public void migration_adds_column_to_populated_table() throws SQLException { + for (int i = 0; i < 9; i++) { + db.executeInsert( + "rules_profiles", + "name", "NAME_" + i, + "language", "java", + "kee", "" + i, + "rules_updated_at", "2016-06-21"); + } + db.commit(); + + underTest.execute(); + + verifyAddedColumns(); + } + + @Test + public void migration_is_not_reentrant() throws SQLException { + underTest.execute(); + + expectedException.expect(IllegalStateException.class); + expectedException.expectMessage("Fail to execute "); + underTest.execute(); + } + + private void verifyAddedColumns() { + db.assertColumnDefinition("rules_profiles", "last_used", Types.BIGINT, null, true); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddProfileKeyToActivitiesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddProfileKeyToActivitiesTest.java new file mode 100644 index 00000000000..bff0a9dc448 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddProfileKeyToActivitiesTest.java @@ -0,0 +1,75 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.sonar.api.utils.System2; +import org.sonar.db.DbTester; + +public class AddProfileKeyToActivitiesTest { + + @Rule + public DbTester db = DbTester.createForSchema(System2.INSTANCE, AddProfileKeyToActivitiesTest.class, "activities.sql"); + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + private AddProfileKeyToActivities underTest = new AddProfileKeyToActivities(db.database()); + + @Test + public void migration_adds_column_to_empty_table() throws SQLException { + underTest.execute(); + + verifyAddedColumns(); + } + + @Test + public void migration_adds_column_to_populated_table() throws SQLException { + for (int i = 0; i < 9; i++) { + db.executeInsert( + "activities", + "log_key", "LOG_KEY_" + i, + "user_login", "login"); + } + db.commit(); + + underTest.execute(); + + verifyAddedColumns(); + } + + @Test + public void migration_is_not_reentrant() throws SQLException { + underTest.execute(); + + expectedException.expect(IllegalStateException.class); + expectedException.expectMessage("Fail to execute "); + underTest.execute(); + } + + private void verifyAddedColumns() { + db.assertColumnDefinition("activities", "profile_key", Types.VARCHAR, 255, true); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUniqueIndexOnUuidOfSnapshotsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUniqueIndexOnUuidOfSnapshotsTest.java new file mode 100644 index 00000000000..77c086e5175 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUniqueIndexOnUuidOfSnapshotsTest.java @@ -0,0 +1,49 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import org.junit.Test; +import org.mockito.Mockito; +import org.sonar.db.Database; +import org.sonar.db.dialect.H2; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static java.util.Arrays.asList; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.when; + +public class AddUniqueIndexOnUuidOfSnapshotsTest { + + private Database db = mock(Database.class, Mockito.RETURNS_DEEP_STUBS); + private DdlChange.Context context = mock(DdlChange.Context.class); + + @Test + public void create_unique_index() throws Exception { + when(db.getDialect()).thenReturn(new H2()); + AddUniqueIndexOnUuidOfSnapshots underTest = new AddUniqueIndexOnUuidOfSnapshots(db); + + underTest.execute(context); + + verify(context).execute(asList("CREATE UNIQUE INDEX analyses_uuid ON snapshots (uuid)")); + verifyNoMoreInteractions(context); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUserUpdatedAtToRulesProfilesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUserUpdatedAtToRulesProfilesTest.java new file mode 100644 index 00000000000..4f9fc036947 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUserUpdatedAtToRulesProfilesTest.java @@ -0,0 +1,77 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.sonar.api.utils.System2; +import org.sonar.db.DbTester; + +public class AddUserUpdatedAtToRulesProfilesTest { + + @Rule + public DbTester db = DbTester.createForSchema(System2.INSTANCE, AddUserUpdatedAtToRulesProfilesTest.class, "rules_profiles.sql"); + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + AddUserUpdatedAtToRulesProfiles underTest = new AddUserUpdatedAtToRulesProfiles(db.database()); + + @Test + public void migration_adds_column_to_empty_table() throws SQLException { + underTest.execute(); + + verifyAddedColumn(); + } + + @Test + public void migration_adds_column_to_populated_table() throws SQLException { + for (int i = 0; i < 9; i++) { + db.executeInsert( + "rules_profiles", + "name", "NAME_" + i, + "language", "java", + "kee", "" + i, + "rules_updated_at", "2016-06-21", + "last_used", "123456789"); + } + db.commit(); + + underTest.execute(); + + verifyAddedColumn(); + } + + @Test + public void migration_is_not_reentrant() throws SQLException { + underTest.execute(); + + expectedException.expect(IllegalStateException.class); + expectedException.expectMessage("Fail to execute "); + underTest.execute(); + } + + private void verifyAddedColumn() { + db.assertColumnDefinition("rules_profiles", "user_updated_at", Types.BIGINT, null, true); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnToSnapshotsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnToSnapshotsTest.java new file mode 100644 index 00000000000..b0cac16af67 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnToSnapshotsTest.java @@ -0,0 +1,76 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.sonar.api.utils.System2; +import org.sonar.db.DbTester; + +import static java.lang.String.valueOf; + +public class AddUuidColumnToSnapshotsTest { + @Rule + public DbTester db = DbTester.createForSchema(System2.INSTANCE, AddUuidColumnToSnapshotsTest.class, "old_snapshots.sql"); + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + private AddUuidColumnToSnapshots underTest = new AddUuidColumnToSnapshots(db.database()); + + @Test + public void migration_adds_columns_to_empty_table() throws SQLException { + underTest.execute(); + + verifyAddedColumns(); + } + + @Test + public void migration_adds_column_to_populated_table() throws SQLException { + for (int i = 0; i < 9; i++) { + db.executeInsert( + "snapshots", + "component_uuid", valueOf(i), + "root_component_uuid", valueOf(i + 10), + "QUALIFIER", (i % 2 == 0 ? "FIL" : "TRK")); + } + db.commit(); + + underTest.execute(); + + verifyAddedColumns(); + } + + @Test + public void migration_is_not_reentrant() throws SQLException { + underTest.execute(); + + expectedException.expect(IllegalStateException.class); + expectedException.expectMessage("Fail to execute "); + underTest.execute(); + } + + private void verifyAddedColumns() { + db.assertColumnDefinition("snapshots", "uuid", Types.VARCHAR, 50, true); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnsToProjectsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnsToProjectsTest.java new file mode 100644 index 00000000000..a2be57ac03f --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnsToProjectsTest.java @@ -0,0 +1,69 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.sonar.api.utils.System2; +import org.sonar.db.DbTester; + +public class AddUuidColumnsToProjectsTest { + + private static final String PROJECTS_TABLE = "projects"; + + @Rule + public DbTester db = DbTester.createForSchema(System2.INSTANCE, AddUuidColumnsToProjectsTest.class, "old_projects.sql"); + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + private AddUuidColumnsToProjects underTest = new AddUuidColumnsToProjects(db.database()); + + @Test + public void migration_adds_columns_to_empty_table() throws SQLException { + underTest.execute(); + + verifyAddedColumns(); + } + + @Test + public void migration_adds_columns_to_populated_table() throws SQLException { + for (int i = 0; i < 9; i++) { + db.executeInsert( + PROJECTS_TABLE, + "KEE", "key_" + i, + "ENABLED", "true"); + } + db.commit(); + + underTest.execute(); + + verifyAddedColumns(); + } + + private void verifyAddedColumns() { + db.assertColumnDefinition(PROJECTS_TABLE, "root_uuid", Types.VARCHAR, 50, true); + db.assertColumnDefinition(PROJECTS_TABLE, "copy_component_uuid", Types.VARCHAR, 50, true); + db.assertColumnDefinition(PROJECTS_TABLE, "developer_uuid", Types.VARCHAR, 50, true); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnsToResourceIndexTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnsToResourceIndexTest.java new file mode 100644 index 00000000000..3718bdee8b1 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnsToResourceIndexTest.java @@ -0,0 +1,80 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.sonar.api.utils.System2; +import org.sonar.db.DbTester; + +import static java.lang.String.valueOf; + +public class AddUuidColumnsToResourceIndexTest { + + @Rule + public DbTester db = DbTester.createForSchema(System2.INSTANCE, AddUuidColumnsToResourceIndexTest.class, "old_resourceindex.sql"); + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + private AddUuidColumnsToResourceIndex underTest = new AddUuidColumnsToResourceIndex(db.database()); + + @Test + public void migration_adds_columns_to_empty_table() throws SQLException { + underTest.execute(); + + verifyAddedColumns(); + } + + @Test + public void migration_adds_columns_to_populated_table() throws SQLException { + for (int i = 0; i < 9; i++) { + db.executeInsert( + "resource_index", + "KEE", "key_" + i, + "POSITION", valueOf(i), + "NAME_SIZE", valueOf(i + 1), + "RESOURCE_ID", valueOf(i + 10), + "ROOT_PROJECT_ID", valueOf(i + 20), + "QUALIFIER", (i % 2 == 0 ? "FILE" : "PROJECT")); + } + db.commit(); + + underTest.execute(); + + verifyAddedColumns(); + } + + private void verifyAddedColumns() { + db.assertColumnDefinition("resource_index", "component_uuid", Types.VARCHAR, 50, true); + db.assertColumnDefinition("resource_index", "root_component_uuid", Types.VARCHAR, 50, true); + } + + @Test + public void migration_is_not_reentrant() throws SQLException { + underTest.execute(); + + expectedException.expect(IllegalStateException.class); + expectedException.expectMessage("Fail to execute "); + underTest.execute(); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutAnalysisUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutAnalysisUuidTest.java new file mode 100644 index 00000000000..dbabfc0294f --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutAnalysisUuidTest.java @@ -0,0 +1,92 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import java.util.List; +import java.util.stream.Collectors; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.api.utils.System2; +import org.sonar.db.DbTester; + +import static java.lang.String.valueOf; +import static org.assertj.core.api.Assertions.assertThat; + +public class CleanEventsWithoutAnalysisUuidTest { + + private static final String TABLE_EVENTS = "events"; + + @Rule + public DbTester db = DbTester.createForSchema(System2.INSTANCE, CleanEventsWithoutAnalysisUuidTest.class, + "in_progress_events.sql"); + + private CleanEventsWithoutAnalysisUuid underTest = new CleanEventsWithoutAnalysisUuid(db.database()); + + @Test + public void migration_has_no_effect_on_empty_table() throws SQLException { + underTest.execute(); + + assertThat(db.countRowsOfTable(TABLE_EVENTS)).isEqualTo(0); + } + + @Test + public void migration_deletes_any_row_with_a_null_uuid() throws SQLException { + insertEvent(1, true, true); + insertEvent(2, false, true); + insertEvent(3, false, false); + insertEvent(4, true, true); + db.commit(); + + underTest.execute(); + + assertThat(idsOfRowsInResourceIndex()).containsOnly(1L, 3L, 4L); + } + + @Test + public void migration_is_reentrant() throws SQLException { + insertEvent(1, true, true); + insertEvent(2, false, true); + + underTest.execute(); + + assertThat(idsOfRowsInResourceIndex()).containsOnly(1L); + + underTest.execute(); + + assertThat(idsOfRowsInResourceIndex()).containsOnly(1L); + } + + private List<Long> idsOfRowsInResourceIndex() { + return db.select("select ID from events").stream().map(map -> (Long) map.get("ID")).collect(Collectors.toList()); + } + + private void insertEvent(long id, boolean hasAnalysisUuid, boolean hasSnapshotId) { + db.executeInsert( + TABLE_EVENTS, + "ID", valueOf(id), + "NAME", "name_" + id, + "ANALYSIS_UUID", hasAnalysisUuid ? "uuid_" + id : null, + "SNAPSHOT_ID", hasSnapshotId ? valueOf(id + 100) : null, + "EVENT_DATE", valueOf(1 + 100), + "CREATED_AT", valueOf(1 + 300)); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutSnapshotIdTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutSnapshotIdTest.java new file mode 100644 index 00000000000..9c675e4a818 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutSnapshotIdTest.java @@ -0,0 +1,91 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import java.util.List; +import java.util.stream.Collectors; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.api.utils.System2; +import org.sonar.db.DbTester; + +import static java.lang.String.valueOf; +import static org.assertj.core.api.Assertions.assertThat; + +public class CleanEventsWithoutSnapshotIdTest { + + private static final String TABLE_EVENTS = "events"; + + @Rule + public DbTester db = DbTester.createForSchema(System2.INSTANCE, CleanEventsWithoutSnapshotIdTest.class, + "in_progress_events.sql"); + + private CleanEventsWithoutSnapshotId underTest = new CleanEventsWithoutSnapshotId(db.database()); + + @Test + public void migration_has_no_effect_on_empty_table() throws SQLException { + underTest.execute(); + + assertThat(db.countRowsOfTable(TABLE_EVENTS)).isEqualTo(0); + } + + @Test + public void migration_deletes_any_row_with_a_null_uuid() throws SQLException { + insertEvent(1, true); + insertEvent(2, false); + insertEvent(3, false); + insertEvent(4, true); + db.commit(); + + underTest.execute(); + + assertThat(idsOfRowsInResourceIndex()).containsOnly(1L, 4L); + } + + @Test + public void migration_is_reentrant() throws SQLException { + insertEvent(1, true); + insertEvent(2, false); + + underTest.execute(); + + assertThat(idsOfRowsInResourceIndex()).containsOnly(1L); + + underTest.execute(); + + assertThat(idsOfRowsInResourceIndex()).containsOnly(1L); + } + + private List<Long> idsOfRowsInResourceIndex() { + return db.select("select ID from events").stream().map(map -> (Long) map.get("ID")).collect(Collectors.toList()); + } + + private void insertEvent(long id, boolean hasSnapshotId) { + db.executeInsert( + TABLE_EVENTS, + "ID", valueOf(id), + "NAME", "name_" + id, + "SNAPSHOT_ID", hasSnapshotId ? valueOf(id + 100) : null, + "EVENT_DATE", valueOf(1 + 100), + "CREATED_AT", valueOf(1 + 300)); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanMeasuresWithNullAnalysisUuidTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanMeasuresWithNullAnalysisUuidTest.java new file mode 100644 index 00000000000..1667aa18794 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanMeasuresWithNullAnalysisUuidTest.java @@ -0,0 +1,90 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import java.util.List; +import java.util.stream.Collectors; +import javax.annotation.Nullable; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.api.utils.System2; +import org.sonar.db.DbTester; + +import static java.lang.String.valueOf; +import static org.assertj.core.api.Assertions.assertThat; + +public class CleanMeasuresWithNullAnalysisUuidTest { + + private static final String TABLE_MEASURES = "project_measures"; + + @Rule + public DbTester db = DbTester.createForSchema(System2.INSTANCE, CleanMeasuresWithNullAnalysisUuidTest.class, + "in_progress_measures.sql"); + + private CleanMeasuresWithNullAnalysisUuid underTest = new CleanMeasuresWithNullAnalysisUuid(db.database()); + + @Test + public void migration_has_no_effect_on_empty_table() throws SQLException { + underTest.execute(); + + assertThat(db.countRowsOfTable(TABLE_MEASURES)).isEqualTo(0); + } + + @Test + public void migration_deletes_rows_with_null_analysis_uuid() throws SQLException { + insertMeasure(1, "U1"); + insertMeasure(2, "U1"); + insertMeasure(3, null); + db.commit(); + + underTest.execute(); + + assertThat(idsOfRows()).containsOnly(1L, 2L); + } + + @Test + public void migration_is_reentrant() throws SQLException { + insertMeasure(1, "U1"); + insertMeasure(2, null); + db.commit(); + + underTest.execute(); + assertThat(idsOfRows()).containsOnly(1L); + + underTest.execute(); + assertThat(idsOfRows()).containsOnly(1L); + } + + private void insertMeasure(long id, @Nullable String analysisUuid) { + db.executeInsert( + TABLE_MEASURES, + "ID", valueOf(id), + "SNAPSHOT_ID", valueOf(id + 10), + "METRIC_ID", valueOf(id + 100), + "VALUE", valueOf(id + 200), + "COMPONENT_UUID", valueOf(id + 300), + "ANALYSIS_UUID", analysisUuid); + } + + private List<Long> idsOfRows() { + return db.select("select ID from project_measures").stream().map(map -> (Long) map.get("ID")).collect(Collectors.toList()); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanOrphanRowsInResourceIndexTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanOrphanRowsInResourceIndexTest.java new file mode 100644 index 00000000000..07020b4248d --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanOrphanRowsInResourceIndexTest.java @@ -0,0 +1,98 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import java.util.List; +import java.util.stream.Collectors; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.api.utils.System2; +import org.sonar.db.DbTester; + +import static java.lang.String.valueOf; +import static org.assertj.core.api.Assertions.assertThat; + +public class CleanOrphanRowsInResourceIndexTest { + + @Rule + public DbTester db = DbTester.createForSchema(System2.INSTANCE, CleanOrphanRowsInResourceIndexTest.class, + "in_progress_resourceindex.sql"); + + private CleanOrphanRowsInResourceIndex underTest = new CleanOrphanRowsInResourceIndex(db.database()); + + @Test + public void migration_has_no_effect_on_empty_table() throws SQLException { + underTest.execute(); + + assertThat(db.countRowsOfTable("resource_index")).isEqualTo(0); + } + + @Test + public void migration_deletes_any_row_with_a_null_uuid() throws SQLException { + insertResourceIndex(1, true, true); + insertResourceIndex(2, false, false); + insertResourceIndex(3, true, false); + insertResourceIndex(4, false, true); + insertResourceIndex(5, true, true); + db.commit(); + + underTest.execute(); + + assertThat(idsOfRowsInResourceIndex()).containsOnly(1l, 5l); + } + + @Test + public void migration_is_reentrant() throws SQLException { + insertResourceIndex(1, true, true); + insertResourceIndex(2, false, false); + + underTest.execute(); + + assertThat(idsOfRowsInResourceIndex()).containsOnly(1l); + + underTest.execute(); + + assertThat(idsOfRowsInResourceIndex()).containsOnly(1l); + } + + private List<Long> idsOfRowsInResourceIndex() { + return db.select("select ID from resource_index").stream().map(map -> (Long) map.get("ID")).collect(Collectors.toList()); + } + + private void insertResourceIndex(long id, boolean hasComponentUiid, boolean hasRootComponentUuid) { + db.executeInsert( + "resource_index", + "ID", valueOf(id), + "KEE", "key_" + id, + "POSITION", valueOf(id + 100), + "NAME_SIZE", valueOf(id + 1000), + "RESOURCE_ID", valueOf(id + 300), + "ROOT_PROJECT_ID", valueOf(id + 4000), + "QUALIFIER", "PROJECT"); + + if (hasComponentUiid) { + db.executeUpdateSql("update resource_index set COMPONENT_UUID=? where id=?", "uuid_" + id, valueOf(id)); + } + if (hasRootComponentUuid) { + db.executeUpdateSql("update resource_index set ROOT_COMPONENT_UUID=? where id=?", "root_uuid_" + id, valueOf(id)); + } + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanOrphanRowsInSnapshotsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanOrphanRowsInSnapshotsTest.java new file mode 100644 index 00000000000..cb490a9936f --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanOrphanRowsInSnapshotsTest.java @@ -0,0 +1,163 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import java.util.List; +import java.util.stream.Collectors; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.api.utils.System2; +import org.sonar.db.DbTester; + +import static java.lang.String.valueOf; +import static org.assertj.core.api.Assertions.assertThat; + +public class CleanOrphanRowsInSnapshotsTest { + + private static final String SNAPSHOTS_TABLE = "snapshots"; + + @Rule + public DbTester db = DbTester.createForSchema(System2.INSTANCE, CleanOrphanRowsInSnapshotsTest.class, + "in_progress_snapshots_and_children_tables.sql"); + + private CleanOrphanRowsInSnapshots underTest = new CleanOrphanRowsInSnapshots(db.database()); + + @Test + public void migration_has_no_effect_on_empty_table() throws SQLException { + underTest.execute(); + + assertThat(db.countRowsOfTable(SNAPSHOTS_TABLE)).isEqualTo(0); + } + + @Test + public void migration_deletes_any_row_with_a_null_uuid() throws SQLException { + insertSnapshots(1, true, true); + insertSnapshots(2, false, false); + insertSnapshots(3, true, false); + insertSnapshots(4, false, true); + insertSnapshots(5, true, true); + db.commit(); + + underTest.execute(); + + assertThat(idsOfRowsInSnapshots()).containsOnly(1l, 5l); + } + + @Test + public void migration_deletes_rows_in_children_tables_referencing_snapshots_with_at_least_null_uuid() throws SQLException { + insertSnapshots(1, true, true); + insertSnapshots(2, false, true); + insertSnapshots(3, true, false); + insertDuplicationIndex(1, 1); + insertDuplicationIndex(30, 1); + insertDuplicationIndex(1, 40); + insertDuplicationIndex(50, 2); + insertDuplicationIndex(2, 2); + insertDuplicationIndex(2, 60); + insertDuplicationIndex(3, 3); + insertDuplicationIndex(70, 3); + insertDuplicationIndex(3, 90); + insertProjectMeasure(1); + insertProjectMeasure(2); + insertProjectMeasure(3); + insertCeActivity(1); + insertCeActivity(2); + insertCeActivity(3); + insertEvents(1); + insertEvents(2); + insertEvents(3); + db.commit(); + + underTest.execute(); + + verifyLineCountsPerSnapshot(1, 1, 3, 1, 1, 1); + verifyLineCountsPerSnapshot(2, 0, 0, 0, 0, 0); + verifyLineCountsPerSnapshot(3, 0, 0, 0, 0, 0); + } + + private void verifyLineCountsPerSnapshot(int snapshotId, int snapshotCount, int duplicationIndexCount, int projectMeasureCount, int ceActivityCount, int eventCount) { + assertThat(count("SNAPSHOTS where id=" + snapshotId)).isEqualTo(snapshotCount); + assertThat(count("DUPLICATIONS_INDEX where snapshot_id=" + snapshotId + " or project_snapshot_id=" + snapshotId)).isEqualTo(duplicationIndexCount); + assertThat(count("PROJECT_MEASURES where snapshot_id=" + snapshotId)).isEqualTo(projectMeasureCount); + assertThat(count("CE_ACTIVITY where snapshot_id=" + snapshotId)).isEqualTo(ceActivityCount); + assertThat(count("EVENTS where snapshot_id=" + snapshotId)).isEqualTo(eventCount); + } + + private long count(String tableAndWhereClause) { + return (Long) db.selectFirst("select count(*) from " + tableAndWhereClause).entrySet().iterator().next().getValue(); + } + + private void insertDuplicationIndex(int snapshotId, int parentSnapshotId) { + db.executeInsert( + "DUPLICATIONS_INDEX", + "SNAPSHOT_ID", valueOf(snapshotId), + "PROJECT_SNAPSHOT_ID", valueOf(parentSnapshotId), + "HASH", "hash_" + snapshotId + "-" + parentSnapshotId, + "INDEX_IN_FILE", valueOf(snapshotId + parentSnapshotId), + "START_LINE", "1", + "END_LINE", "1"); + } + + private void insertProjectMeasure(int snapshotId) { + db.executeInsert( + "PROJECT_MEASURES", + "SNAPSHOT_ID", valueOf(snapshotId), + "METRIC_ID", "111"); + } + + private void insertCeActivity(int snapshotId) { + db.executeInsert( + "CE_ACTIVITY", + "UUID", valueOf(snapshotId + 10), + "TASK_TYPE", "REPORT", + "STATUS", "OK", + "COMPONENT_UUID", valueOf(snapshotId + 20), + "SNAPSHOT_ID", valueOf(snapshotId), + "IS_LAST", "true", + "IS_LAST_KEY", "key", + "SUBMITTED_AT", "984651", + "CREATED_AT", "984651", + "UPDATED_AT", "984651"); + } + + private void insertEvents(int snapshotId) { + db.executeInsert( + "EVENTS", + "SNAPSHOT_ID", valueOf(snapshotId), + "EVENT_DATE", "984651", + "CREATED_AT", "984651"); + } + + private void insertSnapshots(long id, boolean hasComponentUiid, boolean hasRootComponentUuid) { + db.executeInsert( + SNAPSHOTS_TABLE, + "ID", valueOf(id), + "ISLAST", "TRUE", + "PROJECT_ID", valueOf(id + 300), + "COMPONENT_UUID", hasComponentUiid ? "uuid_" + id : null, + "ROOT_COMPONENT_UUID", hasRootComponentUuid ? "root_uuid_" + id : null); + } + + private List<Long> idsOfRowsInSnapshots() { + return db.select("select ID from snapshots").stream().map(map -> (Long) map.get("ID")).collect(Collectors.toList()); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanUsurperRootComponentsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanUsurperRootComponentsTest.java new file mode 100644 index 00000000000..64f127b90c4 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CleanUsurperRootComponentsTest.java @@ -0,0 +1,366 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import com.google.common.collect.ImmutableList; +import java.sql.SQLException; +import java.util.List; +import java.util.Map; +import javax.annotation.Nullable; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.api.resources.Qualifiers; +import org.sonar.api.resources.Scopes; +import org.sonar.api.utils.System2; +import org.sonar.db.DbTester; + +import static java.lang.String.valueOf; +import static org.assertj.core.api.Assertions.assertThat; + +public class CleanUsurperRootComponentsTest { + + private static final List<String> TABLES = ImmutableList.of( + "duplications_index", "project_measures", "ce_activity", "events", "snapshots", + "project_links", "project_measures", "issues", "file_sources", "group_roles", + "user_roles", "properties", "widgets", "projects"); + + @Rule + public DbTester db = DbTester.createForSchema(System2.INSTANCE, CleanUsurperRootComponentsTest.class, + "complete_schema.sql"); + + private CleanUsurperRootComponents underTest = new CleanUsurperRootComponents(db.database()); + + @Test + public void migration_has_no_effect_on_empty_db() throws SQLException { + underTest.execute(); + + TABLES.forEach(tableName -> assertThat(db.countRowsOfTable(tableName)).isEqualTo(0)); + } + + @Test + public void execute_fixes_scope_and_qualifier_of_snapshot_inconsistent_with_component() throws SQLException { + String[] componentUuids = { + insertComponent("sc1", "qu1"), + insertComponent("sc2", "qu2"), + insertComponent("sc3", "qu3"), + insertComponent("sc4", "qu4") + }; + Long[] snapshotIds = { + insertSnapshot(componentUuids[0], "sc1", "qu1"), + insertSnapshot(componentUuids[1], "sc2", "quW"), + insertSnapshot(componentUuids[2], "scX", "qu3"), + insertSnapshot(componentUuids[3], "scY", "quZ"), + }; + + underTest.execute(); + + assertSnapshot(snapshotIds[0], "sc1", "qu1"); + assertSnapshot(snapshotIds[1], "sc2", "qu2"); + assertSnapshot(snapshotIds[2], "sc3", "qu3"); + assertSnapshot(snapshotIds[3], "sc4", "qu4"); + } + + @Test + public void executes_deletes_usurper_root_components() throws SQLException { + String[] componentUuids = { + insertRootComponent(Scopes.PROJECT, Qualifiers.PROJECT), + insertRootComponent(Scopes.PROJECT, Qualifiers.MODULE), + insertRootComponent(Scopes.DIRECTORY, Qualifiers.DIRECTORY), + insertRootComponent(Scopes.FILE, Qualifiers.FILE), + insertRootComponent(Scopes.PROJECT, Qualifiers.VIEW), + insertRootComponent(Scopes.PROJECT, Qualifiers.SUBVIEW), + insertRootComponent(Scopes.FILE, Qualifiers.PROJECT), + insertRootComponent(Scopes.PROJECT, "DEV"), + insertRootComponent(Scopes.PROJECT, "DEV_PRJ"), + }; + + underTest.execute(); + + assertUuidsInTableProjects("projects", componentUuids[0], componentUuids[4], componentUuids[7]); + } + + @Test + public void executes_deletes_data_in_all_children_tables_of_component_for_usurper_root_components() throws SQLException { + long usurperId = 12L; + String usurperUuid = "usurper_uuid"; + insertComponent(Scopes.PROJECT, Qualifiers.MODULE, usurperId, usurperUuid, usurperUuid); + Long snapshotId = insertSnapshot(usurperUuid, usurperUuid); + insertDuplicationsIndex(snapshotId); + insertProjectMeasures(usurperUuid, dontCareLong()); + insertCeActivity(usurperUuid, dontCareLong()); + insertEvent(usurperUuid, dontCareLong()); + insertSnapshot(usurperUuid, dontCare()); + insertSnapshot(dontCare(), usurperUuid); + insertProjectLinks(usurperUuid); + insertIssue(usurperUuid, null); + insertIssue(null, usurperUuid); + insertIssue(usurperUuid, usurperUuid); + insertFileSource(null, usurperUuid); + insertFileSource(usurperUuid, null); + insertFileSource(usurperUuid, usurperUuid); + insertGroupRole(usurperId); + insertUserRole(usurperId); + insertProperties(usurperId); + insertWidget(usurperId); + + TABLES.stream() + .forEach(s -> assertThat(db.countRowsOfTable(s)).describedAs("table " + s).isGreaterThanOrEqualTo(1)); + + underTest.execute(); + + TABLES.stream() + .forEach(s -> assertThat(db.countRowsOfTable(s)).describedAs("table " + s).isEqualTo(0)); + } + + @Test + public void execute_deletes_snapshots_which_root_is_not_root() throws SQLException { + String[] componentUuids = { + insertRootComponent(Scopes.PROJECT, Qualifiers.PROJECT), + insertComponent(Scopes.PROJECT, Qualifiers.MODULE), + insertComponent(Scopes.DIRECTORY, Qualifiers.DIRECTORY), + insertComponent(Scopes.FILE, Qualifiers.FILE), + insertComponent(Scopes.PROJECT, Qualifiers.VIEW), + insertComponent(Scopes.PROJECT, Qualifiers.SUBVIEW), + insertComponent(Scopes.FILE, Qualifiers.PROJECT), + insertComponent(Scopes.PROJECT, "DEV"), + insertComponent(Scopes.PROJECT, "DEV_PRJ"), + }; + Long[] snapshotIds = { + insertSnapshot(dontCare(), componentUuids[0]), + insertSnapshot(dontCare(), componentUuids[1]), + insertSnapshot(dontCare(), componentUuids[2]), + insertSnapshot(dontCare(), componentUuids[3]), + insertSnapshot(dontCare(), componentUuids[4]), + insertSnapshot(dontCare(), componentUuids[5]), + insertSnapshot(dontCare(), componentUuids[6]), + insertSnapshot(dontCare(), componentUuids[7]), + insertSnapshot(dontCare(), componentUuids[8]) + }; + + underTest.execute(); + + assertIdsInTableProjects("snapshots", snapshotIds[0], snapshotIds[4], snapshotIds[7]); + } + + @Test + public void execute_deletes_children_tables_of_snapshots_when_root_of_snapshot_is_not_root() throws SQLException { + String componentUuid = insertComponent(Scopes.FILE, Scopes.FILE); + Long snapshotId = insertSnapshot(dontCare(), componentUuid); + insertProjectMeasures(dontCare(), snapshotId); + insertCeActivity(componentUuid, snapshotId); + insertEvent(componentUuid, snapshotId); + + underTest.execute(); + + TABLES.stream() + .filter(s1 -> !s1.equals("projects")) + .forEach(s -> assertThat(db.countRowsOfTable(s)).describedAs("table " + s).isEqualTo(0)); + } + + private void insertDuplicationsIndex(Long snapshotId) { + db.executeInsert( + "duplications_index", + "PROJECT_SNAPSHOT_ID", valueOf(dontCareLong()), + "SNAPSHOT_ID", valueOf(snapshotId), + "HASH", dontCare(), + "INDEX_IN_FILE", valueOf(0), + "START_LINE", valueOf(0), + "END_LINE", valueOf(0)); + db.commit(); + } + + private void insertProjectMeasures(String componentUuid, Long snapshotId) { + db.executeInsert( + "project_measures", + "METRIC_ID", valueOf(123L), + "COMPONENT_UUID", componentUuid, + "SNAPSHOT_ID", valueOf(snapshotId)); + db.commit(); + } + + private void insertCeActivity(String componentUuid, Long snapshotId) { + db.executeInsert( + "ce_activity", + "UUID", dontCare(), + "TASK_TYPE", dontCare(), + "COMPONENT_UUID", componentUuid, + "SNAPSHOT_ID", valueOf(snapshotId), + "STATUS", dontCare(), + "IS_LAST", "true", + "IS_LAST_KEY", dontCare(), + "SUBMITTED_AT", valueOf(121L), + "CREATED_AT", valueOf(122L), + "UPDATED_AT", valueOf(123L)); + db.commit(); + } + + private void insertEvent(String componentUuid, Long snapshotId) { + db.executeInsert( + "events", + "SNAPSHOT_ID", valueOf(snapshotId), + "COMPONENT_UUID", componentUuid, + "CREATED_AT", valueOf(122L), + "EVENT_DATE", valueOf(123L)); + db.commit(); + } + + private Long insertSnapshot(String componentUuid, String rootComponentUuid) { + Long id = idGenerator++; + db.executeInsert( + "snapshots", + "ID", valueOf(id), + "COMPONENT_UUID", componentUuid, + "ROOT_COMPONENT_UUID", rootComponentUuid); + db.commit(); + return id; + } + + private void insertProjectLinks(String componentUuid) { + db.executeInsert( + "project_links", + "COMPONENT_UUID", componentUuid, + "HREF", dontCare()); + db.commit(); + } + + private void insertIssue(@Nullable String componentUuid, @Nullable String projectUuid) { + db.executeInsert( + "issues", + "COMPONENT_UUID", componentUuid == null ? dontCare() : componentUuid, + "PROJECT_UUID", projectUuid == null ? dontCare() : projectUuid, + "KEE", "kee_" + componentUuid + projectUuid, + "MANUAL_SEVERITY", valueOf(true)); + db.commit(); + } + + private void insertFileSource(@Nullable String fileUuid, @Nullable String projectUuid) { + db.executeInsert( + "file_sources", + "FILE_UUID", fileUuid == null ? dontCare() : fileUuid, + "PROJECT_UUID", projectUuid == null ? dontCare() : projectUuid, + "CREATED_AT", valueOf(122L), + "UPDATED_AT", valueOf(123L)); + db.commit(); + } + + private void insertGroupRole(long componentId) { + db.executeInsert( + "group_roles", + "RESOURCE_ID", valueOf(componentId), + "ROLE", dontCare()); + db.commit(); + } + + private void insertUserRole(long componentId) { + db.executeInsert( + "user_roles", + "RESOURCE_ID", valueOf(componentId), + "ROLE", dontCare()); + db.commit(); + } + + private void insertProperties(long componentId) { + db.executeInsert( + "properties", + "RESOURCE_ID", valueOf(componentId)); + db.commit(); + } + + private void insertWidget(long componentId) { + db.executeInsert( + "widgets", + "DASHBOARD_ID", valueOf(95), + "WIDGET_KEY", dontCare(), + "RESOURCE_ID", valueOf(componentId)); + db.commit(); + } + + private long idGenerator = 0; + + private String insertComponent(String scope, String qualifier) { + long id = idGenerator++; + String uuid = "uuid_" + id; + return insertComponent(scope, qualifier, id, uuid, dontCare()); + } + + private String insertRootComponent(String scope, String qualifier) { + long id = idGenerator++; + String uuid = "uuid_" + id; + return insertComponent(scope, qualifier, id, uuid, uuid); + } + + private String insertComponent(String scope, String qualifier, long id, String uuid, String projectUuid) { + db.executeInsert( + "projects", + "ID", valueOf(id), + "UUID", uuid, + "PROJECT_UUID", projectUuid, + "SCOPE", scope, + "QUALIFIER", qualifier); + db.commit(); + return uuid; + } + + private Long insertSnapshot(String componentUuid, String scope, String qualifier) { + long id = idGenerator++; + + db.executeInsert( + "snapshots", + "id", valueOf(id), + "component_uuid", componentUuid, + "root_component_uuid", dontCare(), + "scope", scope, + "qualifier", qualifier); + db.commit(); + return id; + } + + private void assertSnapshot(Long snapshotId, String scope, String qualifier) { + List<Map<String, Object>> rows = db.select("select SCOPE, QUALIFIER from snapshots where ID=" + snapshotId); + assertThat(rows).hasSize(1); + Map<String, Object> row = rows.get(0); + assertThat(row.get("SCOPE")).isEqualTo(scope); + assertThat(row.get("QUALIFIER")).isEqualTo(qualifier); + } + + private void assertIdsInTableProjects(String tableName, Long... expected) { + assertThat(db.select("select id from " + tableName) + .stream() + .map(stringObjectMap -> (Long) stringObjectMap.entrySet().iterator().next().getValue())) + .containsOnly(expected); + } + + private void assertUuidsInTableProjects(String tableName, String... expected) { + assertThat(db.select("select uuid from " + tableName) + .stream() + .map(stringObjectMap -> (String) stringObjectMap.entrySet().iterator().next().getValue())) + .containsOnly(expected); + } + + private long dontCareGenerator = 0; + + private String dontCare() { + return "DC_" + dontCareGenerator++; + } + + private Long dontCareLong() { + return dontCareGenerator++; + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CreatePermTemplatesCharacteristicsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CreatePermTemplatesCharacteristicsTest.java new file mode 100644 index 00000000000..5af11682593 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CreatePermTemplatesCharacteristicsTest.java @@ -0,0 +1,56 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.api.utils.System2; +import org.sonar.db.DbTester; + +import static org.assertj.core.api.Assertions.assertThat; + +public class CreatePermTemplatesCharacteristicsTest { + + private static final String TABLE_NAME = "perm_tpl_characteristics"; + + @Rule + public final DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, CreatePermTemplatesCharacteristicsTest.class, "empty.sql"); + + private CreatePermTemplatesCharacteristics underTest = new CreatePermTemplatesCharacteristics(dbTester.database()); + + @Test + public void creates_table_and_index() throws SQLException { + underTest.execute(); + + assertThat(dbTester.countRowsOfTable(TABLE_NAME)).isEqualTo(0); + dbTester.assertColumnDefinition(TABLE_NAME, "id", Types.INTEGER, null, false); + dbTester.assertPrimaryKey(TABLE_NAME, "pk_" + TABLE_NAME, "id"); + dbTester.assertColumnDefinition(TABLE_NAME, "template_id", Types.INTEGER, null); + dbTester.assertColumnDefinition(TABLE_NAME, "permission_key", Types.VARCHAR, 64, false); + dbTester.assertColumnDefinition(TABLE_NAME, "with_project_creator", Types.BOOLEAN, null, false); + dbTester.assertColumnDefinition(TABLE_NAME, "created_at", Types.BIGINT, null, false); + dbTester.assertColumnDefinition(TABLE_NAME, "updated_at", Types.BIGINT, null, false); + + dbTester.assertUniqueIndex(TABLE_NAME, "uniq_perm_tpl_charac", "template_id", "permission_key"); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CreateTemporaryIndicesFor1211Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CreateTemporaryIndicesFor1211Test.java new file mode 100644 index 00000000000..5fe4b693dc0 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/CreateTemporaryIndicesFor1211Test.java @@ -0,0 +1,56 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; +import org.sonar.db.Database; +import org.sonar.db.dialect.H2; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static java.util.Arrays.asList; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.when; + +public class CreateTemporaryIndicesFor1211Test { + + private Database db = mock(Database.class, Mockito.RETURNS_DEEP_STUBS); + private DdlChange.Context context = mock(DdlChange.Context.class); + + @Before + public void setUp() { + when(db.getDialect()).thenReturn(new H2()); + } + + @Test + public void create_two_indices() throws Exception { + CreateTemporaryIndicesFor1211 underTest = new CreateTemporaryIndicesFor1211(db); + + underTest.execute(context); + + verify(context).execute(asList("CREATE INDEX ce_activity_snapshot_id ON ce_activity (snapshot_id)")); + verify(context).execute(asList("CREATE INDEX dup_index_psid ON duplications_index (project_snapshot_id)")); + verifyNoMoreInteractions(context); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DbVersion60Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DbVersion60Test.java new file mode 100644 index 00000000000..9601e65e796 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DbVersion60Test.java @@ -0,0 +1,49 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import org.junit.Test; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMigrationCount; +import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMinimumMigrationNumber; + +public class DbVersion60Test { + private DbVersion60 underTest = new DbVersion60(); + + @Test + public void verify_supports_components() { + assertThat(underTest.getSupportComponents()).containsExactly( + FixProjectUuidOfDeveloperProjects.class, + CleanUsurperRootComponents.class + ); + } + + @Test + public void migrationNumber_starts_at_1200() { + verifyMinimumMigrationNumber(underTest, 1200); + } + + @Test + public void verify_migration_count() { + verifyMigrationCount(underTest, 76); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DeleteOrphanMeasuresWithoutComponentTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DeleteOrphanMeasuresWithoutComponentTest.java new file mode 100644 index 00000000000..1ab1fd69afa --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DeleteOrphanMeasuresWithoutComponentTest.java @@ -0,0 +1,91 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import java.util.List; +import java.util.stream.Collectors; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.api.utils.System2; +import org.sonar.db.DbTester; + +import static java.lang.String.valueOf; +import static org.assertj.core.api.Assertions.assertThat; + +public class DeleteOrphanMeasuresWithoutComponentTest { + + @Rule + public DbTester db = DbTester.createForSchema(System2.INSTANCE, DeleteOrphanMeasuresWithoutComponentTest.class, + "in_progress_project_measures.sql"); + + private DeleteOrphanMeasuresWithoutComponent underTest = new DeleteOrphanMeasuresWithoutComponent(db.database()); + + @Test + public void migration_has_no_effects_on_empty_table() throws SQLException { + underTest.execute(); + + assertThat(db.countRowsOfTable("project_measures")).isEqualTo(0); + } + + @Test + public void migration_deletes_any_row_with_a_null_component_uuid() throws SQLException { + insertMeasure(1, true); + insertMeasure(2, false); + insertMeasure(3, false); + insertMeasure(4, true); + db.commit(); + + underTest.execute(); + + assertThat(idsOfRowsInMeasures()).containsOnly(1L, 4L); + } + + @Test + public void migration_is_reentrant() throws SQLException { + insertMeasure(1, true); + insertMeasure(2, false); + + underTest.execute(); + + assertThat(idsOfRowsInMeasures()).containsOnly(1L); + + underTest.execute(); + + assertThat(idsOfRowsInMeasures()).containsOnly(1L); + } + + private List<Long> idsOfRowsInMeasures() { + return db.select("select ID from project_measures").stream().map(map -> (Long) map.get("ID")).collect(Collectors.toList()); + } + + private void insertMeasure(long id, boolean hasComponentUuid) { + db.executeInsert( + "project_measures", + "ID", valueOf(id), + "METRIC_ID", valueOf(id + 10), + "SNAPSHOT_ID", valueOf(id + 100), + "VALUE", valueOf(id + 1000)); + + if (hasComponentUuid) { + db.executeUpdateSql("update project_measures set COMPONENT_UUID=? where id=?", "uuid_" + id, valueOf(id)); + } + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropIdColumnsFromProjectsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropIdColumnsFromProjectsTest.java new file mode 100644 index 00000000000..f15ddbc74ee --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropIdColumnsFromProjectsTest.java @@ -0,0 +1,48 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.junit.Test; +import org.sonar.db.Database; +import org.sonar.db.dialect.PostgreSql; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +public class DropIdColumnsFromProjectsTest { + + private Database database = mock(Database.class); + + private DropIdColumnsFromProjects underTest = new DropIdColumnsFromProjects(database); + + @Test + public void verify_generated_sql_on_postgresql() throws SQLException { + when(database.getDialect()).thenReturn(new PostgreSql()); + + DdlChange.Context context = mock(DdlChange.Context.class); + underTest.execute(context); + + verify(context).execute("ALTER TABLE projects DROP COLUMN root_id, DROP COLUMN copy_resource_id, DROP COLUMN person_id"); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropIdColumnsFromResourceIndexTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropIdColumnsFromResourceIndexTest.java new file mode 100644 index 00000000000..58f4557d455 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropIdColumnsFromResourceIndexTest.java @@ -0,0 +1,47 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.junit.Test; +import org.sonar.db.Database; +import org.sonar.db.dialect.PostgreSql; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +public class DropIdColumnsFromResourceIndexTest { + + private Database database = mock(Database.class); + + private DropIdColumnsFromResourceIndex underTest = new DropIdColumnsFromResourceIndex(database); + + @Test + public void verify_generated_sql_on_postgresql() throws SQLException { + when(database.getDialect()).thenReturn(new PostgreSql()); + + DdlChange.Context context = mock(DdlChange.Context.class); + underTest.execute(context); + + verify(context).execute("ALTER TABLE resource_index DROP COLUMN resource_id, DROP COLUMN root_project_id"); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropIdColumnsFromSnapshotsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropIdColumnsFromSnapshotsTest.java new file mode 100644 index 00000000000..c63d970d804 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropIdColumnsFromSnapshotsTest.java @@ -0,0 +1,48 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.junit.Test; +import org.sonar.db.Database; +import org.sonar.db.dialect.PostgreSql; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +public class DropIdColumnsFromSnapshotsTest { + + private Database database = mock(Database.class); + + private DropIdColumnsFromSnapshots underTest = new DropIdColumnsFromSnapshots(database); + + @Test + public void verify_generated_sql_on_postgresql() throws SQLException { + when(database.getDialect()).thenReturn(new PostgreSql()); + + DdlChange.Context context = mock(DdlChange.Context.class); + underTest.execute(context); + + verify(context).execute("ALTER TABLE snapshots DROP COLUMN project_id, DROP COLUMN root_project_id"); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropIndexDuplicationsIndexSidFromDuplicationsIndexTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropIndexDuplicationsIndexSidFromDuplicationsIndexTest.java new file mode 100644 index 00000000000..a61a8b6d590 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropIndexDuplicationsIndexSidFromDuplicationsIndexTest.java @@ -0,0 +1,57 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; +import org.sonar.db.Database; +import org.sonar.db.dialect.MySql; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static java.util.Arrays.asList; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.when; + +public class DropIndexDuplicationsIndexSidFromDuplicationsIndexTest { + + private Database db = mock(Database.class, Mockito.RETURNS_DEEP_STUBS); + private DdlChange.Context context = mock(DdlChange.Context.class); + + @Before + public void setUp() { + // Some databases have unique names of indexes, so table name is not declared + // when dropping an index ("drop index <index name>"). Because of that MySQL is + // used in the test so that the table name can also be verified + when(db.getDialect()).thenReturn(new MySql()); + } + + @Test + public void drop_index() throws Exception { + DropIndexDuplicationsIndexSidFromDuplicationsIndex underTest = new DropIndexDuplicationsIndexSidFromDuplicationsIndex(db); + + underTest.execute(context); + + verify(context).execute(asList("DROP INDEX duplications_index_sid ON duplications_index")); + verifyNoMoreInteractions(context); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropIndexProjectsRootIdFromProjectsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropIndexProjectsRootIdFromProjectsTest.java new file mode 100644 index 00000000000..5ee840d0ee0 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropIndexProjectsRootIdFromProjectsTest.java @@ -0,0 +1,58 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; +import org.sonar.db.Database; +import org.sonar.db.dialect.MySql; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static java.util.Arrays.asList; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.when; + +public class DropIndexProjectsRootIdFromProjectsTest { + + private Database db = mock(Database.class, Mockito.RETURNS_DEEP_STUBS); + private DdlChange.Context context = mock(DdlChange.Context.class); + + @Before + public void setUp() { + // Some databases have unique names of indexes, so table name is not declared + // when dropping an index ("drop index <index name>"). Because of that MySQL is + // used in the test so that the table name can also be verified + when(db.getDialect()).thenReturn(new MySql()); + } + + @Test + public void drop_index() throws Exception { + DropIndexProjectsRootIdFromProjects underTest = new DropIndexProjectsRootIdFromProjects(db); + + underTest.execute(context); + + verify(context).execute(asList("DROP INDEX projects_root_id ON projects")); + verifyNoMoreInteractions(context); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropIndexProjectsUuidFromProjectsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropIndexProjectsUuidFromProjectsTest.java new file mode 100644 index 00000000000..c6c3bc2f90c --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropIndexProjectsUuidFromProjectsTest.java @@ -0,0 +1,58 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; +import org.sonar.db.Database; +import org.sonar.db.dialect.MySql; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static java.util.Arrays.asList; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.when; + +public class DropIndexProjectsUuidFromProjectsTest { + + private Database db = mock(Database.class, Mockito.RETURNS_DEEP_STUBS); + private DdlChange.Context context = mock(DdlChange.Context.class); + + @Before + public void setUp() { + // Some databases have unique names of indexes, so table name is not declared + // when dropping an index ("drop index <index name>"). Because of that MySQL is + // used in the test so that the table name can also be verified + when(db.getDialect()).thenReturn(new MySql()); + } + + @Test + public void drop_index() throws Exception { + DropIndexProjectsUuidFromProjects underTest = new DropIndexProjectsUuidFromProjects(db); + + underTest.execute(context); + + verify(context).execute(asList("DROP INDEX projects_uuid ON projects")); + verifyNoMoreInteractions(context); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropProjectIdColumnFromMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropProjectIdColumnFromMeasuresTest.java new file mode 100644 index 00000000000..6cd847dd3cb --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropProjectIdColumnFromMeasuresTest.java @@ -0,0 +1,47 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.junit.Test; +import org.sonar.db.Database; +import org.sonar.db.dialect.PostgreSql; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +public class DropProjectIdColumnFromMeasuresTest { + private Database database = mock(Database.class); + + private DropProjectIdColumnFromMeasures underTest = new DropProjectIdColumnFromMeasures(database); + + @Test + public void verify_generated_sql_on_postgresql() throws SQLException { + when(database.getDialect()).thenReturn(new PostgreSql()); + + DdlChange.Context context = mock(DdlChange.Context.class); + underTest.execute(context); + + verify(context).execute("ALTER TABLE project_measures DROP COLUMN project_id"); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropRememberMeColumnsFromUsersTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropRememberMeColumnsFromUsersTest.java new file mode 100644 index 00000000000..76555250292 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropRememberMeColumnsFromUsersTest.java @@ -0,0 +1,47 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.junit.Test; +import org.sonar.db.Database; +import org.sonar.db.dialect.PostgreSql; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +public class DropRememberMeColumnsFromUsersTest { + + private Database database = mock(Database.class); + + private DropRememberMeColumnsFromUsers underTest = new DropRememberMeColumnsFromUsers(database); + + @Test + public void verify_generated_sql_on_postgresql() throws SQLException { + when(database.getDialect()).thenReturn(new PostgreSql()); + + DdlChange.Context context = mock(DdlChange.Context.class); + underTest.execute(context); + + verify(context).execute("ALTER TABLE users DROP COLUMN remember_token, DROP COLUMN remember_token_expires_at"); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropResourceIndexRidFromResourceIndexTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropResourceIndexRidFromResourceIndexTest.java new file mode 100644 index 00000000000..021fe7ad173 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropResourceIndexRidFromResourceIndexTest.java @@ -0,0 +1,58 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; +import org.sonar.db.Database; +import org.sonar.db.dialect.MySql; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static java.util.Arrays.asList; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.when; + +public class DropResourceIndexRidFromResourceIndexTest { + + private Database db = mock(Database.class, Mockito.RETURNS_DEEP_STUBS); + private DdlChange.Context context = mock(DdlChange.Context.class); + + @Before + public void setUp() { + // Some databases have unique names of indexes, so table name is not declared + // when dropping an index ("drop index <index name>"). Because of that MySQL is + // used in the test so that the table name can also be verified + when(db.getDialect()).thenReturn(new MySql()); + } + + @Test + public void drop_index_from_resource_index() throws Exception { + DropResourceIndexRidFromResourceIndex underTest = new DropResourceIndexRidFromResourceIndex(db); + + underTest.execute(context); + + verify(context).execute(asList("DROP INDEX resource_index_rid ON resource_index")); + verifyNoMoreInteractions(context); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotIdColumnFromCeActivityTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotIdColumnFromCeActivityTest.java new file mode 100644 index 00000000000..7fd3a67f091 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotIdColumnFromCeActivityTest.java @@ -0,0 +1,47 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.junit.Test; +import org.sonar.db.Database; +import org.sonar.db.dialect.PostgreSql; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +public class DropSnapshotIdColumnFromCeActivityTest { + + private Database database = mock(Database.class); + private DropSnapshotIdColumnFromCeActivity underTest = new DropSnapshotIdColumnFromCeActivity(database); + + @Test + public void verify_generated_sql_on_postgresql() throws SQLException { + when(database.getDialect()).thenReturn(new PostgreSql()); + + DdlChange.Context context = mock(DdlChange.Context.class); + underTest.execute(context); + + verify(context).execute("ALTER TABLE ce_activity DROP COLUMN snapshot_id"); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotIdColumnFromEventsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotIdColumnFromEventsTest.java new file mode 100644 index 00000000000..aa23dd3070c --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotIdColumnFromEventsTest.java @@ -0,0 +1,47 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.junit.Test; +import org.sonar.db.Database; +import org.sonar.db.dialect.PostgreSql; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +public class DropSnapshotIdColumnFromEventsTest { + + private Database database = mock(Database.class); + private DropSnapshotIdColumnFromEvents underTest = new DropSnapshotIdColumnFromEvents(database); + + @Test + public void verify_generated_sql_on_postgresql() throws SQLException { + when(database.getDialect()).thenReturn(new PostgreSql()); + + DdlChange.Context context = mock(DdlChange.Context.class); + underTest.execute(context); + + verify(context).execute("ALTER TABLE events DROP COLUMN snapshot_id"); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotIdColumnFromMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotIdColumnFromMeasuresTest.java new file mode 100644 index 00000000000..29015a9d80a --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotIdColumnFromMeasuresTest.java @@ -0,0 +1,47 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.junit.Test; +import org.sonar.db.Database; +import org.sonar.db.dialect.PostgreSql; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +public class DropSnapshotIdColumnFromMeasuresTest { + + private Database database = mock(Database.class); + private DropSnapshotIdColumnFromMeasures underTest = new DropSnapshotIdColumnFromMeasures(database); + + @Test + public void verify_generated_sql_on_postgresql() throws SQLException { + when(database.getDialect()).thenReturn(new PostgreSql()); + + DdlChange.Context context = mock(DdlChange.Context.class); + underTest.execute(context); + + verify(context).execute("ALTER TABLE project_measures DROP COLUMN snapshot_id"); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotProjectIdFromSnapshotsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotProjectIdFromSnapshotsTest.java new file mode 100644 index 00000000000..ca673cc5aa9 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropSnapshotProjectIdFromSnapshotsTest.java @@ -0,0 +1,60 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; +import org.sonar.db.Database; +import org.sonar.db.dialect.MySql; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static java.util.Arrays.asList; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.when; + +// FIXME migration is badly named +public class DropSnapshotProjectIdFromSnapshotsTest { + + private Database db = mock(Database.class, Mockito.RETURNS_DEEP_STUBS); + private DdlChange.Context context = mock(DdlChange.Context.class); + + @Before + public void setUp() { + // Some databases have unique names of indexes, so table name is not declared + // when dropping an index ("drop index <index name>"). Because of that MySQL is + // used in the test so that the table name can also be verified + when(db.getDialect()).thenReturn(new MySql()); + } + + @Test + public void drop_two_indices_from_snapshots() throws Exception { + DropSnapshotProjectIdFromSnapshots underTest = new DropSnapshotProjectIdFromSnapshots(db); + + underTest.execute(context); + + verify(context).execute(asList("DROP INDEX snapshot_project_id ON snapshots")); + verify(context).execute(asList("DROP INDEX snapshots_root_project_id ON snapshots")); + verifyNoMoreInteractions(context); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropTemporaryIndicesOf1210Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropTemporaryIndicesOf1210Test.java new file mode 100644 index 00000000000..ac1957492e4 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropTemporaryIndicesOf1210Test.java @@ -0,0 +1,59 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; +import org.sonar.db.Database; +import org.sonar.db.dialect.MySql; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static java.util.Arrays.asList; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.when; + +public class DropTemporaryIndicesOf1210Test { + + private Database db = mock(Database.class, Mockito.RETURNS_DEEP_STUBS); + private DdlChange.Context context = mock(DdlChange.Context.class); + + @Before + public void setUp() { + // Some databases have unique names of indexes, so table name is not declared + // when dropping an index ("drop index <index name>"). Because of that MySQL is + // used in the test so that the table name can also be verified + when(db.getDialect()).thenReturn(new MySql()); + } + + @Test + public void drop_two_indices() throws Exception { + DropTemporaryIndicesOf1210 underTest = new DropTemporaryIndicesOf1210(db); + + underTest.execute(context); + + verify(context).execute(asList("DROP INDEX ce_activity_snapshot_id ON ce_activity")); + verify(context).execute(asList("DROP INDEX dup_index_psid ON duplications_index")); + verifyNoMoreInteractions(context); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropTreeColumnsFromSnapshotsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropTreeColumnsFromSnapshotsTest.java new file mode 100644 index 00000000000..cd295755d7e --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropTreeColumnsFromSnapshotsTest.java @@ -0,0 +1,48 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.junit.Test; +import org.sonar.db.Database; +import org.sonar.db.dialect.PostgreSql; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +public class DropTreeColumnsFromSnapshotsTest { + + private Database database = mock(Database.class); + private DropTreeColumnsFromSnapshots underTest = new DropTreeColumnsFromSnapshots(database); + + @Test + public void verify_generated_sql_on_postgresql() throws SQLException { + when(database.getDialect()).thenReturn(new PostgreSql()); + + DdlChange.Context context = mock(DdlChange.Context.class); + underTest.execute(context); + + verify(context).execute( + "ALTER TABLE snapshots DROP COLUMN parent_snapshot_id, DROP COLUMN scope, DROP COLUMN qualifier, DROP COLUMN root_snapshot_id, DROP COLUMN path, DROP COLUMN depth, DROP COLUMN root_component_uuid"); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropTreesOfSnapshotsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropTreesOfSnapshotsTest.java new file mode 100644 index 00000000000..a115e358c0f --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropTreesOfSnapshotsTest.java @@ -0,0 +1,94 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import java.util.List; +import java.util.Map; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.api.utils.System2; +import org.sonar.db.DbTester; + +import static java.lang.String.valueOf; +import static org.assertj.core.api.Assertions.assertThat; + +public class DropTreesOfSnapshotsTest { + + private static final String SNAPSHOTS_TABLE = "snapshots"; + + @Rule + public DbTester db = DbTester.createForSchema(System2.INSTANCE, DropTreesOfSnapshotsTest.class, + "in_progress_snapshots.sql"); + + private DropTreesOfSnapshots underTest = new DropTreesOfSnapshots(db.database()); + + @Test + public void migration_has_no_effect_on_empty_tables() throws SQLException { + underTest.execute(); + + assertThat(db.countRowsOfTable(SNAPSHOTS_TABLE)).isEqualTo(0); + } + + @Test + public void migration_deletes_snapshots_of_non_root_components() throws SQLException { + insertSnapshot(1L, 0); + insertSnapshot(2L, 2); + insertSnapshot(3L, 1); + insertSnapshot(4L, 0); + insertSnapshot(5L, 3); + db.commit(); + + underTest.execute(); + + verifySnapshots(1L, 4L); + } + + @Test + public void migration_is_reentrant() throws SQLException { + insertSnapshot(1L, 0); + insertSnapshot(2L, 2); + db.commit(); + + underTest.execute(); + verifySnapshots(1L); + + underTest.execute(); + verifySnapshots(1L); + } + + private void insertSnapshot(long id, int depth) { + db.executeInsert( + SNAPSHOTS_TABLE, + "ID", valueOf(id), + "DEPTH", valueOf(depth), + "COMPONENT_UUID", valueOf(id + 10), + "UUID", valueOf(id + 100)); + } + + private void verifySnapshots(long... expectedIds) { + List<Map<String, Object>> rows = db.select("select id from snapshots"); + long[] ids = rows.stream() + .mapToLong(row -> (long) row.get("ID")) + .toArray(); + assertThat(ids).containsOnly(expectedIds); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropUnusedMeasuresColumnsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropUnusedMeasuresColumnsTest.java new file mode 100644 index 00000000000..451c3658502 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/DropUnusedMeasuresColumnsTest.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import org.junit.Before; +import org.junit.Test; +import org.sonar.db.Database; +import org.sonar.db.dialect.PostgreSql; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class DropUnusedMeasuresColumnsTest { + + DropUnusedMeasuresColumns underTest; + Database database; + + @Before + public void setUp() { + database = mock(Database.class); + underTest = new DropUnusedMeasuresColumns(database); + } + + @Test + public void generate_sql_on_postgresql() { + when(database.getDialect()).thenReturn(new PostgreSql()); + assertThat(underTest.generateSql()) + .isEqualTo( + "ALTER TABLE project_measures DROP COLUMN rules_category_id, DROP COLUMN tendency, DROP COLUMN measure_date, DROP COLUMN url, DROP COLUMN rule_priority, DROP COLUMN characteristic_id, DROP COLUMN rule_id"); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/FixProjectUuidOfDeveloperProjectsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/FixProjectUuidOfDeveloperProjectsTest.java new file mode 100644 index 00000000000..5f3872b4579 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/FixProjectUuidOfDeveloperProjectsTest.java @@ -0,0 +1,112 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import java.util.Map; +import javax.annotation.Nullable; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.api.utils.System2; +import org.sonar.db.DbTester; + +import static java.lang.String.valueOf; +import static org.assertj.core.api.Assertions.assertThat; + +public class FixProjectUuidOfDeveloperProjectsTest { + + private static final String TABLE_PROJECTS = "projects"; + private static final String PROJECT_UUID = "U1"; + private static final String FILE_UUID = "U2"; + private static final String DEVELOPER_UUID = "U3"; + private static final String DEV1_IN_PROJECT_UUID = "U4"; + private static final String DEV2_IN_PROJECT_UUID = "U5"; + + @Rule + public DbTester db = DbTester.createForSchema(System2.INSTANCE, FixProjectUuidOfDeveloperProjectsTest.class, + "projects_5.6.sql"); + + private FixProjectUuidOfDeveloperProjects underTest = new FixProjectUuidOfDeveloperProjects(db.database()); + + @Test + public void migration_has_no_effect_on_empty_tables() throws SQLException { + underTest.execute(); + + assertThat(db.countRowsOfTable(TABLE_PROJECTS)).isEqualTo(0); + } + + @Test + public void migration_fixes_project_uuid_of_rows_with_qualifier_DEV_PRJ() throws SQLException { + insertComponents(); + + underTest.execute(); + + verifyComponents(); + } + + @Test + public void migration_is_reentrant() throws SQLException { + insertComponents(); + + underTest.execute(); + verifyComponents(); + + underTest.execute(); + verifyComponents(); + } + + private void verifyComponents() { + verifyProjectUuid(PROJECT_UUID, PROJECT_UUID); + verifyProjectUuid(FILE_UUID, PROJECT_UUID); + verifyProjectUuid(DEVELOPER_UUID, DEVELOPER_UUID); + verifyProjectUuid(DEV1_IN_PROJECT_UUID, DEVELOPER_UUID); + verifyProjectUuid(DEV2_IN_PROJECT_UUID, DEVELOPER_UUID); + } + + private void insertComponents() { + // regular project + insert(PROJECT_UUID, "TRK", null, PROJECT_UUID); + insert(FILE_UUID, "FIL", null, PROJECT_UUID); + // developer + Long personId = insert(DEVELOPER_UUID, "DEV", null, DEVELOPER_UUID); + insert(DEV1_IN_PROJECT_UUID, "DEV_PRJ", personId, /* not correct */PROJECT_UUID); + insert(DEV2_IN_PROJECT_UUID, "DEV_PRJ", personId, /* not correct */PROJECT_UUID); + db.commit(); + } + + private void verifyProjectUuid(String uuid, @Nullable String expectedProjectUuid) { + Map<String, Object> rows = db.selectFirst("select project_uuid as \"projectUuid\" from projects where uuid='" + uuid + "'"); + assertThat(rows.get("projectUuid")).isEqualTo(expectedProjectUuid); + } + + private Long insert(String uuid, String qualifier, @Nullable Long personId, String projectUuid) { + db.executeInsert( + TABLE_PROJECTS, + "UUID", uuid, + "PERSON_ID", personId == null ? null : valueOf(personId), + "PROJECT_UUID", projectUuid, + "QUALIFIER", qualifier); + db.commit(); + return db.select("select ID from projects where UUID='" + uuid + "'").stream() + .findFirst() + .map(f -> (Long) f.get("ID")) + .orElseThrow(() -> new IllegalStateException("NO ID??")); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeAnalysisUuidNotNullOnMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeAnalysisUuidNotNullOnMeasuresTest.java new file mode 100644 index 00000000000..e264e26852c --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeAnalysisUuidNotNullOnMeasuresTest.java @@ -0,0 +1,88 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import java.sql.Types; +import javax.annotation.Nullable; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.sonar.api.utils.System2; +import org.sonar.db.DbTester; + +import static java.lang.String.valueOf; + +public class MakeAnalysisUuidNotNullOnMeasuresTest { + + private static final String TABLE_MEASURES = "project_measures"; + + @Rule + public DbTester db = DbTester.createForSchema(System2.INSTANCE, MakeAnalysisUuidNotNullOnMeasuresTest.class, + "in_progress_measures.sql"); + + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + private MakeAnalysisUuidNotNullOnMeasures underTest = new MakeAnalysisUuidNotNullOnMeasures(db.database()); + + @Test + public void migration_makes_analysis_uuid_not_nullable_on_empty_table() throws SQLException { + underTest.execute(); + + verifyColumnDefinitions(); + } + + @Test + public void migration_makes_analysis_uuid_not_nullable_on_populated_table() throws SQLException { + insertMeasure(1, "U1"); + insertMeasure(2, "U2"); + + underTest.execute(); + + verifyColumnDefinitions(); + } + + @Test + public void migration_fails_if_some_uuid_columns_are_null() throws SQLException { + insertMeasure(2, null); + + expectedException.expect(IllegalStateException.class); + expectedException.expectMessage("Fail to execute"); + + underTest.execute(); + } + + private void insertMeasure(long id, @Nullable String analysisUuid) { + db.executeInsert( + TABLE_MEASURES, + "ID", valueOf(id), + "SNAPSHOT_ID", valueOf(id + 10), + "METRIC_ID", valueOf(id + 100), + "VALUE", valueOf(id + 200), + "COMPONENT_UUID", valueOf(id + 300), + "ANALYSIS_UUID", analysisUuid); + } + + private void verifyColumnDefinitions() { + db.assertColumnDefinition(TABLE_MEASURES, "analysis_uuid", Types.VARCHAR, 50, false); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndexTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndexTest.java new file mode 100644 index 00000000000..106d327d914 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndexTest.java @@ -0,0 +1,112 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import java.sql.Types; +import java.util.List; +import java.util.stream.Collectors; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.sonar.api.utils.System2; +import org.sonar.db.DbTester; + +import static java.lang.String.valueOf; +import static org.assertj.core.api.Assertions.assertThat; + +public class MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndexTest { + + @Rule + public DbTester db = DbTester.createForSchema(System2.INSTANCE, MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndexTest.class, + "in_progress_duplications_index.sql"); + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + private MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndex underTest = new MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndex(db.database()); + + @Test + public void migration_sets_uuid_columns_not_nullable_on_empty_table() throws SQLException { + underTest.execute(); + + verifyColumnDefinitions(); + verifyIndex(); + } + + @Test + public void migration_sets_uuid_columns_not_nullable_on_populated_table() throws SQLException { + insertDuplicationIndex(1L, true, true); + insertDuplicationIndex(2L, true, true); + + underTest.execute(); + + verifyColumnDefinitions(); + verifyIndex(); + assertThat(idsOfRowsInDuplicationsIndex()).containsOnly(1L, 2L); + } + + @Test + public void migration_fails_if_some_component_uuid_columns_are_null() throws SQLException { + insertDuplicationIndex(1L, false, true); + + expectedException.expect(IllegalStateException.class); + expectedException.expectMessage("Fail to execute"); + + underTest.execute(); + } + + @Test + public void migration_fails_if_some_analysis_uuid_columns_are_null() throws SQLException { + insertDuplicationIndex(1L, true, false); + + expectedException.expect(IllegalStateException.class); + expectedException.expectMessage("Fail to execute"); + + underTest.execute(); + } + + private void verifyColumnDefinitions() { + db.assertColumnDefinition("duplications_index", "component_uuid", Types.VARCHAR, 50, false); + db.assertColumnDefinition("duplications_index", "analysis_uuid", Types.VARCHAR, 50, false); + } + + private void verifyIndex() { + db.assertIndex("duplications_index", "duplication_analysis_component", "analysis_uuid", "component_uuid"); + } + + private List<Long> idsOfRowsInDuplicationsIndex() { + return db.select("select ID from duplications_index").stream().map(map -> (Long) map.get("ID")).collect(Collectors.toList()); + } + + private void insertDuplicationIndex(long id, boolean hasComponentUuid, boolean hasAnalysisUuid) { + db.executeInsert( + "duplications_index", + "ID", valueOf(id), + "PROJECT_SNAPSHOT_ID", valueOf(10 + id), + "SNAPSHOT_ID", valueOf(20 + id), + "ANALYSIS_UUID", hasAnalysisUuid ? valueOf(30 + id) : null, + "COMPONENT_UUID", hasComponentUuid ? valueOf(40 + id) : null, + "HASH", "some_hash_" + id, + "INDEX_IN_FILE", "2", + "START_LINE", "3", + "END_LINE", "4"); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidColumnsNotNullOnSnapshotsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidColumnsNotNullOnSnapshotsTest.java new file mode 100644 index 00000000000..1c194c51347 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidColumnsNotNullOnSnapshotsTest.java @@ -0,0 +1,93 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.sonar.api.utils.System2; +import org.sonar.db.DbTester; + +import static java.lang.String.valueOf; + +public class MakeComponentUuidColumnsNotNullOnSnapshotsTest { + + private static final String SNAPSHOTS_TABLE = "snapshots"; + + @Rule + public DbTester db = DbTester.createForSchema(System2.INSTANCE, MakeComponentUuidColumnsNotNullOnSnapshotsTest.class, + "in_progress_snapshots.sql"); + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + private MakeComponentUuidColumnsNotNullOnSnapshots underTest = new MakeComponentUuidColumnsNotNullOnSnapshots(db.database()); + + @Test + public void migration_sets_uuid_columns_not_nullable_on_empty_table() throws SQLException { + underTest.execute(); + + verifyColumnDefinitions(); + verifyIndices(); + } + + @Test + public void migration_sets_uuid_columns_not_nullable_on_populated_table() throws SQLException { + insertSnapshots(1, true, true); + insertSnapshots(2, true, true); + + underTest.execute(); + + verifyColumnDefinitions(); + verifyIndices(); + } + + @Test + public void migration_fails_if_some_uuid_columns_are_null() throws SQLException { + insertSnapshots(1, false, true); + + expectedException.expect(IllegalStateException.class); + expectedException.expectMessage("Fail to execute"); + + underTest.execute(); + } + + private void verifyColumnDefinitions() { + db.assertColumnDefinition(SNAPSHOTS_TABLE, "component_uuid", Types.VARCHAR, 50, false); + db.assertColumnDefinition(SNAPSHOTS_TABLE, "root_component_uuid", Types.VARCHAR, 50, false); + } + + private void verifyIndices() { + db.assertIndex(SNAPSHOTS_TABLE, "snapshot_component", "component_uuid"); + db.assertIndex(SNAPSHOTS_TABLE, "snapshot_root_component", "root_component_uuid"); + } + + private void insertSnapshots(long id, boolean hasComponentUiid, boolean hasRootComponentUuid) { + db.executeInsert( + SNAPSHOTS_TABLE, + "ID", valueOf(id), + "ISLAST", "TRUE", + "PROJECT_ID", valueOf(id + 300), + "COMPONENT_UUID", hasComponentUiid ? "uuid_" + id : null, + "ROOT_COMPONENT_UUID", hasRootComponentUuid ? "root_uuid_" + id : null); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidNotNullOnMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidNotNullOnMeasuresTest.java new file mode 100644 index 00000000000..c144d2c3165 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidNotNullOnMeasuresTest.java @@ -0,0 +1,93 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import java.sql.Types; +import java.util.List; +import java.util.stream.Collectors; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.sonar.api.utils.System2; +import org.sonar.db.DbTester; + +import static java.lang.String.valueOf; +import static org.assertj.core.api.Assertions.assertThat; + +public class MakeComponentUuidNotNullOnMeasuresTest { + + @Rule + public DbTester db = DbTester.createForSchema(System2.INSTANCE, MakeComponentUuidNotNullOnMeasuresTest.class, + "in_progress_project_measures.sql"); + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + private MakeComponentUuidNotNullOnMeasures underTest = new MakeComponentUuidNotNullOnMeasures(db.database()); + + @Test + public void migration_sets_uuid_columns_not_nullable_on_empty_table() throws SQLException { + underTest.execute(); + + verifyColumnDefinitions(); + } + + @Test + public void migration_sets_uuid_columns_not_nullable_on_populated_table() throws SQLException { + insertMeasure(1L, true); + insertMeasure(2L, true); + + underTest.execute(); + + verifyColumnDefinitions(); + assertThat(idsOfRowsInMeasures()).containsOnly(1L, 2L); + } + + @Test + public void migration_fails_if_some_uuid_columns_are_null() throws SQLException { + insertMeasure(1L, false); + + expectedException.expect(IllegalStateException.class); + expectedException.expectMessage("Fail to execute"); + + underTest.execute(); + } + + private void verifyColumnDefinitions() { + db.assertColumnDefinition("project_measures", "component_uuid", Types.VARCHAR, 50, false); + } + + private List<Long> idsOfRowsInMeasures() { + return db.select("select ID from project_measures").stream().map(map -> (Long) map.get("ID")).collect(Collectors.toList()); + } + + private void insertMeasure(long id, boolean hasComponentUuid) { + db.executeInsert( + "project_measures", + "ID", valueOf(id), + "METRIC_ID", valueOf(id + 10), + "SNAPSHOT_ID", valueOf(id + 100), + "VALUE", valueOf(id + 1000)); + + if (hasComponentUuid) { + db.executeUpdateSql("update project_measures set COMPONENT_UUID=? where id=?", "uuid_" + id, valueOf(id)); + } + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeProfileKeyNotNullOnActivitiesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeProfileKeyNotNullOnActivitiesTest.java new file mode 100644 index 00000000000..e889f4d4adb --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeProfileKeyNotNullOnActivitiesTest.java @@ -0,0 +1,80 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.sonar.api.utils.System2; +import org.sonar.db.DbTester; + +public class MakeProfileKeyNotNullOnActivitiesTest { + + private static final String TABLE_ACTIVITIES = "activities"; + + @Rule + public DbTester db = DbTester.createForSchema(System2.INSTANCE, MakeProfileKeyNotNullOnActivitiesTest.class, "activities.sql"); + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + private MakeProfileKeyNotNullOnActivities underTest = new MakeProfileKeyNotNullOnActivities(db.database()); + + @Test + public void migration_sets_uuid_column_not_nullable_on_empty_table() throws SQLException { + underTest.execute(); + + verifyColumnDefinitions(); + } + + @Test + public void migration_sets_uuid_column_not_nullable_on_populated_table() throws SQLException { + insertActivity(true); + insertActivity(true); + + underTest.execute(); + + verifyColumnDefinitions(); + } + + @Test + public void migration_fails_if_some_row_has_a_null_profile_key() throws SQLException { + insertActivity(false); + + expectedException.expect(IllegalStateException.class); + expectedException.expectMessage("Fail to execute"); + + underTest.execute(); + } + + private void verifyColumnDefinitions() { + db.assertColumnDefinition(TABLE_ACTIVITIES, "profile_key", Types.VARCHAR, 255, false); + } + + private void insertActivity(boolean hasProfileKey) { + db.executeInsert( + TABLE_ACTIVITIES, + "user_login", "login", + "profile_key", hasProfileKey ? "my_profile_key" : null); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnNotNullOnSnapshotsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnNotNullOnSnapshotsTest.java new file mode 100644 index 00000000000..97e1a4ff5aa --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnNotNullOnSnapshotsTest.java @@ -0,0 +1,86 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.sonar.api.utils.System2; +import org.sonar.db.DbTester; + +import static java.lang.String.valueOf; + +public class MakeUuidColumnNotNullOnSnapshotsTest { + + private static final String TABLE_SNAPSHOTS = "snapshots"; + + @Rule + public DbTester db = DbTester.createForSchema(System2.INSTANCE, MakeUuidColumnNotNullOnSnapshotsTest.class, + "in_progress_snapshots.sql"); + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + private MakeUuidColumnNotNullOnSnapshots underTest = new MakeUuidColumnNotNullOnSnapshots(db.database()); + + @Test + public void migration_sets_uuid_column_not_nullable_on_empty_table() throws SQLException { + underTest.execute(); + + verifyColumnDefinitions(); + } + + @Test + public void migration_sets_uuid_column_not_nullable_on_populated_table() throws SQLException { + insertSnapshot(1, true); + insertSnapshot(2, true); + + underTest.execute(); + + verifyColumnDefinitions(); + } + + @Test + public void migration_fails_if_some_row_has_a_null_uuid() throws SQLException { + insertSnapshot(1, false); + + expectedException.expect(IllegalStateException.class); + expectedException.expectMessage("Fail to execute"); + + underTest.execute(); + } + + private void verifyColumnDefinitions() { + db.assertColumnDefinition(TABLE_SNAPSHOTS, "uuid", Types.VARCHAR, 50, false); + } + + private String insertSnapshot(long id, boolean hasUuid) { + String uuid = "uuid_" + id; + db.executeInsert( + TABLE_SNAPSHOTS, + "ID", valueOf(id), + "COMPONENT_UUID", valueOf(id + 10), + "ROOT_COMPONENT_UUID", valueOf(id + 100), + "UUID", hasUuid ? "uuid_" + id : null); + return uuid; + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnsNotNullOnProjectsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnsNotNullOnProjectsTest.java new file mode 100644 index 00000000000..a73dbc68719 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnsNotNullOnProjectsTest.java @@ -0,0 +1,102 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.sonar.api.utils.System2; +import org.sonar.db.DbTester; + +import static java.lang.String.valueOf; + +public class MakeUuidColumnsNotNullOnProjectsTest { + + private static final String PROJECTS_TABLE = "projects"; + + @Rule + public DbTester db = DbTester.createForSchema(System2.INSTANCE, MakeUuidColumnsNotNullOnProjectsTest.class, + "in_progress_projects.sql"); + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + private MakeUuidColumnsNotNullOnProjects underTest = new MakeUuidColumnsNotNullOnProjects(db.database()); + + @Test + public void migration_sets_uuid_columns_not_nullable_on_empty_table() throws SQLException { + underTest.execute(); + + verifyColumnDefinitions(); + verifyIndex(); + } + + @Test + public void migration_sets_uuid_columns_not_nullable_on_populated_table() throws SQLException { + insertComponent(1, true, true); + insertComponent(2, true, true); + + underTest.execute(); + + verifyColumnDefinitions(); + verifyIndex(); + } + + @Test + public void migration_fails_if_some_row_has_a_null_uuid() throws SQLException { + insertComponent(1, false, true); + + expectedException.expect(IllegalStateException.class); + expectedException.expectMessage("Fail to execute"); + + underTest.execute(); + } + + @Test + public void migration_fails_if_some_row_has_a_null_rootuuid() throws SQLException { + insertComponent(1, true, false); + + expectedException.expect(IllegalStateException.class); + expectedException.expectMessage("Fail to execute"); + + underTest.execute(); + } + + private void verifyColumnDefinitions() { + db.assertColumnDefinition(PROJECTS_TABLE, "uuid", Types.VARCHAR, 50, false); + db.assertColumnDefinition(PROJECTS_TABLE, "root_uuid", Types.VARCHAR, 50, false); + } + + private void verifyIndex() { + db.assertIndex(PROJECTS_TABLE, "projects_root_uuid", "root_uuid"); + } + + private String insertComponent(long id, boolean hasUuid, boolean hasRootUuid) { + String uuid = "uuid_" + id; + db.executeInsert( + "projects", + "ID", valueOf(id), + "UUID", hasUuid ? "uuid_" + id : null, + "ROOT_UUID", hasRootUuid ? "root_uuuid_" + id : null); + return uuid; + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnsNotNullOnResourceIndexTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnsNotNullOnResourceIndexTest.java new file mode 100644 index 00000000000..3d7423cdcf7 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnsNotNullOnResourceIndexTest.java @@ -0,0 +1,98 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.sonar.api.utils.System2; +import org.sonar.db.DbTester; + +import static java.lang.String.valueOf; + +public class MakeUuidColumnsNotNullOnResourceIndexTest { + + @Rule + public DbTester db = DbTester.createForSchema(System2.INSTANCE, MakeUuidColumnsNotNullOnResourceIndexTest.class, + "in_progress_resourceindex.sql"); + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + private MakeUuidColumnsNotNullOnResourceIndex underTest = new MakeUuidColumnsNotNullOnResourceIndex(db.database()); + + @Test + public void migration_sets_uuid_columns_not_nullable_on_empty_table() throws SQLException { + underTest.execute(); + + verifyColumnDefinitions(); + verifyIndex(); + } + + @Test + public void migration_sets_uuid_columns_not_nullable_on_populated_table() throws SQLException { + insertResourceIndex(1, true, true); + insertResourceIndex(2, true, true); + + underTest.execute(); + + verifyColumnDefinitions(); + verifyIndex(); + } + + @Test + public void migration_fails_if_some_uuid_columns_are_null() throws SQLException { + insertResourceIndex(1, false, true); + + expectedException.expect(IllegalStateException.class); + expectedException.expectMessage("Fail to execute"); + + underTest.execute(); + } + + private void verifyColumnDefinitions() { + db.assertColumnDefinition("resource_index", "component_uuid", Types.VARCHAR, 50, false); + db.assertColumnDefinition("resource_index", "root_component_uuid", Types.VARCHAR, 50, false); + } + + private void verifyIndex() { + db.assertIndex("resource_index", "resource_index_component", "component_uuid"); + } + + private void insertResourceIndex(long id, boolean hasComponentUiid, boolean hasRootComponentUuid) { + db.executeInsert( + "resource_index", + "ID", valueOf(id), + "KEE", "key_" + id, + "POSITION", valueOf(id + 100), + "NAME_SIZE", valueOf(id + 1000), + "RESOURCE_ID", valueOf(id + 300), + "ROOT_PROJECT_ID", valueOf(id + 4000), + "QUALIFIER", "PROJECT"); + + if (hasComponentUiid) { + db.executeUpdateSql("update resource_index set COMPONENT_UUID=? where id=?", "uuid_" + id, valueOf(id)); + } + if (hasRootComponentUuid) { + db.executeUpdateSql("update resource_index set ROOT_COMPONENT_UUID=? where id=?", "root_uuid_" + id, valueOf(id)); + } + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/Migration1223Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/Migration1223Test.java new file mode 100644 index 00000000000..f63bfc07bae --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/Migration1223Test.java @@ -0,0 +1,76 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.Connection; +import java.sql.DatabaseMetaData; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import javax.sql.DataSource; +import org.junit.Before; +import org.junit.Test; +import org.sonar.db.Database; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class Migration1223Test { + private Database database = mock(Database.class); + + private enum Call { + CALL_1, + CALL_2 + } + + private List<Call> calls = new ArrayList<>(); + + private FixProjectUuidOfDeveloperProjects projectUuidOfDeveloperProjects = new FixProjectUuidOfDeveloperProjects(database) { + @Override + public void execute(Context context) throws SQLException { + calls.add(Call.CALL_1); + } + }; + private CleanUsurperRootComponents cleanUsurperRootComponents = new CleanUsurperRootComponents(database) { + @Override + public void execute(Context context) throws SQLException { + calls.add(Call.CALL_2); + } + }; + + private Migration1223 underTest = new Migration1223(projectUuidOfDeveloperProjects, cleanUsurperRootComponents); + + @Before + public void setUp() throws Exception { + DataSource dataSource = mock(DataSource.class); + when(database.getDataSource()).thenReturn(dataSource); + Connection connection = mock(Connection.class); + when(dataSource.getConnection()).thenReturn(connection); + when(connection.getMetaData()).thenReturn(mock(DatabaseMetaData.class)); + } + + @Test + public void execute_calls_2_delegates_in_order() throws SQLException { + underTest.execute(); + + assertThat(calls).containsExactly(Call.CALL_1, Call.CALL_2); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidColumnOnCeActivityTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidColumnOnCeActivityTest.java new file mode 100644 index 00000000000..f11088aeb2f --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidColumnOnCeActivityTest.java @@ -0,0 +1,115 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import java.util.Map; +import javax.annotation.Nullable; +import org.apache.commons.lang.RandomStringUtils; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.api.utils.System2; +import org.sonar.db.DbTester; + +import static java.lang.String.valueOf; +import static org.assertj.core.api.Assertions.assertThat; + +public class PopulateAnalysisUuidColumnOnCeActivityTest { + + private static final long A_DATE = 123_456L; + private static final String TABLE_CE_ACTIVITY = "ce_activity"; + private static final String TABLE_SNAPSHOTS = "snapshots"; + + @Rule + public DbTester db = DbTester.createForSchema(System2.INSTANCE, PopulateAnalysisUuidColumnOnCeActivityTest.class, + "in_progress_ce_activity.sql"); + + private PopulateAnalysisUuidColumnOnCeActivity underTest = new PopulateAnalysisUuidColumnOnCeActivity(db.database()); + + @Test + public void migration_has_no_effect_on_empty_tables() throws SQLException { + underTest.execute(); + + assertThat(db.countRowsOfTable(TABLE_CE_ACTIVITY)).isEqualTo(0); + } + + @Test + public void migration_generates_uuids() throws SQLException { + insertSnapshot(1, "U1"); + insertSnapshot(2, "U2"); + insertCeActivity(1, null); + insertCeActivity(2, 1L); + insertCeActivity(3, 2L); + db.commit(); + + underTest.execute(); + + verifyAnalysisUuid(1, null); + verifyAnalysisUuid(2, "U1"); + verifyAnalysisUuid(3, "U2"); + } + + @Test + public void migration_is_reentrant() throws SQLException { + insertSnapshot(1, "U1"); + insertCeActivity(1, null); + insertCeActivity(2, 1L); + + underTest.execute(); + verifyAnalysisUuid(1, null); + verifyAnalysisUuid(2, "U1"); + + underTest.execute(); + verifyAnalysisUuid(1, null); + verifyAnalysisUuid(2, "U1"); + } + + private void verifyAnalysisUuid(int activityId, @Nullable String expectedAnalysisUuid) { + Map<String, Object> rows = db.selectFirst("select analysis_uuid as \"analysisUuid\" from ce_activity where id=" + activityId); + assertThat(rows.get("analysisUuid")).isEqualTo(expectedAnalysisUuid); + } + + private String insertSnapshot(long id, String uuid) { + db.executeInsert( + TABLE_SNAPSHOTS, + "ID", valueOf(id), + "UUID", uuid, + "COMPONENT_UUID", valueOf(id + 10), + "ROOT_COMPONENT_UUID", valueOf(id + 100), + "SCOPE", "PRJ", + "QUALIFIER", "FIL"); + return uuid; + } + + private void insertCeActivity(long id, @Nullable Long snapshotId) { + db.executeInsert( + TABLE_CE_ACTIVITY, + "uuid", valueOf(id), + "snapshot_id", snapshotId == null ? null : valueOf(snapshotId), + "task_type", "REPORT", + "status", "SUCCESS", + "is_last", valueOf(true), + "is_last_key", RandomStringUtils.randomAlphabetic(10), + "created_at", valueOf(A_DATE), + "updated_at", valueOf(A_DATE), + "submitted_at", valueOf(A_DATE)); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnEventsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnEventsTest.java new file mode 100644 index 00000000000..593910d19a7 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnEventsTest.java @@ -0,0 +1,138 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import java.util.Map; +import javax.annotation.Nullable; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.api.resources.Qualifiers; +import org.sonar.api.resources.Scopes; +import org.sonar.api.utils.System2; +import org.sonar.db.DbTester; + +import static java.lang.String.valueOf; +import static org.assertj.core.api.Assertions.assertThat; + +public class PopulateAnalysisUuidOnEventsTest { + + private static final String TABLE_EVENTS = "events"; + private static final String TABLE_SNAPSHOTS = "snapshots"; + + @Rule + public DbTester db = DbTester.createForSchema(System2.INSTANCE, PopulateAnalysisUuidOnEventsTest.class, + "in_progress_events_with_snapshots.sql"); + + private PopulateAnalysisUuidOnEvents underTest = new PopulateAnalysisUuidOnEvents(db.database()); + + @Test + public void migration_has_no_effect_on_empty_tables() throws SQLException { + underTest.execute(); + + assertThat(db.countRowsOfTable(TABLE_EVENTS)).isEqualTo(0); + } + + @Test + public void migration_populates_uuids_of_root_components_only() throws SQLException { + insertSnapshot(1, "U1", Scopes.PROJECT, Qualifiers.PROJECT); + insertSnapshot(2, "U2", Scopes.PROJECT, Qualifiers.MODULE); + insertSnapshot(3, "U3", Scopes.DIRECTORY, Qualifiers.DIRECTORY); + insertSnapshot(4, "U4", Scopes.FILE, Qualifiers.FILE); + insertSnapshot(5, "U5", Scopes.FILE, Qualifiers.UNIT_TEST_FILE); + insertSnapshot(6, "U6", Scopes.PROJECT, Qualifiers.VIEW); + insertSnapshot(7, "U7", Scopes.PROJECT, Qualifiers.SUBVIEW); + insertSnapshot(8, "U8", Scopes.FILE, Qualifiers.PROJECT); + insertSnapshot(9, "U9", Scopes.PROJECT, "DEV"); + insertSnapshot(10, "U10", Scopes.PROJECT, "DEV_PRJ"); + insertSnapshot(11, "U11", "FOO", "BAR"); + insertEvent(21, null); + insertEvent(22, 1L); + insertEvent(23, 2L); + insertEvent(24, 3L); + insertEvent(25, 4L); + insertEvent(26, 5L); + insertEvent(27, 6L); + insertEvent(28, 7L); + insertEvent(29, 8L); + insertEvent(210, 9L); + insertEvent(211, 10L); + insertEvent(212, 11L); + db.commit(); + + underTest.execute(); + + verifyAnalysisUuid(21, null); + verifyAnalysisUuid(22, "U1"); + verifyAnalysisUuid(23, null); + verifyAnalysisUuid(24, null); + verifyAnalysisUuid(25, null); + verifyAnalysisUuid(26, null); + verifyAnalysisUuid(27, "U6"); + verifyAnalysisUuid(28, null); + verifyAnalysisUuid(29, null); + verifyAnalysisUuid(210, "U9"); + verifyAnalysisUuid(212, null); + verifyAnalysisUuid(211, null); + } + + @Test + public void migration_is_reentrant() throws SQLException { + insertSnapshot(1, "U1", Scopes.PROJECT, Qualifiers.PROJECT); + insertEvent(1, null); + insertEvent(2, 1L); + + underTest.execute(); + verifyAnalysisUuid(1, null); + verifyAnalysisUuid(2, "U1"); + + underTest.execute(); + verifyAnalysisUuid(1, null); + verifyAnalysisUuid(2, "U1"); + } + + private void verifyAnalysisUuid(int eventId, @Nullable String expectedAnalysisUuid) { + Map<String, Object> rows = db.selectFirst("select analysis_uuid as \"analysisUuid\" from events where id=" + eventId); + assertThat(rows.get("analysisUuid")).isEqualTo(expectedAnalysisUuid); + } + + private String insertSnapshot(long id, String uuid, String scope, String qualifier) { + db.executeInsert( + TABLE_SNAPSHOTS, + "ID", valueOf(id), + "UUID", uuid, + "COMPONENT_UUID", valueOf(id + 10), + "ROOT_COMPONENT_UUID", valueOf(id + 100), + "SCOPE", scope, + "QUALIFIER", qualifier); + return uuid; + } + + private void insertEvent(long id, @Nullable Long snapshotId) { + db.executeInsert( + TABLE_EVENTS, + "ID", valueOf(id), + "NAME", "name_" + id, + "SNAPSHOT_ID", snapshotId == null ? null : valueOf(snapshotId), + "EVENT_DATE", valueOf(1 + 100), + "CREATED_AT", valueOf(1 + 300)); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnMeasuresTest.java new file mode 100644 index 00000000000..702e63c80dd --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnMeasuresTest.java @@ -0,0 +1,107 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import java.util.Map; +import javax.annotation.Nullable; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.api.resources.Qualifiers; +import org.sonar.api.utils.System2; +import org.sonar.db.DbTester; + +import static java.lang.String.valueOf; +import static org.assertj.core.api.Assertions.assertThat; + +public class PopulateAnalysisUuidOnMeasuresTest { + + private static final String TABLE_MEASURES = "project_measures"; + private static final String TABLE_SNAPSHOTS = "snapshots"; + + @Rule + public DbTester db = DbTester.createForSchema(System2.INSTANCE, PopulateAnalysisUuidOnMeasuresTest.class, + "old_measures.sql"); + + private PopulateAnalysisUuidOnMeasures underTest = new PopulateAnalysisUuidOnMeasures(db.database()); + + @Test + public void migration_has_no_effect_on_empty_tables() throws SQLException { + underTest.execute(); + + assertThat(db.countRowsOfTable(TABLE_MEASURES)).isEqualTo(0); + } + + @Test + public void migration_populates_analysis_uuids() throws SQLException { + insertSnapshot(1, "U1", Qualifiers.PROJECT, null); + insertSnapshot(2, "U2", Qualifiers.DIRECTORY, 1L); + insertSnapshot(3, "U3", Qualifiers.FILE, 1L); + insertMeasure(21, 1); + insertMeasure(22, 2); + insertMeasure(23, 3); + db.commit(); + + underTest.execute(); + + verifyAnalysisUuid(21, "U1"); + verifyAnalysisUuid(22, "U1"); + verifyAnalysisUuid(23, "U1"); + } + + @Test + public void migration_is_reentrant() throws SQLException { + insertSnapshot(1, "U1", Qualifiers.PROJECT, 1L); + insertMeasure(21, 1); + + underTest.execute(); + verifyAnalysisUuid(21, "U1"); + + underTest.execute(); + verifyAnalysisUuid(21, "U1"); + } + + private void verifyAnalysisUuid(int measureId, @Nullable String expectedAnalysisUuid) { + Map<String, Object> rows = db.selectFirst("select analysis_uuid as \"analysisUuid\" from project_measures where id=" + measureId); + assertThat(rows.get("analysisUuid")).isEqualTo(expectedAnalysisUuid); + } + + private String insertSnapshot(long id, String uuid, String qualifier, @Nullable Long rootSnapshotId) { + db.executeInsert( + TABLE_SNAPSHOTS, + "ID", valueOf(id), + "UUID", uuid, + "COMPONENT_UUID", valueOf(id + 10), + "ROOT_COMPONENT_UUID", valueOf(id + 10), + "ROOT_SNAPSHOT_ID", rootSnapshotId != null ? valueOf(rootSnapshotId) : null, + "QUALIFIER", qualifier); + return uuid; + } + + private void insertMeasure(long id, long snapshotId) { + db.executeInsert( + TABLE_MEASURES, + "ID", valueOf(id), + "SNAPSHOT_ID", valueOf(snapshotId), + "METRIC_ID", valueOf(id + 100), + "VALUE", valueOf(id + 200), + "COMPONENT_UUID", valueOf(id + 300)); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndexTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndexTest.java new file mode 100644 index 00000000000..716de2d7207 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndexTest.java @@ -0,0 +1,121 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import java.util.List; +import java.util.Map; +import javax.annotation.Nullable; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.api.utils.System2; +import org.sonar.db.DbTester; + +import static java.lang.String.valueOf; +import static org.assertj.core.api.Assertions.assertThat; + +public class PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndexTest { + + @Rule + public DbTester db = DbTester.createForSchema(System2.INSTANCE, PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndexTest.class, + "in_progress_measures_with_snapshots.sql"); + + private PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndex underTest = new PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndex(db.database()); + + @Test + public void migration_has_no_effect_on_empty_tables() throws SQLException { + underTest.execute(); + + assertThat(db.countRowsOfTable("duplications_index")).isEqualTo(0); + assertThat(db.countRowsOfTable("snapshots")).isEqualTo(0); + } + + @Test + public void migration_updates_component_uuid_with_values_from_table_snapshots_when_they_exist() throws SQLException { + insertSnapshot(40, "cpt1"); + String rootUuid1 = insertSnapshot(50, "cpt2"); + insertSnapshot(60, "cpt3"); + String rootUuid2 = insertSnapshot(70, "cpt4"); + + insertDuplicationIndex(1, 40, 50); + insertDuplicationIndex(2, 40, 50); + insertDuplicationIndex(3, 40, 70); + insertDuplicationIndex(4, 60, 110); // 110 doesn't exist + insertDuplicationIndex(5, 90, 120); // 90 and 120 does not exist + insertDuplicationIndex(6, 100, 70); // 100 does not exist + db.commit(); + + underTest.execute(); + + verifyDuplicationsIndex(1, 40, "cpt1", rootUuid1); + verifyDuplicationsIndex(2, 40, "cpt1", rootUuid1); + verifyDuplicationsIndex(3, 40, "cpt1", rootUuid2); + verifyDuplicationsIndex(4, 60, "cpt3", null); + verifyDuplicationsIndex(5, 90, null, null); + verifyDuplicationsIndex(6, 100, null, rootUuid2); + } + + @Test + public void migration_is_reentrant() throws SQLException { + insertSnapshot(40, "cpt1"); + String rootUuid = insertSnapshot(50, "cp2"); + insertDuplicationIndex(1, 40, 50); + + underTest.execute(); + verifyDuplicationsIndex(1, 40, "cpt1", rootUuid); + + underTest.execute(); + verifyDuplicationsIndex(1, 40, "cpt1", rootUuid); + + } + + private void verifyDuplicationsIndex(long id, long snapshotId, @Nullable String componentUuid, @Nullable String analysisUuid) { + List<Map<String, Object>> rows = db.select("select SNAPSHOT_ID, COMPONENT_UUID,ANALYSIS_UUID from duplications_index where ID=" + id); + assertThat(rows).hasSize(1); + Map<String, Object> row = rows.get(0); + assertThat(row.get("SNAPSHOT_ID")).isEqualTo(snapshotId); + assertThat(row.get("COMPONENT_UUID")).isEqualTo(componentUuid); + assertThat(row.get("ANALYSIS_UUID")).isEqualTo(analysisUuid); + } + + private String insertSnapshot(long id, String componentUuid) { + String uuid = "uuid_" + id; + db.executeInsert( + "snapshots", + "uuid", uuid, + "id", valueOf(id), + "component_uuid", componentUuid, + "root_component_uuid", valueOf(id + 100)); + return uuid; + } + + private void insertDuplicationIndex(long id, long snapshotId, long projectSnapshotId) { + db.executeInsert( + "duplications_index", + "ID", valueOf(id), + "PROJECT_SNAPSHOT_ID", valueOf(projectSnapshotId), + "SNAPSHOT_ID", valueOf(snapshotId), + "HASH", "some_hash_" + id, + "INDEX_IN_FILE", "2", + "START_LINE", "3", + "END_LINE", "4"); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidColumnsOfSnapshotsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidColumnsOfSnapshotsTest.java new file mode 100644 index 00000000000..8efcf70226e --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidColumnsOfSnapshotsTest.java @@ -0,0 +1,121 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import java.util.List; +import java.util.Map; +import javax.annotation.Nullable; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.api.utils.System2; +import org.sonar.db.DbTester; + +import static java.lang.String.valueOf; +import static org.assertj.core.api.Assertions.assertThat; + +public class PopulateComponentUuidColumnsOfSnapshotsTest { + + private static final String SNAPSHOTS_TABLE = "snapshots"; + + @Rule + public DbTester db = DbTester.createForSchema(System2.INSTANCE, PopulateComponentUuidColumnsOfSnapshotsTest.class, + "in_progress_snapshots_with_projects.sql"); + + private PopulateComponentUuidColumnsOfSnapshots underTest = new PopulateComponentUuidColumnsOfSnapshots(db.database()); + + @Test + public void migration_has_no_effect_on_empty_tables() throws SQLException { + underTest.execute(); + + assertThat(db.countRowsOfTable(SNAPSHOTS_TABLE)).isEqualTo(0); + assertThat(db.countRowsOfTable("projects")).isEqualTo(0); + } + + @Test + public void migration_updates_uuid_columns_with_values_from_table_projects_when_they_exist() throws SQLException { + String uuid1 = insertComponent(40); + String uuid2 = insertComponent(50); + String uuid3 = insertComponent(60); + String uuid4 = insertComponent(70); + String uuid5 = insertComponent(80); + + insertSnapshots(1, 40, 50L); + insertSnapshots(2, 60, 70L); + insertSnapshots(3, 90, 70L); // 90 does not exist + insertSnapshots(4, 40, 100L); // 100 does not exist + insertSnapshots(5, 110, 100L); // 110 and 100 do not exist + insertSnapshots(6, 80, null); // no root + insertSnapshots(7, 120, null); // no root and 120 does not exist + db.commit(); + + underTest.execute(); + + verifySnapshots(1, 40, uuid1, 50L, uuid2); + verifySnapshots(2, 60, uuid3, 70L, uuid4); + verifySnapshots(3, 90, null, 70L, uuid4); + verifySnapshots(4, 40, uuid1, 100L, null); + verifySnapshots(5, 110, null, 100L, null); + verifySnapshots(6, 80, uuid5, null, null); + verifySnapshots(7, 120, null, null, null); + } + + @Test + public void migration_is_reentrant() throws SQLException { + String uuid1 = insertComponent(40); + String uuid2 = insertComponent(50); + insertSnapshots(1, 40, 50L); + + underTest.execute(); + verifySnapshots(1, 40, uuid1, 50L, uuid2); + + underTest.execute(); + verifySnapshots(1, 40, uuid1, 50L, uuid2); + } + + private void insertSnapshots(long id, long projectId, @Nullable Long rootId) { + db.executeInsert( + SNAPSHOTS_TABLE, + "ID", valueOf(id), + "ISLAST", "TRUE", + "PROJECT_ID", valueOf(projectId), + "ROOT_PROJECT_ID", rootId == null ? null : valueOf(rootId)); + } + + private String insertComponent(long id) { + String uuid = "uuid_" + id; + db.executeInsert( + "projects", + "ID", valueOf(id), + "UUID", uuid); + return uuid; + } + + private void verifySnapshots(long id, long resourceId, @Nullable String componentUuid, @Nullable Long rootProjectId, @Nullable String rootComponentUuid) { + List<Map<String, Object>> rows = db.select("select PROJECT_ID, COMPONENT_UUID, ROOT_PROJECT_ID, ROOT_COMPONENT_UUID from snapshots where ID=" + id); + assertThat(rows).hasSize(1); + Map<String, Object> row = rows.get(0); + assertThat(row.get("PROJECT_ID")).isEqualTo(resourceId); + assertThat(row.get("COMPONENT_UUID")).isEqualTo(componentUuid); + assertThat(row.get("ROOT_PROJECT_ID")).isEqualTo(rootProjectId); + assertThat(row.get("ROOT_COMPONENT_UUID")).isEqualTo(rootComponentUuid); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidOfMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidOfMeasuresTest.java new file mode 100644 index 00000000000..02f148d9e9d --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidOfMeasuresTest.java @@ -0,0 +1,123 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import java.util.List; +import java.util.Map; +import javax.annotation.Nullable; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.api.utils.System2; +import org.sonar.db.DbTester; + +import static java.lang.String.valueOf; +import static org.assertj.core.api.Assertions.assertThat; + +public class PopulateComponentUuidOfMeasuresTest { + + private static final int SNAPSHOT_ID_1 = 40; + private static final int SNAPSHOT_ID_2 = 50; + private static final int SNAPSHOT_ID_3 = 60; + private static final int SNAPSHOT_ID_4 = 70; + private static final int SNAPSHOT_ID_5 = 80; + + private static final int COMPONENT_ID_1 = 400; + private static final int COMPONENT_ID_2 = 500; + private static final int COMPONENT_ID_3 = 600; + + private static final String COMPONENT_UUID_1 = "U400"; + private static final String COMPONENT_UUID_2 = "U500"; + + @Rule + public DbTester db = DbTester.createForSchema(System2.INSTANCE, PopulateComponentUuidOfMeasuresTest.class, + "in_progress_measures_with_projects.sql"); + + private PopulateComponentUuidOfMeasures underTest = new PopulateComponentUuidOfMeasures(db.database()); + + @Test + public void migration_has_no_effect_on_empty_tables() throws SQLException { + underTest.execute(); + + assertThat(db.countRowsOfTable("project_measures")).isEqualTo(0); + assertThat(db.countRowsOfTable("snapshots")).isEqualTo(0); + } + + @Test + public void migration_updates_component_uuid_with_values_from_table_snapshots_when_they_exist() throws SQLException { + insertSnapshot(SNAPSHOT_ID_1, COMPONENT_UUID_1); + insertSnapshot(SNAPSHOT_ID_2, COMPONENT_UUID_1); + insertSnapshot(SNAPSHOT_ID_3, COMPONENT_UUID_2); + insertSnapshot(SNAPSHOT_ID_4, COMPONENT_UUID_2); + + insertMeasure(1, SNAPSHOT_ID_1, COMPONENT_ID_1); + insertMeasure(2, SNAPSHOT_ID_2, COMPONENT_ID_1); + insertMeasure(3, SNAPSHOT_ID_3, COMPONENT_ID_2); + insertMeasure(4, SNAPSHOT_ID_5, COMPONENT_ID_3); // snapshot does not exist + db.commit(); + + underTest.execute(); + + verifyMeasure(1, SNAPSHOT_ID_1, COMPONENT_UUID_1); + verifyMeasure(2, SNAPSHOT_ID_2, COMPONENT_UUID_1); + verifyMeasure(3, SNAPSHOT_ID_3, COMPONENT_UUID_2); + verifyMeasure(4, SNAPSHOT_ID_5, null); + } + + @Test + public void migration_is_reentrant() throws SQLException { + insertSnapshot(SNAPSHOT_ID_1, COMPONENT_UUID_1); + insertMeasure(1, SNAPSHOT_ID_1, COMPONENT_ID_1); + + underTest.execute(); + verifyMeasure(1, SNAPSHOT_ID_1, COMPONENT_UUID_1); + + underTest.execute(); + verifyMeasure(1, SNAPSHOT_ID_1, COMPONENT_UUID_1); + + } + + private void verifyMeasure(long id, long snapshotId, @Nullable String componentUuid) { + List<Map<String, Object>> rows = db.select("select SNAPSHOT_ID, COMPONENT_UUID from project_measures where ID=" + id); + assertThat(rows).hasSize(1); + Map<String, Object> row = rows.get(0); + assertThat(row.get("SNAPSHOT_ID")).isEqualTo(snapshotId); + assertThat(row.get("COMPONENT_UUID")).isEqualTo(componentUuid); + } + + private void insertSnapshot(long id, String componentUuid) { + db.executeInsert( + "snapshots", + "id", valueOf(id), + "component_uuid", componentUuid, + "root_component_uuid", "ROOT_" + componentUuid); + } + + private void insertMeasure(long id, long snapshotId, long componentId) { + db.executeInsert( + "project_measures", + "ID", valueOf(id), + "METRIC_ID", valueOf(id + 10), + "SNAPSHOT_ID", valueOf(snapshotId), + "VALUE", valueOf(id + 1000), + "PROJECT_ID", valueOf(componentId)); + + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateLastUsedColumnOfRulesProfilesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateLastUsedColumnOfRulesProfilesTest.java new file mode 100644 index 00000000000..9bd6bcbb49a --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateLastUsedColumnOfRulesProfilesTest.java @@ -0,0 +1,136 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import java.util.Arrays; +import java.util.stream.Collectors; +import javax.annotation.CheckForNull; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.api.utils.System2; +import org.sonar.db.DbTester; + +import static java.lang.String.valueOf; +import static org.assertj.core.api.Assertions.assertThat; + +public class PopulateLastUsedColumnOfRulesProfilesTest { + private static final String QUALITY_PROFILES_TABLE = "rules_profiles"; + private static final String METRICS_TABLE = "metrics"; + private static final String MEASURES_TABLE = "project_measures"; + private static final String SNAPSHOTS_TABLE = "snapshots"; + private static final String METRIC_ID = "1"; + + @Rule + public DbTester db = DbTester.createForSchema(System2.INSTANCE, PopulateLastUsedColumnOfRulesProfilesTest.class, "rules_profiles.sql"); + + PopulateLastUsedColumnOfRulesProfiles underTest = new PopulateLastUsedColumnOfRulesProfiles(db.database()); + + @Test + public void migration_has_no_effect_on_empty_tables() throws SQLException { + underTest.execute(); + + assertThat(db.countRowsOfTable(QUALITY_PROFILES_TABLE)).isEqualTo(0); + assertThat(db.countRowsOfTable(METRICS_TABLE)).isEqualTo(0); + assertThat(db.countRowsOfTable(MEASURES_TABLE)).isEqualTo(0); + assertThat(db.countRowsOfTable(SNAPSHOTS_TABLE)).isEqualTo(0); + } + + @Test + public void migration_update_quality_profiles_last_used() throws SQLException { + insertQualityProfilesMetric(); + insertQualityProfile(1, "first-quality-profile"); + insertQualityProfile(2, "second-quality-profile"); + insertQualityProfile(3, "third-quality-profile"); + insertQualityProfile(4, "fourth-quality-profile"); + insertMeasure(1, "first-quality-profile", "second-quality-profile"); + insertMeasure(2, "second-quality-profile", "third-quality-profile"); + + underTest.execute(); + + assertLastUsedForQP("first-quality-profile", 1); + assertLastUsedForQP("second-quality-profile", 2); + assertLastUsedForQP("third-quality-profile", 2); + assertNoLastUsedForQP("fourth-quality-profile"); + } + + @Test + public void migration_is_reentrant() throws SQLException { + insertQualityProfilesMetric(); + insertQualityProfile(1, "first-quality-profile"); + insertMeasure(1, "first-quality-profile"); + + underTest.execute(); + assertLastUsedForQP("first-quality-profile", 1); + + underTest.execute(); + assertLastUsedForQP("first-quality-profile", 1); + } + + private void assertLastUsedForQP(String qualityProfileKey, long expectedLastUsed) { + assertThat(selectLastUser(qualityProfileKey)).isEqualTo(expectedLastUsed); + } + + private void assertNoLastUsedForQP(String qualityProfileKey) { + assertThat(selectLastUser(qualityProfileKey)).isNull(); + } + + @CheckForNull + private Long selectLastUser(String qualityProfileKey) { + return (Long) db.selectFirst(String.format("select last_used as \"lastUsed\" from rules_profiles where kee ='%s'", qualityProfileKey)).get("lastUsed"); + } + + private void insertQualityProfile(long id, String key) { + db.executeInsert(QUALITY_PROFILES_TABLE, + "id", valueOf(id), + "name", key, + "kee", key); + } + + private void insertMeasure(long id, String... keys) { + db.executeInsert( + SNAPSHOTS_TABLE, + "id", valueOf(id), + "uuid", valueOf(id), + "component_uuid", valueOf(id), + "root_component_uuid", valueOf(id), + "islast", "TRUE", + "created_at", valueOf(id)); + + db.executeInsert( + MEASURES_TABLE, + "id", valueOf(id), + "snapshot_id", valueOf(id), + "metric_id", METRIC_ID, + "component_uuid", valueOf(id), + "text_value", toJson(keys)); + } + + private void insertQualityProfilesMetric() { + db.executeInsert(METRICS_TABLE, + "id", METRIC_ID, + "name", "quality_profiles"); + } + + private static String toJson(String... keys) { + return Arrays.stream(keys).map(key -> "\"key\" : \"" + key + "\"").collect(Collectors.joining(", ", "{", "}")); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateProfileKeyOfActivitiesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateProfileKeyOfActivitiesTest.java new file mode 100644 index 00000000000..dd0cd21cc36 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateProfileKeyOfActivitiesTest.java @@ -0,0 +1,114 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.sonar.api.utils.System2; +import org.sonar.db.DbTester; + +import static org.assertj.core.api.Assertions.assertThat; + +public class PopulateProfileKeyOfActivitiesTest { + private static final String ACTIVITIES_TABLE = "activities"; + + @Rule + public ExpectedException expectedException = ExpectedException.none(); + @Rule + public DbTester db = DbTester.createForSchema(System2.INSTANCE, PopulateProfileKeyOfActivitiesTest.class, "activities.sql"); + + PopulateProfileKeyOfActivities underTest = new PopulateProfileKeyOfActivities(db.database()); + + @Test + public void migration_has_no_effect_on_empty_tables() throws SQLException { + underTest.execute(); + + assertThat(db.countRowsOfTable(ACTIVITIES_TABLE)).isEqualTo(0); + } + + @Test + public void migration_update_activities_profile_key() throws SQLException { + insertActivity("first-profile-key"); + insertActivity("first-profile-key"); + insertActivity("first-profile-key"); + insertActivity("second-profile-key"); + insertActivity("third-profile-key"); + + underTest.execute(); + + assertCountActivitiesWithProfile("first-profile-key", 3); + assertCountActivitiesWithProfile("second-profile-key", 1); + assertCountActivitiesWithProfile("third-profile-key", 1); + } + + @Test + public void migration_is_reentrant() throws SQLException { + insertActivity("profile-key"); + underTest.execute(); + assertCountActivitiesWithProfile("profile-key", 1); + + underTest.execute(); + assertCountActivitiesWithProfile("profile-key", 1); + } + + @Test + public void delete_the_rows_of_ACTIVITIES_that_do_not_have_profileKey() throws SQLException { + db.executeInsert(ACTIVITIES_TABLE, "data_field", "key=fakeKey"); + + underTest.execute(); + + assertThat(db.countRowsOfTable(ACTIVITIES_TABLE)).isEqualTo(0); + } + + @Test + public void delete_the_rows_of_ACTIVITIES_that_have_empty_profileKey() throws SQLException { + insertActivity(""); + + underTest.execute(); + + assertThat(db.countRowsOfTable(ACTIVITIES_TABLE)).isEqualTo(0); + } + + @Test + public void delete_the_rows_of_ACTIVITIES_that_have_blank_profileKey() throws SQLException { + insertActivity(" "); + + underTest.execute(); + + assertThat(db.countRowsOfTable(ACTIVITIES_TABLE)).isEqualTo(0); + } + + private void assertCountActivitiesWithProfile(String profileKey, int expectedNumberOfActivities) { + assertThat(countActivitiesWithProfile(profileKey)).isEqualTo(expectedNumberOfActivities); + } + + private int countActivitiesWithProfile(String qualityProfileKey) { + // profile key is removed from data_field + return db.countSql(String.format("select count(1) from activities where profile_key='%s' and data_field='key=fakeKey'", qualityProfileKey)); + } + + private void insertActivity(String profileKey) { + db.executeInsert(ACTIVITIES_TABLE, + "data_field", "key=fakeKey;profileKey=" + profileKey); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUserUpdatedAtOfRulesProfilesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUserUpdatedAtOfRulesProfilesTest.java new file mode 100644 index 00000000000..819af091d59 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUserUpdatedAtOfRulesProfilesTest.java @@ -0,0 +1,122 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import com.google.common.base.Throwables; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.Timestamp; +import javax.annotation.CheckForNull; +import javax.annotation.Nullable; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.api.utils.System2; +import org.sonar.db.DbTester; + +import static java.lang.String.valueOf; +import static org.assertj.core.api.Assertions.assertThat; + +public class PopulateUserUpdatedAtOfRulesProfilesTest { + private static final String TABLE_QUALITY_PROFILES = "rules_profiles"; + private static final String TABLE_ACTIVITIES = "activities"; + + @Rule + public DbTester db = DbTester.createForSchema(System2.INSTANCE, PopulateUserUpdatedAtOfRulesProfilesTest.class, "schema.sql"); + + PopulateUserUpdatedAtOfRulesProfiles underTest = new PopulateUserUpdatedAtOfRulesProfiles(db.database()); + + @Test + public void migration_has_no_effect_on_empty_tables() throws SQLException { + underTest.execute(); + + assertThat(db.countRowsOfTable(TABLE_QUALITY_PROFILES)).isEqualTo(0); + assertThat(db.countRowsOfTable(TABLE_ACTIVITIES)).isEqualTo(0); + } + + @Test + public void migration_update_quality_profiles_user_updated_at() throws SQLException { + + insertQualityProfile(1, "first-quality-profile"); + insertActivity("first-quality-profile", "my-login", 1_000_000_00L); + insertActivity("first-quality-profile", null, 2_000_000_000L); + insertActivity("first-quality-profile", "my-login", 1_100_000_000L); + insertQualityProfile(2, "second-quality-profile"); + insertActivity("second-quality-profile", null, 1_000_000_00L); + insertQualityProfile(3, "third-quality-profile"); + insertQualityProfile(4, "fourth-quality-profile"); + insertActivity("fourth-quality-profile", "my-login", 1_000_000_00L); + + underTest.execute(); + + assertUserUpdatedAt("first-quality-profile", 1_100_000_000L); + assertNoUserUpdatedAtDate("second-quality-profile"); + assertNoUserUpdatedAtDate("third-quality-profile"); + assertUserUpdatedAt("fourth-quality-profile", 1_000_000_00L); + } + + @Test + public void migration_is_reentrant() throws SQLException { + insertQualityProfile(1, "first-quality-profile"); + insertActivity("first-quality-profile", "my-login", 1_000_000_000L); + + underTest.execute(); + assertUserUpdatedAt("first-quality-profile", 1_000_000_000L); + + underTest.execute(); + assertUserUpdatedAt("first-quality-profile", 1_000_000_000L); + } + + private void assertUserUpdatedAt(String qualityProfileKey, long expectedLastUsed) { + assertThat(selectUserUpdatedAt(qualityProfileKey)).isEqualTo(expectedLastUsed); + } + + private void assertNoUserUpdatedAtDate(String qualityProfileKey) { + assertThat(selectUserUpdatedAt(qualityProfileKey)).isNull(); + } + + @CheckForNull + private Long selectUserUpdatedAt(String qualityProfileKey) { + return (Long) db.selectFirst(String.format("select user_updated_at as \"userUpdatedAt\" from rules_profiles where kee ='%s'", qualityProfileKey)).get("userUpdatedAt"); + } + + private void insertActivity(String profileKey, @Nullable String login, @Nullable Long createdAt) { + final String sqlInsertActivity = "insert into activities (profile_key, user_login, created_at) values (?, ?, ?) "; + + Connection connection = db.getSession().getConnection(); + try (PreparedStatement ps = connection.prepareStatement(sqlInsertActivity)) { + ps.setString(1, profileKey); + ps.setString(2, login); + ps.setTimestamp(3, createdAt == null ? null : new Timestamp(createdAt)); + ps.executeUpdate(); + connection.commit(); + } catch (SQLException e) { + throw Throwables.propagate(e); + } + } + + private void insertQualityProfile(long id, String key) { + db.executeInsert(TABLE_QUALITY_PROFILES, + "id", valueOf(id), + "name", key, + "kee", key); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnOnSnapshotsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnOnSnapshotsTest.java new file mode 100644 index 00000000000..7986ce28563 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnOnSnapshotsTest.java @@ -0,0 +1,95 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; +import org.apache.commons.lang.StringUtils; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.api.utils.System2; +import org.sonar.core.util.UuidFactoryImpl; +import org.sonar.db.DbTester; + +import static java.lang.String.valueOf; +import static org.assertj.core.api.Assertions.assertThat; + +public class PopulateUuidColumnOnSnapshotsTest { + + private static final String TABLE_SNAPSHOTS = "snapshots"; + + @Rule + public DbTester db = DbTester.createForSchema(System2.INSTANCE, PopulateUuidColumnOnSnapshotsTest.class, + "in_progress_snapshots.sql"); + + private PopulateUuidColumnOnSnapshots underTest = new PopulateUuidColumnOnSnapshots(db.database(), UuidFactoryImpl.INSTANCE); + + @Test + public void migration_has_no_effect_on_empty_tables() throws SQLException { + underTest.execute(); + + assertThat(db.countRowsOfTable(TABLE_SNAPSHOTS)).isEqualTo(0); + } + + @Test + public void migration_generates_uuids() throws SQLException { + insertSnapshot(1); + insertSnapshot(2); + insertSnapshot(3); + db.commit(); + + underTest.execute(); + + verifyUuids(3); + } + + private void verifyUuids(int expectedCount) { + List<Map<String, Object>> rows = db.select("select uuid from snapshots where uuid is not null"); + Set<Object> uuids = rows.stream().map(cols -> cols.get("UUID")).filter(uuid -> StringUtils.isNotBlank((String) uuid)).collect(Collectors.toSet()); + assertThat(uuids).hasSize(expectedCount); + } + + @Test + public void migration_is_reentrant() throws SQLException { + insertSnapshot(1); + + underTest.execute(); + verifyUuids(1); + + underTest.execute(); + verifyUuids(1); + } + + private String insertSnapshot(long id) { + String uuid = "uuid_" + id; + db.executeInsert( + TABLE_SNAPSHOTS, + "ID", valueOf(id), + "COMPONENT_UUID", valueOf(id + 10), + "ROOT_COMPONENT_UUID", valueOf(id + 100), + "SCOPE", "PRJ", + "QUALIFIER", "FIL"); + return uuid; + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnsOfProjectsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnsOfProjectsTest.java new file mode 100644 index 00000000000..9f78a4e8307 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnsOfProjectsTest.java @@ -0,0 +1,116 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import java.util.List; +import java.util.Map; +import javax.annotation.Nullable; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.api.utils.System2; +import org.sonar.db.DbTester; + +import static java.lang.String.valueOf; +import static org.assertj.core.api.Assertions.assertThat; + +public class PopulateUuidColumnsOfProjectsTest { + + @Rule + public DbTester db = DbTester.createForSchema(System2.INSTANCE, PopulateUuidColumnsOfProjectsTest.class, + "in_progress_projects.sql"); + + private PopulateUuidColumnsOfProjects underTest = new PopulateUuidColumnsOfProjects(db.database()); + + @Test + public void migration_has_no_effect_on_empty_tables() throws SQLException { + underTest.execute(); + + assertThat(db.countRowsOfTable("projects")).isEqualTo(0); + } + + @Test + public void migration_updates_uuid_columns_with_values_from_table_projects_when_they_exist() throws SQLException { + String uuid1 = insertComponent(1, null, null, null); // project + insertComponent(2, 1L, null, null); // a module or something not a project + String uuid3 = insertComponent(3, null, null, null); // developer + insertComponent(4, 3L, 1L, 3L); // a project copy of project 1 for developer 3 + String uuid5 = insertComponent(5, null, null, null); // another project + String uuid6 = insertComponent(6, null, null, null); // a view + insertComponent(7, 6L, 5L, null); // a project view of project 5 + insertComponent(8, 200L, 1L, 200L); // a project copy of project 1 for developer 200 (does't exist) + insertComponent(9, 6L, 300L, null); // a project view of project 300 (doesn't exist) + insertComponent(10, 400L, null, null); // a module of a non existing project + db.commit(); + + underTest.execute(); + + verifyProject(1, null, uuid1, null, null, null, null); + verifyProject(2, 1L, uuid1, null, null, null, null); + verifyProject(3, null, uuid3, null, null, null, null); + verifyProject(4, 3L, uuid3, 1L, uuid1, 3L, uuid3); + verifyProject(5, null, uuid5, null, null, null, null); + verifyProject(6, null, uuid6, null, null, null, null); + verifyProject(7, 6L, uuid6, 5L, uuid5, null, null); + verifyProject(9, 6L, uuid6, 300L, null, null, null); + verifyProject(10, 400L, null, null, null, null, null); + } + + @Test + public void migration_is_reentrant() throws SQLException { + String uuid1 = insertComponent(1, null, null, null); // project + + underTest.execute(); + verifyProject(1, null, uuid1, null, null, null, null); + + underTest.execute(); + verifyProject(1, null, uuid1, null, null, null, null); + } + + private String insertComponent(long id, @Nullable Long rootId, @Nullable Long copyResourceId, @Nullable Long personId) { + String uuid = "uuid_" + id; + db.executeInsert( + "projects", + "ID", valueOf(id), + "UUID", uuid, + "ROOT_ID", toString(rootId), + "COPY_RESOURCE_ID", toString(copyResourceId), + "PERSON_ID", toString(personId)); + return uuid; + } + + private static String toString(@Nullable Long aLong) { + return aLong == null ? null : valueOf(aLong); + } + + private void verifyProject(long id, @Nullable Long rootId, @Nullable String rootUuid, @Nullable Long copyResourceId, @Nullable String copyComponentUuuid, @Nullable Long personId, + @Nullable String developerUuid) { + List<Map<String, Object>> rows = db.select("select ROOT_ID, ROOT_UUID, COPY_RESOURCE_ID, COPY_COMPONENT_UUID, PERSON_ID, DEVELOPER_UUID from projects where ID=" + id); + assertThat(rows).hasSize(1); + Map<String, Object> row = rows.get(0); + assertThat(row.get("ROOT_ID")).isEqualTo(rootId); + assertThat(row.get("ROOT_UUID")).isEqualTo(rootUuid); + assertThat(row.get("COPY_RESOURCE_ID")).isEqualTo(copyResourceId); + assertThat(row.get("COPY_COMPONENT_UUID")).isEqualTo(copyComponentUuuid); + assertThat(row.get("PERSON_ID")).isEqualTo(personId); + assertThat(row.get("DEVELOPER_UUID")).isEqualTo(developerUuid); + } + +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnsOfResourceIndexTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnsOfResourceIndexTest.java new file mode 100644 index 00000000000..23a0154e3d4 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnsOfResourceIndexTest.java @@ -0,0 +1,117 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import java.util.List; +import java.util.Map; +import javax.annotation.Nullable; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.api.utils.System2; +import org.sonar.db.DbTester; + +import static java.lang.String.valueOf; +import static org.assertj.core.api.Assertions.assertThat; + +public class PopulateUuidColumnsOfResourceIndexTest { + + @Rule + public DbTester db = DbTester.createForSchema(System2.INSTANCE, PopulateUuidColumnsOfResourceIndexTest.class, + "in_progress_resourceindex_with_projects.sql"); + + private PopulateUuidColumnsOfResourceIndex underTest = new PopulateUuidColumnsOfResourceIndex(db.database()); + + @Test + public void migration_has_no_effect_on_empty_tables() throws SQLException { + underTest.execute(); + + assertThat(db.countRowsOfTable("resource_index")).isEqualTo(0); + assertThat(db.countRowsOfTable("projects")).isEqualTo(0); + } + + @Test + public void migration_updates_uuid_columns_with_values_from_table_projects_when_they_exist() throws SQLException { + String uuid1 = insertComponent(40); + String uuid2 = insertComponent(50); + String uuid3 = insertComponent(60); + String uuid4 = insertComponent(70); + + insertResourceIndex(1, 40, 50); + insertResourceIndex(2, 60, 70); + insertResourceIndex(3, 90, 70); // 90 does not exist + insertResourceIndex(4, 40, 100); // 100 does not exist + insertResourceIndex(5, 110, 100); // 110 and 100 do not exist + db.commit(); + + underTest.execute(); + + verifyResourceIndex(1, 40, uuid1, 50, uuid2); + verifyResourceIndex(2, 60, uuid3, 70, uuid4); + verifyResourceIndex(3, 90, null, 70, uuid4); + verifyResourceIndex(4, 40, uuid1, 100, null); + verifyResourceIndex(5, 110, null, 100, null); + } + + @Test + public void migration_is_reentrant() throws SQLException { + String uuid1 = insertComponent(40); + String uuid2 = insertComponent(50); + insertResourceIndex(1, 40, 50); + + underTest.execute(); + verifyResourceIndex(1, 40, uuid1, 50, uuid2); + + underTest.execute(); + verifyResourceIndex(1, 40, uuid1, 50, uuid2); + + } + + private void verifyResourceIndex(long id, long resourceId, @Nullable String componentUuid, long rootProjectId, @Nullable String rootComponentUuid) { + List<Map<String, Object>> rows = db.select("select RESOURCE_ID, COMPONENT_UUID, ROOT_PROJECT_ID, ROOT_COMPONENT_UUID from resource_index where ID=" + id); + assertThat(rows).hasSize(1); + Map<String, Object> row = rows.get(0); + assertThat(row.get("RESOURCE_ID")).isEqualTo(resourceId); + assertThat(row.get("COMPONENT_UUID")).isEqualTo(componentUuid); + assertThat(row.get("ROOT_PROJECT_ID")).isEqualTo(rootProjectId); + assertThat(row.get("ROOT_COMPONENT_UUID")).isEqualTo(rootComponentUuid); + } + + private String insertComponent(long id) { + String uuid = "uuid_" + id; + db.executeInsert( + "projects", + "ID", valueOf(id), + "UUID", uuid); + return uuid; + } + + private void insertResourceIndex(long id, long resourceId, long rootProjectId) { + db.executeInsert( + "resource_index", + "ID", valueOf(id), + "KEE", "key_" + id, + "POSITION", valueOf(id + 100), + "NAME_SIZE", valueOf(id + 1000), + "RESOURCE_ID", valueOf(resourceId), + "ROOT_PROJECT_ID", valueOf(rootProjectId), + "QUALIFIER", "PROJECT"); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidPathColumnOnProjectsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidPathColumnOnProjectsTest.java new file mode 100644 index 00000000000..0578401619e --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/PopulateUuidPathColumnOnProjectsTest.java @@ -0,0 +1,175 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.sql.SQLException; +import java.util.Map; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.api.utils.System2; +import org.sonar.db.DbTester; + +import static java.lang.String.format; +import static org.assertj.core.api.Assertions.assertThat; + +public class PopulateUuidPathColumnOnProjectsTest { + + private static final String TABLE_PROJECTS = "projects"; + private static final String TABLE_SNAPSHOTS = "snapshots"; + private static final String A_PROJECT_UUID = "U_PRJ"; + private static final String A_MODULE_UUID = "U_MOD"; + private static final String A_DIR_UUID = "U_DIR"; + private static final String A_FILE_UUID = "U_FIL"; + private static final String QUALIFIER_PROJECT = "TRK"; + private static final String QUALIFIER_MODULE = "BRC"; + private static final String QUALIFIER_DIR = "DIR"; + private static final String QUALIFIER_FILE = "FIL"; + + @Rule + public DbTester db = DbTester.createForSchema(System2.INSTANCE, PopulateUuidPathColumnOnProjectsTest.class, + "in_progress_projects_and_snapshots.sql"); + + private PopulateUuidPathColumnOnProjects underTest = new PopulateUuidPathColumnOnProjects(db.database()); + + @Test + public void has_no_effect_on_empty_tables() throws SQLException { + underTest.execute(); + + assertThat(db.countRowsOfTable(TABLE_PROJECTS)).isEqualTo(0); + } + + @Test + public void migrates_provisioned_projects() throws SQLException { + insert(QUALIFIER_PROJECT, A_PROJECT_UUID, A_PROJECT_UUID); + + underTest.execute(); + + verifyPath(A_PROJECT_UUID, "."); + } + + @Test + public void migrates_projects_without_modules() throws SQLException { + insert(QUALIFIER_PROJECT, A_PROJECT_UUID, A_PROJECT_UUID, new Snapshot(1L, "", true)); + insert(QUALIFIER_DIR, A_DIR_UUID, A_PROJECT_UUID, new Snapshot(2L, "1.", true)); + insert(QUALIFIER_FILE, A_FILE_UUID, A_PROJECT_UUID, new Snapshot(3L, "1.2.", true)); + + underTest.execute(); + + verifyPath(A_PROJECT_UUID, "."); + verifyPath(A_DIR_UUID, format(".%s.", A_PROJECT_UUID)); + verifyPath(A_FILE_UUID, format(".%s.%s.", A_PROJECT_UUID, A_DIR_UUID)); + } + + @Test + public void migrates_projects_with_modules() throws SQLException { + insert(QUALIFIER_PROJECT, A_PROJECT_UUID, A_PROJECT_UUID, new Snapshot(1L, "", true)); + insert(QUALIFIER_MODULE, A_MODULE_UUID, A_PROJECT_UUID, new Snapshot(2L, "1.", true)); + insert(QUALIFIER_DIR, A_DIR_UUID, A_PROJECT_UUID, new Snapshot(3L, "1.2.", true)); + insert(QUALIFIER_FILE, A_FILE_UUID, A_PROJECT_UUID, new Snapshot(4L, "1.2.3.", true)); + + underTest.execute(); + + verifyPath(A_PROJECT_UUID, "."); + verifyPath(A_MODULE_UUID, format(".%s.", A_PROJECT_UUID)); + verifyPath(A_DIR_UUID, format(".%s.%s.", A_PROJECT_UUID, A_MODULE_UUID)); + verifyPath(A_FILE_UUID, format(".%s.%s.%s.", A_PROJECT_UUID, A_MODULE_UUID, A_DIR_UUID)); + } + + @Test + public void migrates_components_without_snapshot_path() throws SQLException { + // these components do not have snapshots + insert(QUALIFIER_DIR, A_DIR_UUID, A_PROJECT_UUID); + insert(QUALIFIER_FILE, A_FILE_UUID, A_PROJECT_UUID); + + underTest.execute(); + + verifyPath(A_DIR_UUID, format(".%s.", A_PROJECT_UUID)); + verifyPath(A_FILE_UUID, format(".%s.", A_PROJECT_UUID)); + } + + @Test + public void migration_is_reentrant() throws SQLException { + insert(QUALIFIER_PROJECT, A_PROJECT_UUID, A_PROJECT_UUID, new Snapshot(1L, "", true)); + insert(QUALIFIER_DIR, A_DIR_UUID, A_PROJECT_UUID, new Snapshot(2L, "1.", true)); + insert(QUALIFIER_FILE, A_FILE_UUID, A_PROJECT_UUID, new Snapshot(3L, "1.2.", true)); + + underTest.execute(); + verifyNoNullPath(); + + underTest.execute(); + verifyNoNullPath(); + } + + @Test + public void ignore_snapshots_with_invalid_snapshots_in_path() throws SQLException { + insert(QUALIFIER_PROJECT, A_PROJECT_UUID, A_PROJECT_UUID, new Snapshot(1L, "", true)); + // the ID 999999 is unknown in the path + insert(QUALIFIER_DIR, A_DIR_UUID, A_PROJECT_UUID, new Snapshot(2L, "1.999999.", true)); + + underTest.execute(); + + verifyPath(A_PROJECT_UUID, "."); + // path of orphans is the path to project only + verifyPath(A_DIR_UUID, format(".%s.", A_PROJECT_UUID)); + } + + private void insert(String qualifier, String uuid, String rootUuid, Snapshot... snapshots) { + db.executeInsert( + TABLE_PROJECTS, + "uuid", uuid, + "project_uuid", rootUuid, + "root_uuid", rootUuid, + "qualifier", qualifier); + + for (Snapshot snapshot : snapshots) { + db.executeInsert( + TABLE_SNAPSHOTS, + "id", String.valueOf(snapshot.id), + "uuid", "u" + snapshot.id, + "path", snapshot.idPath, + "islast", String.valueOf(snapshot.isLast), + "component_uuid", uuid, + "root_component_uuid", rootUuid, + "qualifier", qualifier); + } + db.commit(); + } + + private void verifyPath(String componentUuid, String expectedUuidPath) { + Map<String, Object> row = db.selectFirst("select uuid_path from projects where uuid='" + componentUuid + "'"); + assertThat(row.get("UUID_PATH")).isEqualTo(expectedUuidPath); + } + + private void verifyNoNullPath() { + assertThat(db.select("select * from projects where uuid_path is null or uuid_path = ''")).isEmpty(); + } + + private static final class Snapshot { + private final long id; + private final String idPath; + private final boolean isLast; + + Snapshot(long id, String idPath, boolean isLast) { + this.id = id; + this.idPath = idPath; + this.isLast = isLast; + } + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/RecreateIndexProjectsUuidFromProjectsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/RecreateIndexProjectsUuidFromProjectsTest.java new file mode 100644 index 00000000000..2d373b930e9 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/RecreateIndexProjectsUuidFromProjectsTest.java @@ -0,0 +1,54 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; +import org.sonar.db.Database; +import org.sonar.db.dialect.H2; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static java.util.Arrays.asList; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.when; + +public class RecreateIndexProjectsUuidFromProjectsTest { + + private Database db = mock(Database.class, Mockito.RETURNS_DEEP_STUBS); + private DdlChange.Context context = mock(DdlChange.Context.class); + + @Before + public void setUp() { + when(db.getDialect()).thenReturn(new H2()); + } + + @Test + public void create_index() throws Exception { + RecreateIndexProjectsUuidFromProjects underTest = new RecreateIndexProjectsUuidFromProjects(db); + + underTest.execute(context); + + verify(context).execute(asList("CREATE INDEX projects_uuid ON projects (uuid)")); + verifyNoMoreInteractions(context); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/RemoveUsersPasswordWhenNotLocalTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/RemoveUsersPasswordWhenNotLocalTest.java new file mode 100644 index 00000000000..2fb63a2293e --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v60/RemoveUsersPasswordWhenNotLocalTest.java @@ -0,0 +1,113 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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.v60; + +import java.util.List; +import java.util.Map; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.api.utils.System2; +import org.sonar.db.DbTester; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class RemoveUsersPasswordWhenNotLocalTest { + + static long PAST_DATE = 1_000_000_000L; + static long NOW = 2_000_000_000L; + + System2 system2 = mock(System2.class); + + @Rule + public DbTester db = DbTester.createForSchema(System2.INSTANCE, RemoveUsersPasswordWhenNotLocalTest.class, "schema.sql"); + + private RemoveUsersPasswordWhenNotLocal migration = new RemoveUsersPasswordWhenNotLocal(db.database(), system2); + + @Before + public void setUp() throws Exception { + when(system2.now()).thenReturn(NOW); + } + + @Test + public void update_not_local_user() throws Exception { + insertUserWithPassword("john", false); + + migration.execute(); + + List<Map<String, Object>> rows = db.select("SELECT CRYPTED_PASSWORD,SALT,UPDATED_AT FROM users"); + assertThat(rows).hasSize(1); + assertThat(rows.get(0).get("CRYPTED_PASSWORD")).isNull(); + assertThat(rows.get(0).get("SALT")).isNull(); + assertThat(rows.get(0).get("UPDATED_AT")).isEqualTo(NOW); + } + + @Test + public void ignore_local_user() throws Exception { + insertUserWithPassword("john", true); + + migration.execute(); + + List<Map<String, Object>> rows = db.select("SELECT CRYPTED_PASSWORD,SALT,UPDATED_AT FROM users"); + assertThat(rows).hasSize(1); + assertThat(rows.get(0).get("CRYPTED_PASSWORD")).isNotNull(); + assertThat(rows.get(0).get("SALT")).isNotNull(); + assertThat(rows.get(0).get("UPDATED_AT")).isEqualTo(PAST_DATE); + } + + @Test + public void ignore_already_migrated_user() throws Exception { + insertUserWithoutPasword("john", false); + + migration.execute(); + + List<Map<String, Object>> rows = db.select("SELECT CRYPTED_PASSWORD,SALT,UPDATED_AT FROM users"); + assertThat(rows).hasSize(1); + assertThat(rows.get(0).get("CRYPTED_PASSWORD")).isNull(); + assertThat(rows.get(0).get("SALT")).isNull(); + assertThat(rows.get(0).get("UPDATED_AT")).isEqualTo(PAST_DATE); + } + + private void insertUserWithPassword(String login, boolean isLocal) { + db.executeInsert( + "users", + "LOGIN", login, + "NAME", login, + "USER_LOCAL", Boolean.toString(isLocal), + "CRYPTED_PASSWORD", "crypted_" + login, + "SALT", "salt" + login, + "CREATED_AT", Long.toString(PAST_DATE), + "UPDATED_AT", Long.toString(PAST_DATE)); + } + + private void insertUserWithoutPasword(String login, boolean isLocal) { + db.executeInsert( + "users", + "LOGIN", login, + "NAME", login, + "USER_LOCAL", Boolean.toString(isLocal), + "CREATED_AT", Long.toString(PAST_DATE), + "UPDATED_AT", Long.toString(PAST_DATE)); + } + +} diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToCeActivityTest/old_ce_activity.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToCeActivityTest/old_ce_activity.sql new file mode 100644 index 00000000000..8fbdcb6cce4 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToCeActivityTest/old_ce_activity.sql @@ -0,0 +1,17 @@ +CREATE TABLE "CE_ACTIVITY" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "UUID" VARCHAR(40) NOT NULL, + "TASK_TYPE" VARCHAR(15) NOT NULL, + "COMPONENT_UUID" VARCHAR(40) NULL, + "SNAPSHOT_ID" INTEGER NULL, + "STATUS" VARCHAR(15) NOT NULL, + "IS_LAST" BOOLEAN NOT NULL, + "IS_LAST_KEY" VARCHAR(55) NOT NULL, + "SUBMITTER_LOGIN" VARCHAR(255) NULL, + "SUBMITTED_AT" BIGINT NOT NULL, + "STARTED_AT" BIGINT NULL, + "EXECUTED_AT" BIGINT NULL, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL, + "EXECUTION_TIME_MS" BIGINT NULL +); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToEventsTest/events_before_6-0.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToEventsTest/events_before_6-0.sql new file mode 100644 index 00000000000..e0c04fc1904 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToEventsTest/events_before_6-0.sql @@ -0,0 +1,12 @@ + +CREATE TABLE "EVENTS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "NAME" VARCHAR(400), + "COMPONENT_UUID" VARCHAR(50), + "SNAPSHOT_ID" INTEGER, + "CATEGORY" VARCHAR(50), + "EVENT_DATE" BIGINT NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + "DESCRIPTION" VARCHAR(4000), + "EVENT_DATA" VARCHAR(4000) +); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToMeasuresTest/old_measures.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToMeasuresTest/old_measures.sql new file mode 100644 index 00000000000..2f918746508 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddAnalysisUuidColumnToMeasuresTest/old_measures.sql @@ -0,0 +1,18 @@ +CREATE TABLE "PROJECT_MEASURES" ( + "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "VALUE" DOUBLE, + "METRIC_ID" INTEGER NOT NULL, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "SNAPSHOT_ID" INTEGER, + "TEXT_VALUE" VARCHAR(4000), + "ALERT_STATUS" VARCHAR(5), + "ALERT_TEXT" VARCHAR(4000), + "DESCRIPTION" VARCHAR(4000), + "PERSON_ID" INTEGER, + "VARIATION_VALUE_1" DOUBLE, + "VARIATION_VALUE_2" DOUBLE, + "VARIATION_VALUE_3" DOUBLE, + "VARIATION_VALUE_4" DOUBLE, + "VARIATION_VALUE_5" DOUBLE, + "MEASURE_DATA" BINARY(167772150) + ); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddBColumnsToProjectsTest/old_projects.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddBColumnsToProjectsTest/old_projects.sql new file mode 100644 index 00000000000..1c469e80b26 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddBColumnsToProjectsTest/old_projects.sql @@ -0,0 +1,23 @@ +CREATE TABLE "PROJECTS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "KEE" VARCHAR(400), + "UUID" VARCHAR(50) NOT NULL, + "UUID_PATH" VARCHAR(4000) NOT NULL, + "ROOT_UUID" VARCHAR(50) NOT NULL, + "PROJECT_UUID" VARCHAR(50), + "MODULE_UUID" VARCHAR(50), + "MODULE_UUID_PATH" VARCHAR(4000), + "NAME" VARCHAR(2000), + "DESCRIPTION" VARCHAR(2000), + "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, + "SCOPE" VARCHAR(3), + "QUALIFIER" VARCHAR(10), + "DEPRECATED_KEE" VARCHAR(400), + "PATH" VARCHAR(2000), + "LANGUAGE" VARCHAR(20), + "COPY_COMPONENT_UUID" VARCHAR(50), + "LONG_NAME" VARCHAR(2000), + "DEVELOPER_UUID" VARCHAR(50), + "CREATED_AT" TIMESTAMP, + "AUTHORIZATION_UPDATED_AT" BIGINT +); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndexTest/duplications_index_5.6.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndexTest/duplications_index_5.6.sql new file mode 100644 index 00000000000..6ac3885a261 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndexTest/duplications_index_5.6.sql @@ -0,0 +1,9 @@ +CREATE TABLE "DUPLICATIONS_INDEX" ( + "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "PROJECT_SNAPSHOT_ID" INTEGER NOT NULL, + "SNAPSHOT_ID" INTEGER NOT NULL, + "HASH" VARCHAR(50) NOT NULL, + "INDEX_IN_FILE" INTEGER NOT NULL, + "START_LINE" INTEGER NOT NULL, + "END_LINE" INTEGER NOT NULL +); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnToMeasuresTest/project_measures_5.6.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnToMeasuresTest/project_measures_5.6.sql new file mode 100644 index 00000000000..c4f1eab4b8d --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnToMeasuresTest/project_measures_5.6.sql @@ -0,0 +1,29 @@ +CREATE TABLE "PROJECT_MEASURES" ( + "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "VALUE" DOUBLE, + "METRIC_ID" INTEGER NOT NULL, + "SNAPSHOT_ID" INTEGER, + "RULE_ID" INTEGER, + "RULES_CATEGORY_ID" INTEGER, + "TEXT_VALUE" VARCHAR(4000), + "TENDENCY" INTEGER, + "MEASURE_DATE" TIMESTAMP, + "PROJECT_ID" INTEGER, + "ALERT_STATUS" VARCHAR(5), + "ALERT_TEXT" VARCHAR(4000), + "URL" VARCHAR(2000), + "DESCRIPTION" VARCHAR(4000), + "RULE_PRIORITY" INTEGER, + "CHARACTERISTIC_ID" INTEGER, + "PERSON_ID" INTEGER, + "VARIATION_VALUE_1" DOUBLE, + "VARIATION_VALUE_2" DOUBLE, + "VARIATION_VALUE_3" DOUBLE, + "VARIATION_VALUE_4" DOUBLE, + "VARIATION_VALUE_5" DOUBLE, + "MEASURE_DATA" BINARY(167772150) +); + +CREATE INDEX "MEASURES_SID_METRIC" ON "PROJECT_MEASURES" ("SNAPSHOT_ID", "METRIC_ID"); + +CREATE INDEX "MEASURES_PERSON" ON "PROJECT_MEASURES" ("PERSON_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnsToSnapshotsTest/old_snapshots.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnsToSnapshotsTest/old_snapshots.sql new file mode 100644 index 00000000000..1472d580371 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddComponentUuidColumnsToSnapshotsTest/old_snapshots.sql @@ -0,0 +1,33 @@ +CREATE TABLE "SNAPSHOTS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "CREATED_AT" BIGINT, + "BUILD_DATE" BIGINT, + "PROJECT_ID" INTEGER NOT NULL, + "PARENT_SNAPSHOT_ID" INTEGER, + "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U', + "PURGE_STATUS" INTEGER, + "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE, + "SCOPE" VARCHAR(3), + "QUALIFIER" VARCHAR(10), + "ROOT_SNAPSHOT_ID" INTEGER, + "VERSION" VARCHAR(500), + "PATH" VARCHAR(500), + "DEPTH" INTEGER, + "ROOT_PROJECT_ID" INTEGER, + "PERIOD1_MODE" VARCHAR(100), + "PERIOD1_PARAM" VARCHAR(100), + "PERIOD1_DATE" BIGINT, + "PERIOD2_MODE" VARCHAR(100), + "PERIOD2_PARAM" VARCHAR(100), + "PERIOD2_DATE" BIGINT, + "PERIOD3_MODE" VARCHAR(100), + "PERIOD3_PARAM" VARCHAR(100), + "PERIOD3_DATE" BIGINT, + "PERIOD4_MODE" VARCHAR(100), + "PERIOD4_PARAM" VARCHAR(100), + "PERIOD4_DATE" BIGINT, + "PERIOD5_MODE" VARCHAR(100), + "PERIOD5_PARAM" VARCHAR(100), + "PERIOD5_DATE" BIGINT +); + diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddLastUsedColumnToRulesProfilesTest/rules_profiles.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddLastUsedColumnToRulesProfilesTest/rules_profiles.sql new file mode 100644 index 00000000000..cddbb2038a8 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddLastUsedColumnToRulesProfilesTest/rules_profiles.sql @@ -0,0 +1,13 @@ +CREATE TABLE "RULES_PROFILES" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "NAME" VARCHAR(100) NOT NULL, + "LANGUAGE" VARCHAR(20), + "KEE" VARCHAR(255) NOT NULL, + "PARENT_KEE" VARCHAR(255), + "RULES_UPDATED_AT" VARCHAR(100), + "IS_DEFAULT" BOOLEAN NOT NULL DEFAULT FALSE, + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); + +CREATE UNIQUE INDEX "UNIQ_QPROF_KEY" ON "RULES_PROFILES" ("KEE"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddProfileKeyToActivitiesTest/activities.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddProfileKeyToActivitiesTest/activities.sql new file mode 100644 index 00000000000..338d203db7d --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddProfileKeyToActivitiesTest/activities.sql @@ -0,0 +1,10 @@ +CREATE TABLE "ACTIVITIES" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "LOG_KEY" VARCHAR(250), + "CREATED_AT" TIMESTAMP, + "USER_LOGIN" VARCHAR(255), + "LOG_TYPE" VARCHAR(250), + "LOG_ACTION" VARCHAR(250), + "LOG_MESSAGE" VARCHAR(250), + "DATA_FIELD" CLOB(2147483647) +); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddUserUpdatedAtToRulesProfilesTest/rules_profiles.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddUserUpdatedAtToRulesProfilesTest/rules_profiles.sql new file mode 100644 index 00000000000..efa759b85e5 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddUserUpdatedAtToRulesProfilesTest/rules_profiles.sql @@ -0,0 +1,12 @@ +CREATE TABLE "RULES_PROFILES" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "NAME" VARCHAR(100) NOT NULL, + "LANGUAGE" VARCHAR(20), + "KEE" VARCHAR(255) NOT NULL, + "PARENT_KEE" VARCHAR(255), + "RULES_UPDATED_AT" VARCHAR(100), + "IS_DEFAULT" BOOLEAN NOT NULL DEFAULT FALSE, + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP, + "LAST_USED" BIGINT +); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnToSnapshotsTest/old_snapshots.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnToSnapshotsTest/old_snapshots.sql new file mode 100644 index 00000000000..d8e6c110791 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnToSnapshotsTest/old_snapshots.sql @@ -0,0 +1,32 @@ +CREATE TABLE "SNAPSHOTS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "CREATED_AT" BIGINT, + "BUILD_DATE" BIGINT, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "PARENT_SNAPSHOT_ID" INTEGER, + "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U', + "PURGE_STATUS" INTEGER, + "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE, + "SCOPE" VARCHAR(3), + "QUALIFIER" VARCHAR(10), + "ROOT_SNAPSHOT_ID" INTEGER, + "VERSION" VARCHAR(500), + "PATH" VARCHAR(500), + "DEPTH" INTEGER, + "ROOT_COMPONENT_UUID" VARCHAR(50) NOT NULL, + "PERIOD1_MODE" VARCHAR(100), + "PERIOD1_PARAM" VARCHAR(100), + "PERIOD1_DATE" BIGINT, + "PERIOD2_MODE" VARCHAR(100), + "PERIOD2_PARAM" VARCHAR(100), + "PERIOD2_DATE" BIGINT, + "PERIOD3_MODE" VARCHAR(100), + "PERIOD3_PARAM" VARCHAR(100), + "PERIOD3_DATE" BIGINT, + "PERIOD4_MODE" VARCHAR(100), + "PERIOD4_PARAM" VARCHAR(100), + "PERIOD4_DATE" BIGINT, + "PERIOD5_MODE" VARCHAR(100), + "PERIOD5_PARAM" VARCHAR(100), + "PERIOD5_DATE" BIGINT +); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnsToProjectsTest/old_projects.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnsToProjectsTest/old_projects.sql new file mode 100644 index 00000000000..d8331447c2f --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnsToProjectsTest/old_projects.sql @@ -0,0 +1,22 @@ +CREATE TABLE "PROJECTS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "KEE" VARCHAR(400), + "ROOT_ID" INTEGER, + "UUID" VARCHAR(50), + "PROJECT_UUID" VARCHAR(50), + "MODULE_UUID" VARCHAR(50), + "MODULE_UUID_PATH" VARCHAR(4000), + "NAME" VARCHAR(2000), + "DESCRIPTION" VARCHAR(2000), + "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, + "SCOPE" VARCHAR(3), + "QUALIFIER" VARCHAR(10), + "DEPRECATED_KEE" VARCHAR(400), + "PATH" VARCHAR(2000), + "LANGUAGE" VARCHAR(20), + "COPY_RESOURCE_ID" INTEGER, + "LONG_NAME" VARCHAR(2000), + "PERSON_ID" INTEGER, + "CREATED_AT" TIMESTAMP, + "AUTHORIZATION_UPDATED_AT" BIGINT +); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnsToResourceIndexTest/old_resourceindex.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnsToResourceIndexTest/old_resourceindex.sql new file mode 100644 index 00000000000..6037299d5ac --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/AddUuidColumnsToResourceIndexTest/old_resourceindex.sql @@ -0,0 +1,9 @@ +CREATE TABLE "RESOURCE_INDEX" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "KEE" VARCHAR(400) NOT NULL, + "POSITION" INTEGER NOT NULL, + "NAME_SIZE" INTEGER NOT NULL, + "RESOURCE_ID" INTEGER NOT NULL, + "ROOT_PROJECT_ID" INTEGER NOT NULL, + "QUALIFIER" VARCHAR(10) NOT NULL +); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutAnalysisUuidTest/in_progress_events.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutAnalysisUuidTest/in_progress_events.sql new file mode 100644 index 00000000000..6f84d3b6dd4 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutAnalysisUuidTest/in_progress_events.sql @@ -0,0 +1,15 @@ + +CREATE TABLE "EVENTS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "NAME" VARCHAR(400), + "ANALYSIS_UUID" VARCHAR(50), + "COMPONENT_UUID" VARCHAR(50), + "SNAPSHOT_ID" INTEGER, + "CATEGORY" VARCHAR(50), + "EVENT_DATE" BIGINT NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + "DESCRIPTION" VARCHAR(4000), + "EVENT_DATA" VARCHAR(4000) +); + + diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutSnapshotIdTest/in_progress_events.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutSnapshotIdTest/in_progress_events.sql new file mode 100644 index 00000000000..6f84d3b6dd4 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/CleanEventsWithoutSnapshotIdTest/in_progress_events.sql @@ -0,0 +1,15 @@ + +CREATE TABLE "EVENTS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "NAME" VARCHAR(400), + "ANALYSIS_UUID" VARCHAR(50), + "COMPONENT_UUID" VARCHAR(50), + "SNAPSHOT_ID" INTEGER, + "CATEGORY" VARCHAR(50), + "EVENT_DATE" BIGINT NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + "DESCRIPTION" VARCHAR(4000), + "EVENT_DATA" VARCHAR(4000) +); + + diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/CleanMeasuresWithNullAnalysisUuidTest/in_progress_measures.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/CleanMeasuresWithNullAnalysisUuidTest/in_progress_measures.sql new file mode 100644 index 00000000000..5f58ad529ce --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/CleanMeasuresWithNullAnalysisUuidTest/in_progress_measures.sql @@ -0,0 +1,20 @@ +CREATE TABLE "PROJECT_MEASURES" ( + "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "VALUE" DOUBLE, + "METRIC_ID" INTEGER NOT NULL, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "SNAPSHOT_ID" INTEGER, + // NULLABLE at that time + "ANALYSIS_UUID" VARCHAR(50), + "TEXT_VALUE" VARCHAR(4000), + "ALERT_STATUS" VARCHAR(5), + "ALERT_TEXT" VARCHAR(4000), + "DESCRIPTION" VARCHAR(4000), + "PERSON_ID" INTEGER, + "VARIATION_VALUE_1" DOUBLE, + "VARIATION_VALUE_2" DOUBLE, + "VARIATION_VALUE_3" DOUBLE, + "VARIATION_VALUE_4" DOUBLE, + "VARIATION_VALUE_5" DOUBLE, + "MEASURE_DATA" BINARY(167772150) + ); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/CleanOrphanRowsInResourceIndexTest/in_progress_resourceindex.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/CleanOrphanRowsInResourceIndexTest/in_progress_resourceindex.sql new file mode 100644 index 00000000000..aab2040b1ed --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/CleanOrphanRowsInResourceIndexTest/in_progress_resourceindex.sql @@ -0,0 +1,12 @@ +CREATE TABLE "RESOURCE_INDEX" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "KEE" VARCHAR(400) NOT NULL, + "POSITION" INTEGER NOT NULL, + "NAME_SIZE" INTEGER NOT NULL, + "RESOURCE_ID" INTEGER NOT NULL, + "ROOT_PROJECT_ID" INTEGER NOT NULL, + "QUALIFIER" VARCHAR(10) NOT NULL, + "COMPONENT_UUID" VARCHAR(50), + "ROOT_COMPONENT_UUID" VARCHAR(50) +); + diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/CleanOrphanRowsInSnapshotsTest/in_progress_snapshots_and_children_tables.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/CleanOrphanRowsInSnapshotsTest/in_progress_snapshots_and_children_tables.sql new file mode 100644 index 00000000000..d77a2eab205 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/CleanOrphanRowsInSnapshotsTest/in_progress_snapshots_and_children_tables.sql @@ -0,0 +1,101 @@ +CREATE TABLE "SNAPSHOTS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "CREATED_AT" BIGINT, + "BUILD_DATE" BIGINT, + "PROJECT_ID" INTEGER NOT NULL, + "COMPONENT_UUID" VARCHAR(50), + "PARENT_SNAPSHOT_ID" INTEGER, + "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U', + "PURGE_STATUS" INTEGER, + "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE, + "SCOPE" VARCHAR(3), + "QUALIFIER" VARCHAR(10), + "ROOT_SNAPSHOT_ID" INTEGER, + "VERSION" VARCHAR(500), + "PATH" VARCHAR(500), + "DEPTH" INTEGER, + "ROOT_PROJECT_ID" INTEGER, + "ROOT_COMPONENT_UUID" VARCHAR(50), + "PERIOD1_MODE" VARCHAR(100), + "PERIOD1_PARAM" VARCHAR(100), + "PERIOD1_DATE" BIGINT, + "PERIOD2_MODE" VARCHAR(100), + "PERIOD2_PARAM" VARCHAR(100), + "PERIOD2_DATE" BIGINT, + "PERIOD3_MODE" VARCHAR(100), + "PERIOD3_PARAM" VARCHAR(100), + "PERIOD3_DATE" BIGINT, + "PERIOD4_MODE" VARCHAR(100), + "PERIOD4_PARAM" VARCHAR(100), + "PERIOD4_DATE" BIGINT, + "PERIOD5_MODE" VARCHAR(100), + "PERIOD5_PARAM" VARCHAR(100), + "PERIOD5_DATE" BIGINT +); + +CREATE TABLE "DUPLICATIONS_INDEX" ( + "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "PROJECT_SNAPSHOT_ID" INTEGER NOT NULL, + "SNAPSHOT_ID" INTEGER NOT NULL, + "HASH" VARCHAR(50) NOT NULL, + "INDEX_IN_FILE" INTEGER NOT NULL, + "START_LINE" INTEGER NOT NULL, + "END_LINE" INTEGER NOT NULL +); + +CREATE TABLE "PROJECT_MEASURES" ( + "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "VALUE" DOUBLE, + "METRIC_ID" INTEGER NOT NULL, + "SNAPSHOT_ID" INTEGER, + "RULE_ID" INTEGER, + "RULES_CATEGORY_ID" INTEGER, + "TEXT_VALUE" VARCHAR(4000), + "TENDENCY" INTEGER, + "MEASURE_DATE" TIMESTAMP, + "PROJECT_ID" INTEGER, + "ALERT_STATUS" VARCHAR(5), + "ALERT_TEXT" VARCHAR(4000), + "URL" VARCHAR(2000), + "DESCRIPTION" VARCHAR(4000), + "RULE_PRIORITY" INTEGER, + "CHARACTERISTIC_ID" INTEGER, + "PERSON_ID" INTEGER, + "VARIATION_VALUE_1" DOUBLE, + "VARIATION_VALUE_2" DOUBLE, + "VARIATION_VALUE_3" DOUBLE, + "VARIATION_VALUE_4" DOUBLE, + "VARIATION_VALUE_5" DOUBLE, + "MEASURE_DATA" BINARY(167772150) +); + +CREATE TABLE "CE_ACTIVITY" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "UUID" VARCHAR(40) NOT NULL, + "TASK_TYPE" VARCHAR(15) NOT NULL, + "COMPONENT_UUID" VARCHAR(40) NULL, + "SNAPSHOT_ID" INTEGER NULL, + "STATUS" VARCHAR(15) NOT NULL, + "IS_LAST" BOOLEAN NOT NULL, + "IS_LAST_KEY" VARCHAR(55) NOT NULL, + "SUBMITTER_LOGIN" VARCHAR(255) NULL, + "SUBMITTED_AT" BIGINT NOT NULL, + "STARTED_AT" BIGINT NULL, + "EXECUTED_AT" BIGINT NULL, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL, + "EXECUTION_TIME_MS" BIGINT NULL +); + +CREATE TABLE "EVENTS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "NAME" VARCHAR(400), + "COMPONENT_UUID" VARCHAR(50), + "SNAPSHOT_ID" INTEGER, + "CATEGORY" VARCHAR(50), + "EVENT_DATE" BIGINT NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + "DESCRIPTION" VARCHAR(4000), + "EVENT_DATA" VARCHAR(4000) +); + diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/CleanUsurperRootComponentsTest/complete_schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/CleanUsurperRootComponentsTest/complete_schema.sql new file mode 100644 index 00000000000..299da292538 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/CleanUsurperRootComponentsTest/complete_schema.sql @@ -0,0 +1,682 @@ +CREATE TABLE "GROUPS_USERS" ( + "USER_ID" INTEGER, + "GROUP_ID" INTEGER +); + +CREATE TABLE "RULES_PARAMETERS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "RULE_ID" INTEGER NOT NULL, + "NAME" VARCHAR(128) NOT NULL, + "PARAM_TYPE" VARCHAR(512) NOT NULL, + "DEFAULT_VALUE" VARCHAR(4000), + "DESCRIPTION" VARCHAR(4000) +); + +CREATE TABLE "RULES_PROFILES" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "NAME" VARCHAR(100) NOT NULL, + "LANGUAGE" VARCHAR(20), + "KEE" VARCHAR(255) NOT NULL, + "PARENT_KEE" VARCHAR(255), + "RULES_UPDATED_AT" VARCHAR(100), + "IS_DEFAULT" BOOLEAN NOT NULL DEFAULT FALSE, + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); + +CREATE TABLE "PROJECT_QPROFILES" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "PROJECT_UUID" VARCHAR(50) NOT NULL, + "PROFILE_KEY" VARCHAR(255) NOT NULL +); + +CREATE TABLE "WIDGETS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "DASHBOARD_ID" INTEGER NOT NULL, + "WIDGET_KEY" VARCHAR(256) NOT NULL, + "NAME" VARCHAR(256), + "DESCRIPTION" VARCHAR(1000), + "COLUMN_INDEX" INTEGER, + "ROW_INDEX" INTEGER, + "CONFIGURED" BOOLEAN, + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP, + "RESOURCE_ID" INTEGER +); + +CREATE TABLE "GROUPS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "NAME" VARCHAR(500), + "DESCRIPTION" VARCHAR(200), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); + +CREATE TABLE "SNAPSHOTS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "CREATED_AT" BIGINT, + "BUILD_DATE" BIGINT, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "PARENT_SNAPSHOT_ID" INTEGER, + "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U', + "PURGE_STATUS" INTEGER, + "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE, + "SCOPE" VARCHAR(3), + "QUALIFIER" VARCHAR(10), + "ROOT_SNAPSHOT_ID" INTEGER, + "VERSION" VARCHAR(500), + "PATH" VARCHAR(500), + "DEPTH" INTEGER, + "ROOT_COMPONENT_UUID" VARCHAR(50) NOT NULL, + "PERIOD1_MODE" VARCHAR(100), + "PERIOD1_PARAM" VARCHAR(100), + "PERIOD1_DATE" BIGINT, + "PERIOD2_MODE" VARCHAR(100), + "PERIOD2_PARAM" VARCHAR(100), + "PERIOD2_DATE" BIGINT, + "PERIOD3_MODE" VARCHAR(100), + "PERIOD3_PARAM" VARCHAR(100), + "PERIOD3_DATE" BIGINT, + "PERIOD4_MODE" VARCHAR(100), + "PERIOD4_PARAM" VARCHAR(100), + "PERIOD4_DATE" BIGINT, + "PERIOD5_MODE" VARCHAR(100), + "PERIOD5_PARAM" VARCHAR(100), + "PERIOD5_DATE" BIGINT +); + +CREATE TABLE "SCHEMA_MIGRATIONS" ( +"VERSION" VARCHAR(256) NOT NULL +); + +CREATE TABLE "GROUP_ROLES" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "GROUP_ID" INTEGER, + "RESOURCE_ID" INTEGER, + "ROLE" VARCHAR(64) NOT NULL +); + +CREATE TABLE "RULES" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, + "PLUGIN_NAME" VARCHAR(255) NOT NULL, + "DESCRIPTION" VARCHAR(16777215), + "DESCRIPTION_FORMAT" VARCHAR(20), + "PRIORITY" INTEGER, + "IS_TEMPLATE" BOOLEAN DEFAULT FALSE, + "TEMPLATE_ID" INTEGER, + "PLUGIN_CONFIG_KEY" VARCHAR(200), + "NAME" VARCHAR(200), + "STATUS" VARCHAR(40), + "LANGUAGE" VARCHAR(20), + "NOTE_DATA" CLOB(2147483647), + "NOTE_USER_LOGIN" VARCHAR(255), + "NOTE_CREATED_AT" TIMESTAMP, + "NOTE_UPDATED_AT" TIMESTAMP, + "REMEDIATION_FUNCTION" VARCHAR(20), + "DEF_REMEDIATION_FUNCTION" VARCHAR(20), + "REMEDIATION_GAP_MULT" VARCHAR(20), + "DEF_REMEDIATION_GAP_MULT" VARCHAR(20), + "REMEDIATION_BASE_EFFORT" VARCHAR(20), + "DEF_REMEDIATION_BASE_EFFORT" VARCHAR(20), + "GAP_DESCRIPTION" VARCHAR(4000), + "TAGS" VARCHAR(4000), + "SYSTEM_TAGS" VARCHAR(4000), + "RULE_TYPE" TINYINT, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT +); + + +CREATE TABLE "WIDGET_PROPERTIES" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "WIDGET_ID" INTEGER NOT NULL, + "KEE" VARCHAR(100), + "TEXT_VALUE" VARCHAR(4000) +); + +CREATE TABLE "EVENTS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "NAME" VARCHAR(400), + "COMPONENT_UUID" VARCHAR(50), + "SNAPSHOT_ID" INTEGER, + "CATEGORY" VARCHAR(50), + "EVENT_DATE" BIGINT NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + "DESCRIPTION" VARCHAR(4000), + "EVENT_DATA" VARCHAR(4000) +); + +CREATE TABLE "QUALITY_GATES" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "NAME" VARCHAR(100) NOT NULL, + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP, +); + +CREATE TABLE "QUALITY_GATE_CONDITIONS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "QGATE_ID" INTEGER, + "METRIC_ID" INTEGER, + "OPERATOR" VARCHAR(3), + "VALUE_ERROR" VARCHAR(64), + "VALUE_WARNING" VARCHAR(64), + "PERIOD" INTEGER, + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP, +); + +CREATE TABLE "PROPERTIES" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "PROP_KEY" VARCHAR(512), + "RESOURCE_ID" INTEGER, + "TEXT_VALUE" CLOB(2147483647), + "USER_ID" INTEGER +); + +CREATE TABLE "PROJECT_LINKS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "COMPONENT_UUID" VARCHAR(50), + "LINK_TYPE" VARCHAR(20), + "NAME" VARCHAR(128), + "HREF" VARCHAR(2048) NOT NULL +); + +CREATE TABLE "DUPLICATIONS_INDEX" ( + "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "PROJECT_SNAPSHOT_ID" INTEGER NOT NULL, + "SNAPSHOT_ID" INTEGER NOT NULL, + "HASH" VARCHAR(50) NOT NULL, + "INDEX_IN_FILE" INTEGER NOT NULL, + "START_LINE" INTEGER NOT NULL, + "END_LINE" INTEGER NOT NULL +); + +CREATE TABLE "PROJECT_MEASURES" ( + "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "VALUE" DOUBLE, + "METRIC_ID" INTEGER NOT NULL, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "SNAPSHOT_ID" INTEGER, + "TEXT_VALUE" VARCHAR(4000), + "ALERT_STATUS" VARCHAR(5), + "ALERT_TEXT" VARCHAR(4000), + "DESCRIPTION" VARCHAR(4000), + "PERSON_ID" INTEGER, + "VARIATION_VALUE_1" DOUBLE, + "VARIATION_VALUE_2" DOUBLE, + "VARIATION_VALUE_3" DOUBLE, + "VARIATION_VALUE_4" DOUBLE, + "VARIATION_VALUE_5" DOUBLE, + "MEASURE_DATA" BINARY(167772150) +); + +CREATE TABLE "PROJECTS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "KEE" VARCHAR(400), + "ROOT_ID" INTEGER, + "UUID" VARCHAR(50), + "PROJECT_UUID" VARCHAR(50), + "MODULE_UUID" VARCHAR(50), + "MODULE_UUID_PATH" VARCHAR(4000), + "NAME" VARCHAR(2000), + "DESCRIPTION" VARCHAR(2000), + "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, + "SCOPE" VARCHAR(3), + "QUALIFIER" VARCHAR(10), + "DEPRECATED_KEE" VARCHAR(400), + "PATH" VARCHAR(2000), + "LANGUAGE" VARCHAR(20), + "COPY_RESOURCE_ID" INTEGER, + "LONG_NAME" VARCHAR(2000), + "PERSON_ID" INTEGER, + "CREATED_AT" TIMESTAMP, + "AUTHORIZATION_UPDATED_AT" BIGINT +); + +CREATE TABLE "MANUAL_MEASURES" ( + "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "METRIC_ID" INTEGER NOT NULL, + "COMPONENT_UUID" VARCHAR(50), + "VALUE" DOUBLE, + "TEXT_VALUE" VARCHAR(4000), + "USER_LOGIN" VARCHAR(255), + "DESCRIPTION" VARCHAR(4000), + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT +); + +CREATE TABLE "ACTIVE_RULES" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "PROFILE_ID" INTEGER NOT NULL, + "RULE_ID" INTEGER NOT NULL, + "FAILURE_LEVEL" INTEGER NOT NULL, + "INHERITANCE" VARCHAR(10), + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT +); + +CREATE TABLE "NOTIFICATIONS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "DATA" BLOB(167772150) +); + +CREATE TABLE "USER_ROLES" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "USER_ID" INTEGER, + "RESOURCE_ID" INTEGER, + "ROLE" VARCHAR(64) NOT NULL +); + +CREATE TABLE "ACTIVE_DASHBOARDS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "DASHBOARD_ID" INTEGER NOT NULL, + "USER_ID" INTEGER, + "ORDER_INDEX" INTEGER +); + +CREATE TABLE "ACTIVE_RULE_PARAMETERS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "ACTIVE_RULE_ID" INTEGER NOT NULL, + "RULES_PARAMETER_ID" INTEGER NOT NULL, + "RULES_PARAMETER_KEY" VARCHAR(128), + "VALUE" VARCHAR(4000) +); + +CREATE TABLE "USERS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "LOGIN" VARCHAR(255), + "NAME" VARCHAR(200), + "EMAIL" VARCHAR(100), + "CRYPTED_PASSWORD" VARCHAR(40), + "SALT" VARCHAR(40), + "ACTIVE" BOOLEAN DEFAULT TRUE, + "SCM_ACCOUNTS" VARCHAR(4000), + "EXTERNAL_IDENTITY" VARCHAR(255), + "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100), + "USER_LOCAL" BOOLEAN, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT +); + +CREATE TABLE "DASHBOARDS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "USER_ID" INTEGER, + "NAME" VARCHAR(256), + "DESCRIPTION" VARCHAR(1000), + "COLUMN_LAYOUT" VARCHAR(20), + "SHARED" BOOLEAN, + "IS_GLOBAL" BOOLEAN, + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); + +CREATE TABLE "METRICS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "NAME" VARCHAR(64) NOT NULL, + "DESCRIPTION" VARCHAR(255), + "DIRECTION" INTEGER NOT NULL DEFAULT 0, + "DOMAIN" VARCHAR(64), + "SHORT_NAME" VARCHAR(64), + "QUALITATIVE" BOOLEAN NOT NULL DEFAULT FALSE, + "VAL_TYPE" VARCHAR(8), + "USER_MANAGED" BOOLEAN DEFAULT FALSE, + "ENABLED" BOOLEAN DEFAULT TRUE, + "WORST_VALUE" DOUBLE, + "BEST_VALUE" DOUBLE, + "OPTIMIZED_BEST_VALUE" BOOLEAN, + "HIDDEN" BOOLEAN, + "DELETE_HISTORICAL_DATA" BOOLEAN, + "DECIMAL_SCALE" INTEGER +); + +CREATE TABLE "LOADED_TEMPLATES" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "KEE" VARCHAR(200), + "TEMPLATE_TYPE" VARCHAR(15) +); + +CREATE TABLE "RESOURCE_INDEX" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "KEE" VARCHAR(400) NOT NULL, + "POSITION" INTEGER NOT NULL, + "NAME_SIZE" INTEGER NOT NULL, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "ROOT_COMPONENT_UUID" VARCHAR(50) NOT NULL, + "QUALIFIER" VARCHAR(10) NOT NULL +); + +CREATE TABLE "AUTHORS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "PERSON_ID" INTEGER, + "LOGIN" VARCHAR(255), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); + +CREATE TABLE "MEASURE_FILTERS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "NAME" VARCHAR(100) NOT NULL, + "SHARED" BOOLEAN NOT NULL DEFAULT FALSE, + "USER_ID" INTEGER, + "DESCRIPTION" VARCHAR(4000), + "DATA" CLOB(2147483647), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); + +CREATE TABLE "MEASURE_FILTER_FAVOURITES" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "USER_ID" INTEGER NOT NULL, + "MEASURE_FILTER_ID" INTEGER NOT NULL, + "CREATED_AT" TIMESTAMP +); + +CREATE TABLE "ISSUES" ( + "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "KEE" VARCHAR(50) UNIQUE NOT NULL, + "COMPONENT_UUID" VARCHAR(50), + "PROJECT_UUID" VARCHAR(50), + "RULE_ID" INTEGER, + "SEVERITY" VARCHAR(10), + "MANUAL_SEVERITY" BOOLEAN NOT NULL, + "MESSAGE" VARCHAR(4000), + "LINE" INTEGER, + "GAP" DOUBLE, + "EFFORT" INTEGER, + "STATUS" VARCHAR(20), + "RESOLUTION" VARCHAR(20), + "CHECKSUM" VARCHAR(1000), + "REPORTER" VARCHAR(255), + "ASSIGNEE" VARCHAR(255), + "AUTHOR_LOGIN" VARCHAR(255), + "ACTION_PLAN_KEY" VARCHAR(50) NULL, + "ISSUE_ATTRIBUTES" VARCHAR(4000), + "TAGS" VARCHAR(4000), + "ISSUE_CREATION_DATE" BIGINT, + "ISSUE_CLOSE_DATE" BIGINT, + "ISSUE_UPDATE_DATE" BIGINT, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "LOCATIONS" BLOB(167772150), + "ISSUE_TYPE" TINYINT +); + +CREATE TABLE "ISSUE_CHANGES" ( + "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "KEE" VARCHAR(50), + "ISSUE_KEY" VARCHAR(50) NOT NULL, + "USER_LOGIN" VARCHAR(255), + "CHANGE_TYPE" VARCHAR(40), + "CHANGE_DATA" VARCHAR(16777215), + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "ISSUE_CHANGE_CREATION_DATE" BIGINT +); + +CREATE TABLE "ISSUE_FILTERS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "NAME" VARCHAR(100) NOT NULL, + "SHARED" BOOLEAN NOT NULL DEFAULT FALSE, + "USER_LOGIN" VARCHAR(255), + "DESCRIPTION" VARCHAR(4000), + "DATA" CLOB(2147483647), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); + +CREATE TABLE "ISSUE_FILTER_FAVOURITES" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "USER_LOGIN" VARCHAR(255) NOT NULL, + "ISSUE_FILTER_ID" INTEGER NOT NULL, + "CREATED_AT" TIMESTAMP +); + +CREATE TABLE "PERMISSION_TEMPLATES" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "NAME" VARCHAR(100) NOT NULL, + "KEE" VARCHAR(100) NOT NULL, + "DESCRIPTION" VARCHAR(4000), + "KEY_PATTERN" VARCHAR(500), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); + +CREATE TABLE "PERM_TPL_CHARACTERISTICS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "TEMPLATE_ID" INTEGER NOT NULL, + "PERMISSION_KEY" VARCHAR(64) NOT NULL, + "WITH_PROJECT_CREATOR" BOOLEAN NOT NULL DEFAULT FALSE, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL +); + +CREATE TABLE "PERM_TEMPLATES_USERS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "USER_ID" INTEGER NOT NULL, + "TEMPLATE_ID" INTEGER NOT NULL, + "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); + +CREATE TABLE "PERM_TEMPLATES_GROUPS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "GROUP_ID" INTEGER, + "TEMPLATE_ID" INTEGER NOT NULL, + "PERMISSION_REFERENCE" VARCHAR(64) NOT NULL, + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); + + +CREATE TABLE "ACTIVITIES" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "LOG_KEY" VARCHAR(250), + "CREATED_AT" TIMESTAMP, + "USER_LOGIN" VARCHAR(255), + "LOG_TYPE" VARCHAR(250), + "LOG_ACTION" VARCHAR(250), + "LOG_MESSAGE" VARCHAR(250), + "DATA_FIELD" CLOB(2147483647) +); + +CREATE TABLE "FILE_SOURCES" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "PROJECT_UUID" VARCHAR(50) NOT NULL, + "FILE_UUID" VARCHAR(50) NOT NULL, + "LINE_HASHES" CLOB(2147483647), + "BINARY_DATA" BLOB(167772150), + "DATA_TYPE" VARCHAR(20), + "DATA_HASH" VARCHAR(50), + "SRC_HASH" VARCHAR(50), + "REVISION" VARCHAR(100), + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL +); + +CREATE TABLE "CE_QUEUE" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "UUID" VARCHAR(40) NOT NULL, + "TASK_TYPE" VARCHAR(15) NOT NULL, + "COMPONENT_UUID" VARCHAR(40) NULL, + "STATUS" VARCHAR(15) NOT NULL, + "SUBMITTER_LOGIN" VARCHAR(255) NULL, + "STARTED_AT" BIGINT NULL, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL +); + +CREATE TABLE "CE_ACTIVITY" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "UUID" VARCHAR(40) NOT NULL, + "TASK_TYPE" VARCHAR(15) NOT NULL, + "COMPONENT_UUID" VARCHAR(40) NULL, + "SNAPSHOT_ID" INTEGER NULL, + "STATUS" VARCHAR(15) NOT NULL, + "IS_LAST" BOOLEAN NOT NULL, + "IS_LAST_KEY" VARCHAR(55) NOT NULL, + "SUBMITTER_LOGIN" VARCHAR(255) NULL, + "SUBMITTED_AT" BIGINT NOT NULL, + "STARTED_AT" BIGINT NULL, + "EXECUTED_AT" BIGINT NULL, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL, + "EXECUTION_TIME_MS" BIGINT NULL +); + +CREATE TABLE "USER_TOKENS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "LOGIN" VARCHAR(255) NOT NULL, + "NAME" VARCHAR(100) NOT NULL, + "TOKEN_HASH" VARCHAR(255) NOT NULL, + "CREATED_AT" BIGINT NOT NULL +); + +-- ---------------------------------------------- +-- DDL Statements for indexes +-- ---------------------------------------------- + +CREATE UNIQUE INDEX "ACTIVITIES_LOG_KEY" ON "ACTIVITIES" ("LOG_KEY"); + +CREATE INDEX "GROUP_ROLES_RESOURCE" ON "GROUP_ROLES" ("RESOURCE_ID"); + +CREATE INDEX "USER_ROLES_RESOURCE" ON "USER_ROLES" ("RESOURCE_ID"); + +CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES" ("USER_ID"); + +CREATE INDEX "DUPLICATIONS_INDEX_HASH" ON "DUPLICATIONS_INDEX" ("HASH"); + +CREATE INDEX "DUPLICATIONS_INDEX_SID" ON "DUPLICATIONS_INDEX" ("SNAPSHOT_ID"); + +CREATE INDEX "INDEX_GROUPS_USERS_ON_GROUP_ID" ON "GROUPS_USERS" ("GROUP_ID"); + +CREATE INDEX "INDEX_GROUPS_USERS_ON_USER_ID" ON "GROUPS_USERS" ("USER_ID"); + +CREATE UNIQUE INDEX "GROUPS_USERS_UNIQUE" ON "GROUPS_USERS" ("GROUP_ID", "USER_ID"); + +CREATE INDEX "MEASURES_SID_METRIC" ON "PROJECT_MEASURES" ("SNAPSHOT_ID", "METRIC_ID"); + +CREATE INDEX "MEASURES_PERSON" ON "PROJECT_MEASURES" ("PERSON_ID"); + +CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS" ("NAME"); + +CREATE INDEX "EVENTS_SNAPSHOT_ID" ON "EVENTS" ("SNAPSHOT_ID"); + +CREATE INDEX "EVENTS_COMPONENT_UUID" ON "EVENTS" ("COMPONENT_UUID"); + +CREATE INDEX "WIDGETS_WIDGETKEY" ON "WIDGETS" ("WIDGET_KEY"); + +CREATE INDEX "WIDGETS_DASHBOARDS" ON "WIDGETS" ("DASHBOARD_ID"); + +CREATE INDEX "SNAPSHOTS_QUALIFIER" ON "SNAPSHOTS" ("QUALIFIER"); + +CREATE INDEX "SNAPSHOTS_ROOT" ON "SNAPSHOTS" ("ROOT_SNAPSHOT_ID"); + +CREATE INDEX "SNAPSHOTS_PARENT" ON "SNAPSHOTS" ("PARENT_SNAPSHOT_ID"); + +CREATE INDEX "SNAPSHOT_COMPONENT" ON "SNAPSHOTS" ("COMPONENT_UUID"); + +CREATE INDEX "RULES_PARAMETERS_RULE_ID" ON "RULES_PARAMETERS" ("RULE_ID"); + +CREATE INDEX "ACTIVE_DASHBOARDS_DASHBOARDID" ON "ACTIVE_DASHBOARDS" ("DASHBOARD_ID"); + +CREATE INDEX "ACTIVE_DASHBOARDS_USERID" ON "ACTIVE_DASHBOARDS" ("USER_ID"); + +CREATE INDEX "UNIQUE_SCHEMA_MIGRATIONS" ON "SCHEMA_MIGRATIONS" ("VERSION"); + +CREATE INDEX "WIDGET_PROPERTIES_WIDGETS" ON "WIDGET_PROPERTIES" ("WIDGET_ID"); + +CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES" ("PROP_KEY"); + +CREATE INDEX "MANUAL_MEASURES_COMPONENT_UUID" ON "MANUAL_MEASURES" ("COMPONENT_UUID"); + +CREATE UNIQUE INDEX "PROJECTS_KEE" ON "PROJECTS" ("KEE"); + +CREATE INDEX "PROJECTS_ROOT_ID" ON "PROJECTS" ("ROOT_ID"); + +CREATE UNIQUE INDEX "PROJECTS_UUID" ON "PROJECTS" ("UUID"); + +CREATE INDEX "PROJECTS_PROJECT_UUID" ON "PROJECTS" ("PROJECT_UUID"); + +CREATE INDEX "PROJECTS_MODULE_UUID" ON "PROJECTS" ("MODULE_UUID"); + +CREATE INDEX "PROJECTS_QUALIFIER" ON "PROJECTS" ("QUALIFIER"); + +CREATE INDEX "RESOURCE_INDEX_KEY" ON "RESOURCE_INDEX" ("KEE"); + +CREATE INDEX "RESOURCE_INDEX_COMPONENT" ON "RESOURCE_INDEX" ("COMPONENT_UUID"); + +CREATE UNIQUE INDEX "UNIQ_AUTHOR_LOGINS" ON "AUTHORS" ("LOGIN"); + +CREATE INDEX "MEASURE_FILTERS_NAME" ON "MEASURE_FILTERS" ("NAME"); + +CREATE INDEX "MEASURE_FILTER_FAVS_USERID" ON "MEASURE_FILTER_FAVOURITES" ("USER_ID"); + +CREATE UNIQUE INDEX "ISSUES_KEE" ON "ISSUES" ("KEE"); + +CREATE INDEX "ISSUES_COMPONENT_UUID" ON "ISSUES" ("COMPONENT_UUID"); + +CREATE INDEX "ISSUES_PROJECT_UUID" ON "ISSUES" ("PROJECT_UUID"); + +CREATE INDEX "ISSUES_RULE_ID" ON "ISSUES" ("RULE_ID"); + +CREATE INDEX "ISSUES_RESOLUTION" ON "ISSUES" ("RESOLUTION"); + +CREATE INDEX "ISSUES_ASSIGNEE" ON "ISSUES" ("ASSIGNEE"); + +CREATE INDEX "ISSUES_CREATION_DATE" ON "ISSUES" ("ISSUE_CREATION_DATE"); + +CREATE INDEX "ISSUES_UPDATED_AT" ON "ISSUES" ("UPDATED_AT"); + +CREATE INDEX "ISSUE_CHANGES_KEE" ON "ISSUE_CHANGES" ("KEE"); + +CREATE INDEX "ISSUE_CHANGES_ISSUE_KEY" ON "ISSUE_CHANGES" ("ISSUE_KEY"); + +CREATE INDEX "ISSUE_FILTERS_NAME" ON "ISSUE_FILTERS" ("NAME"); + +CREATE INDEX "ISSUE_FILTER_FAVS_USER" ON "ISSUE_FILTER_FAVOURITES" ("USER_LOGIN"); + +CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS" ("LOGIN"); + +CREATE INDEX "USERS_UPDATED_AT" ON "USERS" ("UPDATED_AT"); + +CREATE INDEX "SNAPSHOTS_ROOT_COMPONENT" ON "SNAPSHOTS" ("ROOT_COMPONENT_UUID"); + +CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES" ("GROUP_ID", "RESOURCE_ID", "ROLE"); + +CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES" ("PLUGIN_NAME", "PLUGIN_RULE_KEY"); + +CREATE UNIQUE INDEX "UNIQ_QUALITY_GATES" ON "QUALITY_GATES" ("NAME"); + +CREATE UNIQUE INDEX "ACTIVE_RULES_UNIQUE" ON "ACTIVE_RULES" ("PROFILE_ID","RULE_ID"); + +CREATE UNIQUE INDEX "UNIQ_QPROF_KEY" ON "RULES_PROFILES" ("KEE"); + +CREATE INDEX "FILE_SOURCES_PROJECT_UUID" ON "FILE_SOURCES" ("PROJECT_UUID"); + +CREATE UNIQUE INDEX "FILE_SOURCES_UUID_TYPE" ON "FILE_SOURCES" ("FILE_UUID", "DATA_TYPE"); + +CREATE INDEX "FILE_SOURCES_UPDATED_AT" ON "FILE_SOURCES" ("UPDATED_AT"); + +CREATE UNIQUE INDEX "UNIQ_PROJECT_QPROFILES" ON "PROJECT_QPROFILES" ("PROJECT_UUID", "PROFILE_KEY"); + +CREATE UNIQUE INDEX "CE_QUEUE_UUID" ON "CE_QUEUE" ("UUID"); + +CREATE INDEX "CE_QUEUE_COMPONENT_UUID" ON "CE_QUEUE" ("COMPONENT_UUID"); + +CREATE INDEX "CE_QUEUE_STATUS" ON "CE_QUEUE" ("STATUS"); + +CREATE UNIQUE INDEX "CE_ACTIVITY_UUID" ON "CE_ACTIVITY" ("UUID"); + +CREATE INDEX "CE_ACTIVITY_COMPONENT_UUID" ON "CE_ACTIVITY" ("COMPONENT_UUID"); + +CREATE UNIQUE INDEX "USER_TOKENS_TOKEN_HASH" ON "USER_TOKENS" ("TOKEN_HASH"); + +CREATE UNIQUE INDEX "USER_TOKENS_LOGIN_NAME" ON "USER_TOKENS" ("LOGIN", "NAME"); + +CREATE INDEX "CE_ACTIVITY_ISLASTKEY" ON "CE_ACTIVITY" ("IS_LAST_KEY"); + +CREATE INDEX "CE_ACTIVITY_ISLAST_STATUS" ON "CE_ACTIVITY" ("IS_LAST", "STATUS"); + +CREATE UNIQUE INDEX "UNIQ_PERM_TPL_CHARAC" ON "PERM_TPL_CHARACTERISTICS" ("TEMPLATE_ID", "PERMISSION_KEY"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/CreatePermTemplatesCharacteristicsTest/empty.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/CreatePermTemplatesCharacteristicsTest/empty.sql new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/CreatePermTemplatesCharacteristicsTest/empty.sql diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/DeleteOrphanMeasuresWithoutComponentTest/in_progress_project_measures.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/DeleteOrphanMeasuresWithoutComponentTest/in_progress_project_measures.sql new file mode 100644 index 00000000000..42d924883b9 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/DeleteOrphanMeasuresWithoutComponentTest/in_progress_project_measures.sql @@ -0,0 +1,32 @@ +CREATE TABLE "PROJECT_MEASURES" ( + "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "VALUE" DOUBLE, + "METRIC_ID" INTEGER NOT NULL, + "SNAPSHOT_ID" INTEGER, + "RULE_ID" INTEGER, + "RULES_CATEGORY_ID" INTEGER, + "TEXT_VALUE" VARCHAR(4000), + "TENDENCY" INTEGER, + "MEASURE_DATE" TIMESTAMP, + "PROJECT_ID" INTEGER, + "ALERT_STATUS" VARCHAR(5), + "ALERT_TEXT" VARCHAR(4000), + "URL" VARCHAR(2000), + "DESCRIPTION" VARCHAR(4000), + "RULE_PRIORITY" INTEGER, + "CHARACTERISTIC_ID" INTEGER, + "PERSON_ID" INTEGER, + "VARIATION_VALUE_1" DOUBLE, + "VARIATION_VALUE_2" DOUBLE, + "VARIATION_VALUE_3" DOUBLE, + "VARIATION_VALUE_4" DOUBLE, + "VARIATION_VALUE_5" DOUBLE, + "MEASURE_DATA" BINARY(167772150), + + // new column, introduced in migration 1214 + "COMPONENT_UUID" VARCHAR(50) +); + +CREATE INDEX "MEASURES_SID_METRIC" ON "PROJECT_MEASURES" ("SNAPSHOT_ID", "METRIC_ID"); + +CREATE INDEX "MEASURES_PERSON" ON "PROJECT_MEASURES" ("PERSON_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/DropIdColumnsFromResourceIndexTest/in_progress_resourceindex.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/DropIdColumnsFromResourceIndexTest/in_progress_resourceindex.sql new file mode 100644 index 00000000000..aab2040b1ed --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/DropIdColumnsFromResourceIndexTest/in_progress_resourceindex.sql @@ -0,0 +1,12 @@ +CREATE TABLE "RESOURCE_INDEX" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "KEE" VARCHAR(400) NOT NULL, + "POSITION" INTEGER NOT NULL, + "NAME_SIZE" INTEGER NOT NULL, + "RESOURCE_ID" INTEGER NOT NULL, + "ROOT_PROJECT_ID" INTEGER NOT NULL, + "QUALIFIER" VARCHAR(10) NOT NULL, + "COMPONENT_UUID" VARCHAR(50), + "ROOT_COMPONENT_UUID" VARCHAR(50) +); + diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/DropTreesOfSnapshotsTest/in_progress_snapshots.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/DropTreesOfSnapshotsTest/in_progress_snapshots.sql new file mode 100644 index 00000000000..8e89fd56335 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/DropTreesOfSnapshotsTest/in_progress_snapshots.sql @@ -0,0 +1,33 @@ +CREATE TABLE "SNAPSHOTS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "CREATED_AT" BIGINT, + "BUILD_DATE" BIGINT, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "UUID" VARCHAR(50) NOT NULL, + "PARENT_SNAPSHOT_ID" INTEGER, + "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U', + "PURGE_STATUS" INTEGER, + "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE, + "SCOPE" VARCHAR(3), + "QUALIFIER" VARCHAR(10), + "ROOT_SNAPSHOT_ID" INTEGER, + "VERSION" VARCHAR(500), + "PATH" VARCHAR(500), + "DEPTH" INTEGER, + "ROOT_COMPONENT_UUID" VARCHAR(50), + "PERIOD1_MODE" VARCHAR(100), + "PERIOD1_PARAM" VARCHAR(100), + "PERIOD1_DATE" BIGINT, + "PERIOD2_MODE" VARCHAR(100), + "PERIOD2_PARAM" VARCHAR(100), + "PERIOD2_DATE" BIGINT, + "PERIOD3_MODE" VARCHAR(100), + "PERIOD3_PARAM" VARCHAR(100), + "PERIOD3_DATE" BIGINT, + "PERIOD4_MODE" VARCHAR(100), + "PERIOD4_PARAM" VARCHAR(100), + "PERIOD4_DATE" BIGINT, + "PERIOD5_MODE" VARCHAR(100), + "PERIOD5_PARAM" VARCHAR(100), + "PERIOD5_DATE" BIGINT +); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/FixProjectUuidOfDeveloperProjectsTest/projects_5.6.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/FixProjectUuidOfDeveloperProjectsTest/projects_5.6.sql new file mode 100644 index 00000000000..d051017969b --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/FixProjectUuidOfDeveloperProjectsTest/projects_5.6.sql @@ -0,0 +1,23 @@ +CREATE TABLE "PROJECTS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "KEE" VARCHAR(400), + "ROOT_ID" INTEGER, + "UUID" VARCHAR(50), + "PROJECT_UUID" VARCHAR(50), + "MODULE_UUID" VARCHAR(50), + "MODULE_UUID_PATH" VARCHAR(4000), + "NAME" VARCHAR(2000), + "DESCRIPTION" VARCHAR(2000), + "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, + "SCOPE" VARCHAR(3), + "QUALIFIER" VARCHAR(10), + "DEPRECATED_KEE" VARCHAR(400), + "PATH" VARCHAR(2000), + "LANGUAGE" VARCHAR(20), + "COPY_RESOURCE_ID" INTEGER, + "LONG_NAME" VARCHAR(2000), + "PERSON_ID" INTEGER, + "CREATED_AT" TIMESTAMP, + "AUTHORIZATION_UPDATED_AT" BIGINT +); + diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeAnalysisUuidNotNullOnMeasuresTest/in_progress_measures.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeAnalysisUuidNotNullOnMeasuresTest/in_progress_measures.sql new file mode 100644 index 00000000000..5f58ad529ce --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeAnalysisUuidNotNullOnMeasuresTest/in_progress_measures.sql @@ -0,0 +1,20 @@ +CREATE TABLE "PROJECT_MEASURES" ( + "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "VALUE" DOUBLE, + "METRIC_ID" INTEGER NOT NULL, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "SNAPSHOT_ID" INTEGER, + // NULLABLE at that time + "ANALYSIS_UUID" VARCHAR(50), + "TEXT_VALUE" VARCHAR(4000), + "ALERT_STATUS" VARCHAR(5), + "ALERT_TEXT" VARCHAR(4000), + "DESCRIPTION" VARCHAR(4000), + "PERSON_ID" INTEGER, + "VARIATION_VALUE_1" DOUBLE, + "VARIATION_VALUE_2" DOUBLE, + "VARIATION_VALUE_3" DOUBLE, + "VARIATION_VALUE_4" DOUBLE, + "VARIATION_VALUE_5" DOUBLE, + "MEASURE_DATA" BINARY(167772150) + ); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndexTest/in_progress_duplications_index.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndexTest/in_progress_duplications_index.sql new file mode 100644 index 00000000000..5bd4e10d8de --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndexTest/in_progress_duplications_index.sql @@ -0,0 +1,11 @@ +CREATE TABLE "DUPLICATIONS_INDEX" ( + "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "PROJECT_SNAPSHOT_ID" INTEGER NOT NULL, + "SNAPSHOT_ID" INTEGER NOT NULL, + "ANALYSIS_UUID" VARCHAR(50), + "COMPONENT_UUID" VARCHAR(50), + "HASH" VARCHAR(50) NOT NULL, + "INDEX_IN_FILE" INTEGER NOT NULL, + "START_LINE" INTEGER NOT NULL, + "END_LINE" INTEGER NOT NULL +); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidColumnsNotNullOnSnapshotsTest/in_progress_snapshots.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidColumnsNotNullOnSnapshotsTest/in_progress_snapshots.sql new file mode 100644 index 00000000000..89c13c7e102 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidColumnsNotNullOnSnapshotsTest/in_progress_snapshots.sql @@ -0,0 +1,34 @@ +CREATE TABLE "SNAPSHOTS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "CREATED_AT" BIGINT, + "BUILD_DATE" BIGINT, + "PROJECT_ID" INTEGER NOT NULL, + "COMPONENT_UUID" VARCHAR(50), + "PARENT_SNAPSHOT_ID" INTEGER, + "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U', + "PURGE_STATUS" INTEGER, + "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE, + "SCOPE" VARCHAR(3), + "QUALIFIER" VARCHAR(10), + "ROOT_SNAPSHOT_ID" INTEGER, + "VERSION" VARCHAR(500), + "PATH" VARCHAR(500), + "DEPTH" INTEGER, + "ROOT_PROJECT_ID" INTEGER, + "ROOT_COMPONENT_UUID" VARCHAR(50), + "PERIOD1_MODE" VARCHAR(100), + "PERIOD1_PARAM" VARCHAR(100), + "PERIOD1_DATE" BIGINT, + "PERIOD2_MODE" VARCHAR(100), + "PERIOD2_PARAM" VARCHAR(100), + "PERIOD2_DATE" BIGINT, + "PERIOD3_MODE" VARCHAR(100), + "PERIOD3_PARAM" VARCHAR(100), + "PERIOD3_DATE" BIGINT, + "PERIOD4_MODE" VARCHAR(100), + "PERIOD4_PARAM" VARCHAR(100), + "PERIOD4_DATE" BIGINT, + "PERIOD5_MODE" VARCHAR(100), + "PERIOD5_PARAM" VARCHAR(100), + "PERIOD5_DATE" BIGINT +); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidNotNullOnMeasuresTest/in_progress_project_measures.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidNotNullOnMeasuresTest/in_progress_project_measures.sql new file mode 100644 index 00000000000..42d924883b9 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeComponentUuidNotNullOnMeasuresTest/in_progress_project_measures.sql @@ -0,0 +1,32 @@ +CREATE TABLE "PROJECT_MEASURES" ( + "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "VALUE" DOUBLE, + "METRIC_ID" INTEGER NOT NULL, + "SNAPSHOT_ID" INTEGER, + "RULE_ID" INTEGER, + "RULES_CATEGORY_ID" INTEGER, + "TEXT_VALUE" VARCHAR(4000), + "TENDENCY" INTEGER, + "MEASURE_DATE" TIMESTAMP, + "PROJECT_ID" INTEGER, + "ALERT_STATUS" VARCHAR(5), + "ALERT_TEXT" VARCHAR(4000), + "URL" VARCHAR(2000), + "DESCRIPTION" VARCHAR(4000), + "RULE_PRIORITY" INTEGER, + "CHARACTERISTIC_ID" INTEGER, + "PERSON_ID" INTEGER, + "VARIATION_VALUE_1" DOUBLE, + "VARIATION_VALUE_2" DOUBLE, + "VARIATION_VALUE_3" DOUBLE, + "VARIATION_VALUE_4" DOUBLE, + "VARIATION_VALUE_5" DOUBLE, + "MEASURE_DATA" BINARY(167772150), + + // new column, introduced in migration 1214 + "COMPONENT_UUID" VARCHAR(50) +); + +CREATE INDEX "MEASURES_SID_METRIC" ON "PROJECT_MEASURES" ("SNAPSHOT_ID", "METRIC_ID"); + +CREATE INDEX "MEASURES_PERSON" ON "PROJECT_MEASURES" ("PERSON_ID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeProfileKeyNotNullOnActivitiesTest/activities.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeProfileKeyNotNullOnActivitiesTest/activities.sql new file mode 100644 index 00000000000..fead19a9ef2 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeProfileKeyNotNullOnActivitiesTest/activities.sql @@ -0,0 +1,11 @@ +CREATE TABLE "ACTIVITIES" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "LOG_KEY" VARCHAR(250), + "PROFILE_KEY" VARCHAR(255), + "CREATED_AT" TIMESTAMP, + "USER_LOGIN" VARCHAR(255), + "LOG_TYPE" VARCHAR(250), + "LOG_ACTION" VARCHAR(250), + "LOG_MESSAGE" VARCHAR(250), + "DATA_FIELD" CLOB(2147483647) +); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnNotNullOnSnapshotsTest/in_progress_snapshots.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnNotNullOnSnapshotsTest/in_progress_snapshots.sql new file mode 100644 index 00000000000..e87bc84183e --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnNotNullOnSnapshotsTest/in_progress_snapshots.sql @@ -0,0 +1,34 @@ +CREATE TABLE "SNAPSHOTS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + // NULLABLE + "UUID" VARCHAR(50), + "CREATED_AT" BIGINT, + "BUILD_DATE" BIGINT, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "PARENT_SNAPSHOT_ID" INTEGER, + "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U', + "PURGE_STATUS" INTEGER, + "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE, + "SCOPE" VARCHAR(3), + "QUALIFIER" VARCHAR(10), + "ROOT_SNAPSHOT_ID" INTEGER, + "VERSION" VARCHAR(500), + "PATH" VARCHAR(500), + "DEPTH" INTEGER, + "ROOT_COMPONENT_UUID" VARCHAR(50) NOT NULL, + "PERIOD1_MODE" VARCHAR(100), + "PERIOD1_PARAM" VARCHAR(100), + "PERIOD1_DATE" BIGINT, + "PERIOD2_MODE" VARCHAR(100), + "PERIOD2_PARAM" VARCHAR(100), + "PERIOD2_DATE" BIGINT, + "PERIOD3_MODE" VARCHAR(100), + "PERIOD3_PARAM" VARCHAR(100), + "PERIOD3_DATE" BIGINT, + "PERIOD4_MODE" VARCHAR(100), + "PERIOD4_PARAM" VARCHAR(100), + "PERIOD4_DATE" BIGINT, + "PERIOD5_MODE" VARCHAR(100), + "PERIOD5_PARAM" VARCHAR(100), + "PERIOD5_DATE" BIGINT +); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnsNotNullOnProjectsTest/in_progress_projects.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnsNotNullOnProjectsTest/in_progress_projects.sql new file mode 100644 index 00000000000..5ea7d165ad3 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnsNotNullOnProjectsTest/in_progress_projects.sql @@ -0,0 +1,25 @@ +CREATE TABLE "PROJECTS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "KEE" VARCHAR(400), + "ROOT_ID" INTEGER, + "UUID" VARCHAR(50), + "PROJECT_UUID" VARCHAR(50), + "MODULE_UUID" VARCHAR(50), + "MODULE_UUID_PATH" VARCHAR(4000), + "NAME" VARCHAR(2000), + "DESCRIPTION" VARCHAR(2000), + "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, + "SCOPE" VARCHAR(3), + "QUALIFIER" VARCHAR(10), + "DEPRECATED_KEE" VARCHAR(400), + "PATH" VARCHAR(2000), + "LANGUAGE" VARCHAR(20), + "COPY_RESOURCE_ID" INTEGER, + "LONG_NAME" VARCHAR(2000), + "PERSON_ID" INTEGER, + "CREATED_AT" TIMESTAMP, + "AUTHORIZATION_UPDATED_AT" BIGINT, + "ROOT_UUID" VARCHAR(50), + "COPY_COMPONENT_UUID" VARCHAR(50), + "DEVELOPER_UUID" VARCHAR(50) +); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnsNotNullOnResourceIndexTest/in_progress_resourceindex.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnsNotNullOnResourceIndexTest/in_progress_resourceindex.sql new file mode 100644 index 00000000000..aab2040b1ed --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/MakeUuidColumnsNotNullOnResourceIndexTest/in_progress_resourceindex.sql @@ -0,0 +1,12 @@ +CREATE TABLE "RESOURCE_INDEX" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "KEE" VARCHAR(400) NOT NULL, + "POSITION" INTEGER NOT NULL, + "NAME_SIZE" INTEGER NOT NULL, + "RESOURCE_ID" INTEGER NOT NULL, + "ROOT_PROJECT_ID" INTEGER NOT NULL, + "QUALIFIER" VARCHAR(10) NOT NULL, + "COMPONENT_UUID" VARCHAR(50), + "ROOT_COMPONENT_UUID" VARCHAR(50) +); + diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidColumnOnCeActivityTest/in_progress_ce_activity.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidColumnOnCeActivityTest/in_progress_ce_activity.sql new file mode 100644 index 00000000000..25d5c6cb28f --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidColumnOnCeActivityTest/in_progress_ce_activity.sql @@ -0,0 +1,52 @@ +CREATE TABLE "CE_ACTIVITY" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "UUID" VARCHAR(40) NOT NULL, + "TASK_TYPE" VARCHAR(15) NOT NULL, + "COMPONENT_UUID" VARCHAR(40) NULL, + "SNAPSHOT_ID" INTEGER NULL, + "ANALYSIS_UUID" VARCHAR(50) NULL, + "STATUS" VARCHAR(15) NOT NULL, + "IS_LAST" BOOLEAN NOT NULL, + "IS_LAST_KEY" VARCHAR(55) NOT NULL, + "SUBMITTER_LOGIN" VARCHAR(255) NULL, + "SUBMITTED_AT" BIGINT NOT NULL, + "STARTED_AT" BIGINT NULL, + "EXECUTED_AT" BIGINT NULL, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL, + "EXECUTION_TIME_MS" BIGINT NULL +); + +CREATE TABLE "SNAPSHOTS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "UUID" VARCHAR(50) NOT NULL, + "CREATED_AT" BIGINT, + "BUILD_DATE" BIGINT, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "PARENT_SNAPSHOT_ID" INTEGER, + "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U', + "PURGE_STATUS" INTEGER, + "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE, + "SCOPE" VARCHAR(3), + "QUALIFIER" VARCHAR(10), + "ROOT_SNAPSHOT_ID" INTEGER, + "VERSION" VARCHAR(500), + "PATH" VARCHAR(500), + "DEPTH" INTEGER, + "ROOT_COMPONENT_UUID" VARCHAR(50) NOT NULL, + "PERIOD1_MODE" VARCHAR(100), + "PERIOD1_PARAM" VARCHAR(100), + "PERIOD1_DATE" BIGINT, + "PERIOD2_MODE" VARCHAR(100), + "PERIOD2_PARAM" VARCHAR(100), + "PERIOD2_DATE" BIGINT, + "PERIOD3_MODE" VARCHAR(100), + "PERIOD3_PARAM" VARCHAR(100), + "PERIOD3_DATE" BIGINT, + "PERIOD4_MODE" VARCHAR(100), + "PERIOD4_PARAM" VARCHAR(100), + "PERIOD4_DATE" BIGINT, + "PERIOD5_MODE" VARCHAR(100), + "PERIOD5_PARAM" VARCHAR(100), + "PERIOD5_DATE" BIGINT +); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnEventsTest/in_progress_events_with_snapshots.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnEventsTest/in_progress_events_with_snapshots.sql new file mode 100644 index 00000000000..3b66dd23009 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnEventsTest/in_progress_events_with_snapshots.sql @@ -0,0 +1,48 @@ + +CREATE TABLE "EVENTS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "NAME" VARCHAR(400), + "ANALYSIS_UUID" VARCHAR(50), + "COMPONENT_UUID" VARCHAR(50), + "SNAPSHOT_ID" INTEGER, + "CATEGORY" VARCHAR(50), + "EVENT_DATE" BIGINT NOT NULL, + "CREATED_AT" BIGINT NOT NULL, + "DESCRIPTION" VARCHAR(4000), + "EVENT_DATA" VARCHAR(4000) +); + +CREATE TABLE "SNAPSHOTS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "UUID" VARCHAR(50) NOT NULL, + "CREATED_AT" BIGINT, + "BUILD_DATE" BIGINT, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "PARENT_SNAPSHOT_ID" INTEGER, + "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U', + "PURGE_STATUS" INTEGER, + "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE, + "SCOPE" VARCHAR(3), + "QUALIFIER" VARCHAR(10), + "ROOT_SNAPSHOT_ID" INTEGER, + "VERSION" VARCHAR(500), + "PATH" VARCHAR(500), + "DEPTH" INTEGER, + "ROOT_COMPONENT_UUID" VARCHAR(50) NOT NULL, + "PERIOD1_MODE" VARCHAR(100), + "PERIOD1_PARAM" VARCHAR(100), + "PERIOD1_DATE" BIGINT, + "PERIOD2_MODE" VARCHAR(100), + "PERIOD2_PARAM" VARCHAR(100), + "PERIOD2_DATE" BIGINT, + "PERIOD3_MODE" VARCHAR(100), + "PERIOD3_PARAM" VARCHAR(100), + "PERIOD3_DATE" BIGINT, + "PERIOD4_MODE" VARCHAR(100), + "PERIOD4_PARAM" VARCHAR(100), + "PERIOD4_DATE" BIGINT, + "PERIOD5_MODE" VARCHAR(100), + "PERIOD5_PARAM" VARCHAR(100), + "PERIOD5_DATE" BIGINT +); + diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnMeasuresTest/old_measures.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnMeasuresTest/old_measures.sql new file mode 100644 index 00000000000..203419ad2bd --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateAnalysisUuidOnMeasuresTest/old_measures.sql @@ -0,0 +1,54 @@ +CREATE TABLE "SNAPSHOTS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "UUID" VARCHAR(50) NOT NULL, + "CREATED_AT" BIGINT, + "BUILD_DATE" BIGINT, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "PARENT_SNAPSHOT_ID" INTEGER, + "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U', + "PURGE_STATUS" INTEGER, + "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE, + "SCOPE" VARCHAR(3), + "QUALIFIER" VARCHAR(10), + "ROOT_SNAPSHOT_ID" INTEGER, + "VERSION" VARCHAR(500), + "PATH" VARCHAR(500), + "DEPTH" INTEGER, + "ROOT_COMPONENT_UUID" VARCHAR(50) NOT NULL, + "PERIOD1_MODE" VARCHAR(100), + "PERIOD1_PARAM" VARCHAR(100), + "PERIOD1_DATE" BIGINT, + "PERIOD2_MODE" VARCHAR(100), + "PERIOD2_PARAM" VARCHAR(100), + "PERIOD2_DATE" BIGINT, + "PERIOD3_MODE" VARCHAR(100), + "PERIOD3_PARAM" VARCHAR(100), + "PERIOD3_DATE" BIGINT, + "PERIOD4_MODE" VARCHAR(100), + "PERIOD4_PARAM" VARCHAR(100), + "PERIOD4_DATE" BIGINT, + "PERIOD5_MODE" VARCHAR(100), + "PERIOD5_PARAM" VARCHAR(100), + "PERIOD5_DATE" BIGINT +); + +CREATE TABLE "PROJECT_MEASURES" ( + "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "VALUE" DOUBLE, + "METRIC_ID" INTEGER NOT NULL, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "SNAPSHOT_ID" INTEGER, + // NULLABLE at that time + "ANALYSIS_UUID" VARCHAR(50), + "TEXT_VALUE" VARCHAR(4000), + "ALERT_STATUS" VARCHAR(5), + "ALERT_TEXT" VARCHAR(4000), + "DESCRIPTION" VARCHAR(4000), + "PERSON_ID" INTEGER, + "VARIATION_VALUE_1" DOUBLE, + "VARIATION_VALUE_2" DOUBLE, + "VARIATION_VALUE_3" DOUBLE, + "VARIATION_VALUE_4" DOUBLE, + "VARIATION_VALUE_5" DOUBLE, + "MEASURE_DATA" BINARY(167772150) + ); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndexTest/in_progress_measures_with_snapshots.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndexTest/in_progress_measures_with_snapshots.sql new file mode 100644 index 00000000000..526a759d76d --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndexTest/in_progress_measures_with_snapshots.sql @@ -0,0 +1,45 @@ +CREATE TABLE "DUPLICATIONS_INDEX" ( + "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "PROJECT_SNAPSHOT_ID" INTEGER NOT NULL, + "SNAPSHOT_ID" INTEGER NOT NULL, + "ANALYSIS_UUID" VARCHAR(50), + "COMPONENT_UUID" VARCHAR(50), + "HASH" VARCHAR(50) NOT NULL, + "INDEX_IN_FILE" INTEGER NOT NULL, + "START_LINE" INTEGER NOT NULL, + "END_LINE" INTEGER NOT NULL +); + +CREATE TABLE "SNAPSHOTS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "UUID" VARCHAR(50) NOT NULL, + "CREATED_AT" BIGINT, + "BUILD_DATE" BIGINT, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "PARENT_SNAPSHOT_ID" INTEGER, + "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U', + "PURGE_STATUS" INTEGER, + "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE, + "SCOPE" VARCHAR(3), + "QUALIFIER" VARCHAR(10), + "ROOT_SNAPSHOT_ID" INTEGER, + "VERSION" VARCHAR(500), + "PATH" VARCHAR(500), + "DEPTH" INTEGER, + "ROOT_COMPONENT_UUID" VARCHAR(50) NOT NULL, + "PERIOD1_MODE" VARCHAR(100), + "PERIOD1_PARAM" VARCHAR(100), + "PERIOD1_DATE" BIGINT, + "PERIOD2_MODE" VARCHAR(100), + "PERIOD2_PARAM" VARCHAR(100), + "PERIOD2_DATE" BIGINT, + "PERIOD3_MODE" VARCHAR(100), + "PERIOD3_PARAM" VARCHAR(100), + "PERIOD3_DATE" BIGINT, + "PERIOD4_MODE" VARCHAR(100), + "PERIOD4_PARAM" VARCHAR(100), + "PERIOD4_DATE" BIGINT, + "PERIOD5_MODE" VARCHAR(100), + "PERIOD5_PARAM" VARCHAR(100), + "PERIOD5_DATE" BIGINT +); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidColumnsOfSnapshotsTest/in_progress_snapshots_with_projects.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidColumnsOfSnapshotsTest/in_progress_snapshots_with_projects.sql new file mode 100644 index 00000000000..64128b7e4c2 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidColumnsOfSnapshotsTest/in_progress_snapshots_with_projects.sql @@ -0,0 +1,57 @@ +CREATE TABLE "SNAPSHOTS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "CREATED_AT" BIGINT, + "BUILD_DATE" BIGINT, + "PROJECT_ID" INTEGER NOT NULL, + "COMPONENT_UUID" VARCHAR(50), + "PARENT_SNAPSHOT_ID" INTEGER, + "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U', + "PURGE_STATUS" INTEGER, + "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE, + "SCOPE" VARCHAR(3), + "QUALIFIER" VARCHAR(10), + "ROOT_SNAPSHOT_ID" INTEGER, + "VERSION" VARCHAR(500), + "PATH" VARCHAR(500), + "DEPTH" INTEGER, + "ROOT_PROJECT_ID" INTEGER, + "ROOT_COMPONENT_UUID" VARCHAR(50), + "PERIOD1_MODE" VARCHAR(100), + "PERIOD1_PARAM" VARCHAR(100), + "PERIOD1_DATE" BIGINT, + "PERIOD2_MODE" VARCHAR(100), + "PERIOD2_PARAM" VARCHAR(100), + "PERIOD2_DATE" BIGINT, + "PERIOD3_MODE" VARCHAR(100), + "PERIOD3_PARAM" VARCHAR(100), + "PERIOD3_DATE" BIGINT, + "PERIOD4_MODE" VARCHAR(100), + "PERIOD4_PARAM" VARCHAR(100), + "PERIOD4_DATE" BIGINT, + "PERIOD5_MODE" VARCHAR(100), + "PERIOD5_PARAM" VARCHAR(100), + "PERIOD5_DATE" BIGINT +); + +CREATE TABLE "PROJECTS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "KEE" VARCHAR(400), + "ROOT_ID" INTEGER, + "UUID" VARCHAR(50), + "PROJECT_UUID" VARCHAR(50), + "MODULE_UUID" VARCHAR(50), + "MODULE_UUID_PATH" VARCHAR(4000), + "NAME" VARCHAR(2000), + "DESCRIPTION" VARCHAR(2000), + "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, + "SCOPE" VARCHAR(3), + "QUALIFIER" VARCHAR(10), + "DEPRECATED_KEE" VARCHAR(400), + "PATH" VARCHAR(2000), + "LANGUAGE" VARCHAR(20), + "COPY_RESOURCE_ID" INTEGER, + "LONG_NAME" VARCHAR(2000), + "PERSON_ID" INTEGER, + "CREATED_AT" TIMESTAMP, + "AUTHORIZATION_UPDATED_AT" BIGINT +); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidOfMeasuresTest/in_progress_measures_with_projects.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidOfMeasuresTest/in_progress_measures_with_projects.sql new file mode 100644 index 00000000000..94d9362daaa --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateComponentUuidOfMeasuresTest/in_progress_measures_with_projects.sql @@ -0,0 +1,65 @@ +CREATE TABLE "PROJECT_MEASURES" ( + "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "VALUE" DOUBLE, + "METRIC_ID" INTEGER NOT NULL, + "SNAPSHOT_ID" INTEGER, + "RULE_ID" INTEGER, + "RULES_CATEGORY_ID" INTEGER, + "TEXT_VALUE" VARCHAR(4000), + "TENDENCY" INTEGER, + "MEASURE_DATE" TIMESTAMP, + "PROJECT_ID" INTEGER, + "ALERT_STATUS" VARCHAR(5), + "ALERT_TEXT" VARCHAR(4000), + "URL" VARCHAR(2000), + "DESCRIPTION" VARCHAR(4000), + "RULE_PRIORITY" INTEGER, + "CHARACTERISTIC_ID" INTEGER, + "PERSON_ID" INTEGER, + "VARIATION_VALUE_1" DOUBLE, + "VARIATION_VALUE_2" DOUBLE, + "VARIATION_VALUE_3" DOUBLE, + "VARIATION_VALUE_4" DOUBLE, + "VARIATION_VALUE_5" DOUBLE, + "MEASURE_DATA" BINARY(167772150), + + // new column, introduced in migration 1214 + "COMPONENT_UUID" VARCHAR(50) +); + +CREATE INDEX "MEASURES_SID_METRIC" ON "PROJECT_MEASURES" ("SNAPSHOT_ID", "METRIC_ID"); + +CREATE INDEX "MEASURES_PERSON" ON "PROJECT_MEASURES" ("PERSON_ID"); + +CREATE TABLE "SNAPSHOTS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "CREATED_AT" BIGINT, + "BUILD_DATE" BIGINT, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "PARENT_SNAPSHOT_ID" INTEGER, + "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U', + "PURGE_STATUS" INTEGER, + "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE, + "SCOPE" VARCHAR(3), + "QUALIFIER" VARCHAR(10), + "ROOT_SNAPSHOT_ID" INTEGER, + "VERSION" VARCHAR(500), + "PATH" VARCHAR(500), + "DEPTH" INTEGER, + "ROOT_COMPONENT_UUID" VARCHAR(50) NOT NULL, + "PERIOD1_MODE" VARCHAR(100), + "PERIOD1_PARAM" VARCHAR(100), + "PERIOD1_DATE" BIGINT, + "PERIOD2_MODE" VARCHAR(100), + "PERIOD2_PARAM" VARCHAR(100), + "PERIOD2_DATE" BIGINT, + "PERIOD3_MODE" VARCHAR(100), + "PERIOD3_PARAM" VARCHAR(100), + "PERIOD3_DATE" BIGINT, + "PERIOD4_MODE" VARCHAR(100), + "PERIOD4_PARAM" VARCHAR(100), + "PERIOD4_DATE" BIGINT, + "PERIOD5_MODE" VARCHAR(100), + "PERIOD5_PARAM" VARCHAR(100), + "PERIOD5_DATE" BIGINT +); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateLastUsedColumnOfRulesProfilesTest/rules_profiles.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateLastUsedColumnOfRulesProfilesTest/rules_profiles.sql new file mode 100644 index 00000000000..8f6183f65fe --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateLastUsedColumnOfRulesProfilesTest/rules_profiles.sql @@ -0,0 +1,84 @@ +CREATE TABLE "RULES_PROFILES" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "NAME" VARCHAR(100) NOT NULL, + "LANGUAGE" VARCHAR(20), + "KEE" VARCHAR(255) NOT NULL, + "PARENT_KEE" VARCHAR(255), + "RULES_UPDATED_AT" VARCHAR(100), + "IS_DEFAULT" BOOLEAN NOT NULL DEFAULT FALSE, + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP, + "LAST_USED" BIGINT +); + +CREATE TABLE "PROJECT_MEASURES" ( + "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "VALUE" DOUBLE, + "METRIC_ID" INTEGER NOT NULL, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "SNAPSHOT_ID" INTEGER, + "TEXT_VALUE" VARCHAR(4000), + "ALERT_STATUS" VARCHAR(5), + "ALERT_TEXT" VARCHAR(4000), + "DESCRIPTION" VARCHAR(4000), + "PERSON_ID" INTEGER, + "VARIATION_VALUE_1" DOUBLE, + "VARIATION_VALUE_2" DOUBLE, + "VARIATION_VALUE_3" DOUBLE, + "VARIATION_VALUE_4" DOUBLE, + "VARIATION_VALUE_5" DOUBLE, + "MEASURE_DATA" BINARY(167772150) +); + +CREATE TABLE "SNAPSHOTS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "UUID" VARCHAR(50) NOT NULL, + "CREATED_AT" BIGINT, + "BUILD_DATE" BIGINT, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "PARENT_SNAPSHOT_ID" INTEGER, + "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U', + "PURGE_STATUS" INTEGER, + "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE, + "SCOPE" VARCHAR(3), + "QUALIFIER" VARCHAR(10), + "ROOT_SNAPSHOT_ID" INTEGER, + "VERSION" VARCHAR(500), + "PATH" VARCHAR(500), + "DEPTH" INTEGER, + "ROOT_COMPONENT_UUID" VARCHAR(50) NOT NULL, + "PERIOD1_MODE" VARCHAR(100), + "PERIOD1_PARAM" VARCHAR(100), + "PERIOD1_DATE" BIGINT, + "PERIOD2_MODE" VARCHAR(100), + "PERIOD2_PARAM" VARCHAR(100), + "PERIOD2_DATE" BIGINT, + "PERIOD3_MODE" VARCHAR(100), + "PERIOD3_PARAM" VARCHAR(100), + "PERIOD3_DATE" BIGINT, + "PERIOD4_MODE" VARCHAR(100), + "PERIOD4_PARAM" VARCHAR(100), + "PERIOD4_DATE" BIGINT, + "PERIOD5_MODE" VARCHAR(100), + "PERIOD5_PARAM" VARCHAR(100), + "PERIOD5_DATE" BIGINT +); + +CREATE TABLE "METRICS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "NAME" VARCHAR(64) NOT NULL, + "DESCRIPTION" VARCHAR(255), + "DIRECTION" INTEGER NOT NULL DEFAULT 0, + "DOMAIN" VARCHAR(64), + "SHORT_NAME" VARCHAR(64), + "QUALITATIVE" BOOLEAN NOT NULL DEFAULT FALSE, + "VAL_TYPE" VARCHAR(8), + "USER_MANAGED" BOOLEAN DEFAULT FALSE, + "ENABLED" BOOLEAN DEFAULT TRUE, + "WORST_VALUE" DOUBLE, + "BEST_VALUE" DOUBLE, + "OPTIMIZED_BEST_VALUE" BOOLEAN, + "HIDDEN" BOOLEAN, + "DELETE_HISTORICAL_DATA" BOOLEAN, + "DECIMAL_SCALE" INTEGER +); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateProfileKeyOfActivitiesTest/activities.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateProfileKeyOfActivitiesTest/activities.sql new file mode 100644 index 00000000000..fead19a9ef2 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateProfileKeyOfActivitiesTest/activities.sql @@ -0,0 +1,11 @@ +CREATE TABLE "ACTIVITIES" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "LOG_KEY" VARCHAR(250), + "PROFILE_KEY" VARCHAR(255), + "CREATED_AT" TIMESTAMP, + "USER_LOGIN" VARCHAR(255), + "LOG_TYPE" VARCHAR(250), + "LOG_ACTION" VARCHAR(250), + "LOG_MESSAGE" VARCHAR(250), + "DATA_FIELD" CLOB(2147483647) +); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateUserUpdatedAtOfRulesProfilesTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateUserUpdatedAtOfRulesProfilesTest/schema.sql new file mode 100644 index 00000000000..fa7acc48f55 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateUserUpdatedAtOfRulesProfilesTest/schema.sql @@ -0,0 +1,25 @@ +CREATE TABLE "ACTIVITIES" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "LOG_KEY" VARCHAR(250), + "PROFILE_KEY" VARCHAR(255) NOT NULL, + "CREATED_AT" TIMESTAMP, + "USER_LOGIN" VARCHAR(255), + "LOG_TYPE" VARCHAR(250), + "LOG_ACTION" VARCHAR(250), + "LOG_MESSAGE" VARCHAR(250), + "DATA_FIELD" CLOB(2147483647) +); + +CREATE TABLE "RULES_PROFILES" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "NAME" VARCHAR(100) NOT NULL, + "LANGUAGE" VARCHAR(20), + "KEE" VARCHAR(255) NOT NULL, + "PARENT_KEE" VARCHAR(255), + "RULES_UPDATED_AT" VARCHAR(100), + "IS_DEFAULT" BOOLEAN NOT NULL DEFAULT FALSE, + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP, + "LAST_USED" BIGINT, + "USER_UPDATED_AT" BIGINT +); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnOnSnapshotsTest/in_progress_snapshots.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnOnSnapshotsTest/in_progress_snapshots.sql new file mode 100644 index 00000000000..e87bc84183e --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnOnSnapshotsTest/in_progress_snapshots.sql @@ -0,0 +1,34 @@ +CREATE TABLE "SNAPSHOTS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + // NULLABLE + "UUID" VARCHAR(50), + "CREATED_AT" BIGINT, + "BUILD_DATE" BIGINT, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "PARENT_SNAPSHOT_ID" INTEGER, + "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U', + "PURGE_STATUS" INTEGER, + "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE, + "SCOPE" VARCHAR(3), + "QUALIFIER" VARCHAR(10), + "ROOT_SNAPSHOT_ID" INTEGER, + "VERSION" VARCHAR(500), + "PATH" VARCHAR(500), + "DEPTH" INTEGER, + "ROOT_COMPONENT_UUID" VARCHAR(50) NOT NULL, + "PERIOD1_MODE" VARCHAR(100), + "PERIOD1_PARAM" VARCHAR(100), + "PERIOD1_DATE" BIGINT, + "PERIOD2_MODE" VARCHAR(100), + "PERIOD2_PARAM" VARCHAR(100), + "PERIOD2_DATE" BIGINT, + "PERIOD3_MODE" VARCHAR(100), + "PERIOD3_PARAM" VARCHAR(100), + "PERIOD3_DATE" BIGINT, + "PERIOD4_MODE" VARCHAR(100), + "PERIOD4_PARAM" VARCHAR(100), + "PERIOD4_DATE" BIGINT, + "PERIOD5_MODE" VARCHAR(100), + "PERIOD5_PARAM" VARCHAR(100), + "PERIOD5_DATE" BIGINT +); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnsOfProjectsTest/in_progress_projects.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnsOfProjectsTest/in_progress_projects.sql new file mode 100644 index 00000000000..5ea7d165ad3 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnsOfProjectsTest/in_progress_projects.sql @@ -0,0 +1,25 @@ +CREATE TABLE "PROJECTS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "KEE" VARCHAR(400), + "ROOT_ID" INTEGER, + "UUID" VARCHAR(50), + "PROJECT_UUID" VARCHAR(50), + "MODULE_UUID" VARCHAR(50), + "MODULE_UUID_PATH" VARCHAR(4000), + "NAME" VARCHAR(2000), + "DESCRIPTION" VARCHAR(2000), + "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, + "SCOPE" VARCHAR(3), + "QUALIFIER" VARCHAR(10), + "DEPRECATED_KEE" VARCHAR(400), + "PATH" VARCHAR(2000), + "LANGUAGE" VARCHAR(20), + "COPY_RESOURCE_ID" INTEGER, + "LONG_NAME" VARCHAR(2000), + "PERSON_ID" INTEGER, + "CREATED_AT" TIMESTAMP, + "AUTHORIZATION_UPDATED_AT" BIGINT, + "ROOT_UUID" VARCHAR(50), + "COPY_COMPONENT_UUID" VARCHAR(50), + "DEVELOPER_UUID" VARCHAR(50) +); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnsOfResourceIndexTest/in_progress_resourceindex_with_projects.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnsOfResourceIndexTest/in_progress_resourceindex_with_projects.sql new file mode 100644 index 00000000000..2551ca942d0 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateUuidColumnsOfResourceIndexTest/in_progress_resourceindex_with_projects.sql @@ -0,0 +1,34 @@ +CREATE TABLE "RESOURCE_INDEX" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "KEE" VARCHAR(400) NOT NULL, + "POSITION" INTEGER NOT NULL, + "NAME_SIZE" INTEGER NOT NULL, + "RESOURCE_ID" INTEGER NOT NULL, + "ROOT_PROJECT_ID" INTEGER NOT NULL, + "QUALIFIER" VARCHAR(10) NOT NULL, + "COMPONENT_UUID" VARCHAR(50), + "ROOT_COMPONENT_UUID" VARCHAR(50) +); + +CREATE TABLE "PROJECTS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "KEE" VARCHAR(400), + "ROOT_ID" INTEGER, + "UUID" VARCHAR(50), + "PROJECT_UUID" VARCHAR(50), + "MODULE_UUID" VARCHAR(50), + "MODULE_UUID_PATH" VARCHAR(4000), + "NAME" VARCHAR(2000), + "DESCRIPTION" VARCHAR(2000), + "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, + "SCOPE" VARCHAR(3), + "QUALIFIER" VARCHAR(10), + "DEPRECATED_KEE" VARCHAR(400), + "PATH" VARCHAR(2000), + "LANGUAGE" VARCHAR(20), + "COPY_RESOURCE_ID" INTEGER, + "LONG_NAME" VARCHAR(2000), + "PERSON_ID" INTEGER, + "CREATED_AT" TIMESTAMP, + "AUTHORIZATION_UPDATED_AT" BIGINT +); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateUuidPathColumnOnProjectsTest/in_progress_projects_and_snapshots.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateUuidPathColumnOnProjectsTest/in_progress_projects_and_snapshots.sql new file mode 100644 index 00000000000..92f64e965a6 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/PopulateUuidPathColumnOnProjectsTest/in_progress_projects_and_snapshots.sql @@ -0,0 +1,58 @@ +CREATE TABLE "PROJECTS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "KEE" VARCHAR(400), + "UUID" VARCHAR(50) NOT NULL, + // NULLABLE at the time + "UUID_PATH" VARCHAR(4000), + "ROOT_UUID" VARCHAR(50) NOT NULL, + "PROJECT_UUID" VARCHAR(50), + "MODULE_UUID" VARCHAR(50), + "MODULE_UUID_PATH" VARCHAR(4000), + "NAME" VARCHAR(2000), + "DESCRIPTION" VARCHAR(2000), + "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, + "SCOPE" VARCHAR(3), + "QUALIFIER" VARCHAR(10), + "DEPRECATED_KEE" VARCHAR(400), + "PATH" VARCHAR(2000), + "LANGUAGE" VARCHAR(20), + "COPY_COMPONENT_UUID" VARCHAR(50), + "LONG_NAME" VARCHAR(2000), + "DEVELOPER_UUID" VARCHAR(50), + "CREATED_AT" TIMESTAMP, + "AUTHORIZATION_UPDATED_AT" BIGINT +); + +CREATE TABLE "SNAPSHOTS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "UUID" VARCHAR(50) NOT NULL, + "CREATED_AT" BIGINT, + "BUILD_DATE" BIGINT, + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "PARENT_SNAPSHOT_ID" INTEGER, + "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U', + "PURGE_STATUS" INTEGER, + "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE, + "SCOPE" VARCHAR(3), + "QUALIFIER" VARCHAR(10), + "ROOT_SNAPSHOT_ID" INTEGER, + "VERSION" VARCHAR(500), + "PATH" VARCHAR(500), + "DEPTH" INTEGER, + "ROOT_COMPONENT_UUID" VARCHAR(50) NOT NULL, + "PERIOD1_MODE" VARCHAR(100), + "PERIOD1_PARAM" VARCHAR(100), + "PERIOD1_DATE" BIGINT, + "PERIOD2_MODE" VARCHAR(100), + "PERIOD2_PARAM" VARCHAR(100), + "PERIOD2_DATE" BIGINT, + "PERIOD3_MODE" VARCHAR(100), + "PERIOD3_PARAM" VARCHAR(100), + "PERIOD3_DATE" BIGINT, + "PERIOD4_MODE" VARCHAR(100), + "PERIOD4_PARAM" VARCHAR(100), + "PERIOD4_DATE" BIGINT, + "PERIOD5_MODE" VARCHAR(100), + "PERIOD5_PARAM" VARCHAR(100), + "PERIOD5_DATE" BIGINT +); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/RemoveUsersPasswordWhenNotLocalTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/RemoveUsersPasswordWhenNotLocalTest/schema.sql new file mode 100644 index 00000000000..cae775f31cb --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v60/RemoveUsersPasswordWhenNotLocalTest/schema.sql @@ -0,0 +1,15 @@ +CREATE TABLE "USERS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "LOGIN" VARCHAR(255), + "NAME" VARCHAR(200), + "EMAIL" VARCHAR(100), + "CRYPTED_PASSWORD" VARCHAR(40), + "SALT" VARCHAR(40), + "ACTIVE" BOOLEAN DEFAULT TRUE, + "SCM_ACCOUNTS" VARCHAR(4000), + "EXTERNAL_IDENTITY" VARCHAR(255), + "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100), + "USER_LOCAL" BOOLEAN, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT +); diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1200_create_perm_templates_characteristics.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1200_create_perm_templates_characteristics.rb deleted file mode 100644 index 4ea89cdb1f3..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1200_create_perm_templates_characteristics.rb +++ /dev/null @@ -1,30 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# -# -# SonarQube 6.0 -# -class CreatePermTemplatesCharacteristics < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.CreatePermTemplatesCharacteristics') - end - -end - diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1201_add_columns_with_uuids_to_resource_index.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1201_add_columns_with_uuids_to_resource_index.rb deleted file mode 100644 index 25922c96f68..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1201_add_columns_with_uuids_to_resource_index.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class AddColumnsWithUuidsToResourceIndex < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.AddUuidColumnsToResourceIndex') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1202_populate_uuid_columns_of_resource_index.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1202_populate_uuid_columns_of_resource_index.rb deleted file mode 100644 index f08b4a84735..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1202_populate_uuid_columns_of_resource_index.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class PopulateUuidColumnsOfResourceIndex < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.PopulateUuidColumnsOfResourceIndex') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1203_clean_orphan_rows_in_resource_index.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1203_clean_orphan_rows_in_resource_index.rb deleted file mode 100644 index 00fb9fabc03..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1203_clean_orphan_rows_in_resource_index.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class CleanOrphanRowsInResourceIndex < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.CleanOrphanRowsInResourceIndex') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1204_make_uuid_columns_not_null_on_resource_index.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1204_make_uuid_columns_not_null_on_resource_index.rb deleted file mode 100644 index 915966315b5..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1204_make_uuid_columns_not_null_on_resource_index.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class MakeUuidColumnsNotNullOnResourceIndex < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.MakeUuidColumnsNotNullOnResourceIndex') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1205_drop_resource_index_rid_from_resource_index.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1205_drop_resource_index_rid_from_resource_index.rb deleted file mode 100644 index b41df473bdb..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1205_drop_resource_index_rid_from_resource_index.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class DropResourceIndexRidFromResourceIndex < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.DropResourceIndexRidFromResourceIndex') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1206_drop_id_columns_from_resource_index.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1206_drop_id_columns_from_resource_index.rb deleted file mode 100644 index 515e7f40b33..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1206_drop_id_columns_from_resource_index.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class DropIdColumnsFromResourceIndex < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.DropIdColumnsFromResourceIndex') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1207_drop_unused_measures_columns.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1207_drop_unused_measures_columns.rb deleted file mode 100644 index c91c48025b3..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1207_drop_unused_measures_columns.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class DropUnusedMeasuresColumns < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.DropUnusedMeasuresColumns') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1208_add_component_uuid_columns_to_snapshots.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1208_add_component_uuid_columns_to_snapshots.rb deleted file mode 100644 index c9f51f0a2d4..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1208_add_component_uuid_columns_to_snapshots.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class AddComponentUuidColumnsToSnapshots < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.AddComponentUuidColumnsToSnapshots') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1209_populate_component_uuid_columns_of_snapshots.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1209_populate_component_uuid_columns_of_snapshots.rb deleted file mode 100644 index 8ef0bf521b3..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1209_populate_component_uuid_columns_of_snapshots.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class PopulateComponentUuidColumnsOfSnapshots < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.PopulateComponentUuidColumnsOfSnapshots') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1210_create_temporary_indices_for_1211.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1210_create_temporary_indices_for_1211.rb deleted file mode 100644 index adaa6baf1c8..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1210_create_temporary_indices_for_1211.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class CreateTemporaryIndicesFor1211 < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.CreateTemporaryIndicesFor1211') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1211_clean_orphan_rows_in_snapshots.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1211_clean_orphan_rows_in_snapshots.rb deleted file mode 100644 index 626b219b765..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1211_clean_orphan_rows_in_snapshots.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class CleanOrphanRowsInSnapshots < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.CleanOrphanRowsInSnapshots') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1212_drop_temporary_indices_of_1210.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1212_drop_temporary_indices_of_1210.rb deleted file mode 100644 index c5193f927b7..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1212_drop_temporary_indices_of_1210.rb +++ /dev/null @@ -1,30 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class DropTemporaryIndicesOf1210 < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.DropTemporaryIndicesOf1210') - end - -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1213_make_component_uuid_columns_not_null_on_snapshots.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1213_make_component_uuid_columns_not_null_on_snapshots.rb deleted file mode 100644 index cec3b032a2b..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1213_make_component_uuid_columns_not_null_on_snapshots.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class MakeComponentUuidColumnsNotNullOnSnapshots < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.MakeComponentUuidColumnsNotNullOnSnapshots') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1214_drop_snapshot_project_id_from_snapshots.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1214_drop_snapshot_project_id_from_snapshots.rb deleted file mode 100644 index bb9ddc23aab..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1214_drop_snapshot_project_id_from_snapshots.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class DropSnapshotProjectIdFromSnapshots < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.DropSnapshotProjectIdFromSnapshots') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1215_drop_id_columns_from_snapshots.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1215_drop_id_columns_from_snapshots.rb deleted file mode 100644 index 15234f1c8fa..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1215_drop_id_columns_from_snapshots.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class DropIdColumnsFromSnapshots < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.DropIdColumnsFromSnapshots') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1216_add_component_uuid_to_measures.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1216_add_component_uuid_to_measures.rb deleted file mode 100644 index f2ead8b94e5..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1216_add_component_uuid_to_measures.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class AddComponentUuidToMeasures < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.AddComponentUuidColumnToMeasures') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1217_populate_component_uuid_of_measures.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1217_populate_component_uuid_of_measures.rb deleted file mode 100644 index bb88f5f5b3b..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1217_populate_component_uuid_of_measures.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class PopulateComponentUuidOfMeasures < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.PopulateComponentUuidOfMeasures') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1218_delete_orphan_measures_without_component.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1218_delete_orphan_measures_without_component.rb deleted file mode 100644 index 01384d8d919..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1218_delete_orphan_measures_without_component.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class DeleteOrphanMeasuresWithoutComponent < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.DeleteOrphanMeasuresWithoutComponent') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1219_make_component_uuid_not_null_on_measures.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1219_make_component_uuid_not_null_on_measures.rb deleted file mode 100644 index e864972d2d9..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1219_make_component_uuid_not_null_on_measures.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class MakeComponentUuidNotNullOnMeasures < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.MakeComponentUuidNotNullOnMeasures') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1220_drop_project_id_column_from_measures.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1220_drop_project_id_column_from_measures.rb deleted file mode 100644 index 640eea8dc96..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1220_drop_project_id_column_from_measures.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class DropProjectIdColumnFromMeasures < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.DropProjectIdColumnFromMeasures') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1221_add_index_on_component_uuid_of_measures.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1221_add_index_on_component_uuid_of_measures.rb deleted file mode 100644 index 17273925c3e..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1221_add_index_on_component_uuid_of_measures.rb +++ /dev/null @@ -1,30 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class AddIndexOnComponentUuidOfMeasures < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.AddIndexOnComponentUuidOfMeasures') - end - -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1222_drop_remember_me_columns_from_users.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1222_drop_remember_me_columns_from_users.rb deleted file mode 100644 index 37c7f722f04..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1222_drop_remember_me_columns_from_users.rb +++ /dev/null @@ -1,30 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# SONAR-7739 -# -class DropRememberMeColumnsFromUsers < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.DropRememberMeColumnsFromUsers') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1223_clean_some_data_in_table_projects.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1223_clean_some_data_in_table_projects.rb deleted file mode 100644 index 42f8fdba4ba..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1223_clean_some_data_in_table_projects.rb +++ /dev/null @@ -1,30 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class CleanSomeDataInTableProjects < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.FixProjectUuidOfDeveloperProjects') - execute_java_migration('org.sonar.db.version.v60.CleanUsurperRootComponents') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1224_add_uuid_columns_to_projects.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1224_add_uuid_columns_to_projects.rb deleted file mode 100644 index fa21a648e21..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1224_add_uuid_columns_to_projects.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class AddUuidColumnsToProjects < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.AddUuidColumnsToProjects') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1225_populate_uuid_columns_of_projects.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1225_populate_uuid_columns_of_projects.rb deleted file mode 100644 index 0404d6d4b0c..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1225_populate_uuid_columns_of_projects.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class PopulateUuidColumnsOfProjects < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.PopulateUuidColumnsOfProjects') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1226_clean_orphan_rows_in_projects.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1226_clean_orphan_rows_in_projects.rb deleted file mode 100644 index 94a1a403d0f..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1226_clean_orphan_rows_in_projects.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class CleanOrphanRowsInProjects < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.CleanOrphanRowsInProjects') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1227_drop_index_projects_uuid_from_projects.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1227_drop_index_projects_uuid_from_projects.rb deleted file mode 100644 index ab2419fb634..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1227_drop_index_projects_uuid_from_projects.rb +++ /dev/null @@ -1,30 +0,0 @@ - -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class DropIndexProjectsUuidFromProjects < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.DropIndexProjectsUuidFromProjects') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1228_make_uuid_columns_not_null_on_projects.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1228_make_uuid_columns_not_null_on_projects.rb deleted file mode 100644 index 684ca3d7a15..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1228_make_uuid_columns_not_null_on_projects.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class MakeUuidColumnsNotNullOnProjects < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.MakeUuidColumnsNotNullOnProjects') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1229_recreate_index_projects_uuid_from_projects.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1229_recreate_index_projects_uuid_from_projects.rb deleted file mode 100644 index 52deb046223..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1229_recreate_index_projects_uuid_from_projects.rb +++ /dev/null @@ -1,30 +0,0 @@ - -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class RecreateIndexProjectsUuidFromProjects < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.RecreateIndexProjectsUuidFromProjects') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1230_drop_index_projects_root_id_from_projects.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1230_drop_index_projects_root_id_from_projects.rb deleted file mode 100644 index 1e0b606af0b..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1230_drop_index_projects_root_id_from_projects.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class DropIndexProjectsRootIdFromProjects < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.DropIndexProjectsRootIdFromProjects') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1231_drop_id_columns_from_projects.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1231_drop_id_columns_from_projects.rb deleted file mode 100644 index 8d476bfc59d..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1231_drop_id_columns_from_projects.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class DropIdColumnsFromProjects < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.DropIdColumnsFromProjects') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1232_add_uuid_column_to_snapshots.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1232_add_uuid_column_to_snapshots.rb deleted file mode 100644 index 5c9d0061779..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1232_add_uuid_column_to_snapshots.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class AddUuidColumnToSnapshots < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.AddUuidColumnToSnapshots') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1233_populate_uuid_column_on_snapshots.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1233_populate_uuid_column_on_snapshots.rb deleted file mode 100644 index fa2f8203768..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1233_populate_uuid_column_on_snapshots.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class PopulateUuidColumnOnSnapshots < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.PopulateUuidColumnOnSnapshots') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1234_make_uuid_column_not_null_on_snapshots.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1234_make_uuid_column_not_null_on_snapshots.rb deleted file mode 100644 index bb2985cbfb5..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1234_make_uuid_column_not_null_on_snapshots.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class MakeUuidColumnNotNullOnSnapshots < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.MakeUuidColumnNotNullOnSnapshots') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1235_add_unique_index_on_uuid_of_snapshots.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1235_add_unique_index_on_uuid_of_snapshots.rb deleted file mode 100644 index 498397fcd6d..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1235_add_unique_index_on_uuid_of_snapshots.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class AddUniqueIndexOnUuidOfSnapshots < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.AddUniqueIndexOnUuidOfSnapshots') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1236_add_analysis_uuid_column_to_ce_activity.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1236_add_analysis_uuid_column_to_ce_activity.rb deleted file mode 100644 index 9dcd6c4081e..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1236_add_analysis_uuid_column_to_ce_activity.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class AddAnalysisUuidColumnToCeActivity < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.AddAnalysisUuidColumnToCeActivity') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1237_populate_analysis_uuid_column_on_ce_activity.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1237_populate_analysis_uuid_column_on_ce_activity.rb deleted file mode 100644 index d076d2157fd..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1237_populate_analysis_uuid_column_on_ce_activity.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class PopulateAnalysisUuidColumnOnCeActivity < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.PopulateAnalysisUuidColumnOnCeActivity') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1238_drop_snapshot_id_column_from_ce_activity.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1238_drop_snapshot_id_column_from_ce_activity.rb deleted file mode 100644 index 3966832897a..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1238_drop_snapshot_id_column_from_ce_activity.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class DropSnapshotIdColumnFromCeActivity < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.DropSnapshotIdColumnFromCeActivity') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1239_add_component_uuid_and_analysis_uuid_to_duplications_index.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1239_add_component_uuid_and_analysis_uuid_to_duplications_index.rb deleted file mode 100644 index c7ecc23e1ad..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1239_add_component_uuid_and_analysis_uuid_to_duplications_index.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class AddComponentUuidAndAnalysisUuidToDuplicationsIndex < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndex') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1240_populate_component_uuid_and_analysis_uuid_of_duplications_index.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1240_populate_component_uuid_and_analysis_uuid_of_duplications_index.rb deleted file mode 100644 index 024aa7f5ca1..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1240_populate_component_uuid_and_analysis_uuid_of_duplications_index.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndex < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.PopulateComponentUuidAndAnalysisUuidOfDuplicationsIndex') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1241_delete_orphan_duplications_index_rows_without_component_or_analysis.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1241_delete_orphan_duplications_index_rows_without_component_or_analysis.rb deleted file mode 100644 index caa887bffe4..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1241_delete_orphan_duplications_index_rows_without_component_or_analysis.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class DeleteOrphanDuplicationsIndexRowsWithoutComponentOrAnalysis < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.DeleteOrphanDuplicationsIndexRowsWithoutComponentOrAnalysis') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1242_make_component_uuid_and_analysis_uuid_not_null_on_duplications_index.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1242_make_component_uuid_and_analysis_uuid_not_null_on_duplications_index.rb deleted file mode 100644 index 171d3750870..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1242_make_component_uuid_and_analysis_uuid_not_null_on_duplications_index.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndex < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndex') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1243_drop_index_duplications_index_sid_from_duplications_index.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1243_drop_index_duplications_index_sid_from_duplications_index.rb deleted file mode 100644 index 69f4ed2404f..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1243_drop_index_duplications_index_sid_from_duplications_index.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class DropIndexDuplicationsIndexSidFromDuplicationsIndex < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.DropIndexDuplicationsIndexSidFromDuplicationsIndex') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1244_drop_snapshot_id_columns_from_duplications_index.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1244_drop_snapshot_id_columns_from_duplications_index.rb deleted file mode 100644 index 46698d190fa..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1244_drop_snapshot_id_columns_from_duplications_index.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class DropSnapshotIdColumnsFromDuplicationsIndex < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.DropSnapshotIdColumnsFromDuplicationsIndex') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1246_add_last_used_column_to_rules_profiles.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1246_add_last_used_column_to_rules_profiles.rb deleted file mode 100644 index b8c14b28ae3..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1246_add_last_used_column_to_rules_profiles.rb +++ /dev/null @@ -1,28 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# -# -# SonarQube 6.0 -# SONAR-7789 -# -class AddLastUsedColumnToRulesProfiles < ActiveRecord::Migration - def self.up - execute_java_migration('org.sonar.db.version.v60.AddLastUsedColumnToRulesProfiles') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1247_populate_last_used_of_rules_profiles.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1247_populate_last_used_of_rules_profiles.rb deleted file mode 100644 index 349c81f71bf..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1247_populate_last_used_of_rules_profiles.rb +++ /dev/null @@ -1,28 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# -# -# SonarQube 6.0 -# SONAR-7789 -# -class PopulateLastUsedOfRulesProfiles < ActiveRecord::Migration - def self.up - execute_java_migration('org.sonar.db.version.v60.PopulateLastUsedColumnOfRulesProfiles') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1248_add_analysis_uuid_column_to_events.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1248_add_analysis_uuid_column_to_events.rb deleted file mode 100644 index 445992ec3bc..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1248_add_analysis_uuid_column_to_events.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class AddAnalysisUuidColumnToEvents < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.AddAnalysisUuidColumnToEvents') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1249_populate_analysis_uuid_on_events.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1249_populate_analysis_uuid_on_events.rb deleted file mode 100644 index 856221cdbf4..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1249_populate_analysis_uuid_on_events.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class PopulateAnalysisUuidOnEvents < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.PopulateAnalysisUuidOnEvents') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1250_clean_events_without_analysis_uuid.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1250_clean_events_without_analysis_uuid.rb deleted file mode 100644 index 7cfdee300cc..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1250_clean_events_without_analysis_uuid.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class CleanEventsWithoutAnalysisUuid < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.CleanEventsWithoutAnalysisUuid') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1251_clean_events_without_snapshot_id.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1251_clean_events_without_snapshot_id.rb deleted file mode 100644 index 4b56a0e76a0..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1251_clean_events_without_snapshot_id.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class CleanEventsWithoutSnapshotId < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.CleanEventsWithoutSnapshotId') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1252_make_analysis_uuid_not_null_on_events.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1252_make_analysis_uuid_not_null_on_events.rb deleted file mode 100644 index e9d5bf66abf..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1252_make_analysis_uuid_not_null_on_events.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class MakeAnalysisUuidNotNullOnEvents < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.MakeAnalysisUuidNotNullOnEvents') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1253_drop_index_events_snapshot_id_from_events.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1253_drop_index_events_snapshot_id_from_events.rb deleted file mode 100644 index 4c6206651ca..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1253_drop_index_events_snapshot_id_from_events.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class DropIndexEventsSnapshotIdFromEvents < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.DropIndexEventsSnapshotIdFromEvents') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1254_drop_snapshot_id_column_from_events.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1254_drop_snapshot_id_column_from_events.rb deleted file mode 100644 index 6f2438e1aad..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1254_drop_snapshot_id_column_from_events.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class DropSnapshotIdColumnFromEvents < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.DropSnapshotIdColumnFromEvents') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1256_add_uuid_path_column_to_projects.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1256_add_uuid_path_column_to_projects.rb deleted file mode 100644 index 6821051930b..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1256_add_uuid_path_column_to_projects.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class AddUuidPathColumnToProjects < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.AddUuidPathColumnToProjects') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1257_populate_uuid_path_column_on_projects.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1257_populate_uuid_path_column_on_projects.rb deleted file mode 100644 index 6458635ef1a..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1257_populate_uuid_path_column_on_projects.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class PopulateUuidPathColumnOnProjects < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.PopulateUuidPathColumnOnProjects') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1258_make_uuid_path_column_not_null_on_projects.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1258_make_uuid_path_column_not_null_on_projects.rb deleted file mode 100644 index a790c0f56f8..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1258_make_uuid_path_column_not_null_on_projects.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class MakeUuidPathColumnNotNullOnProjects < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.MakeUuidPathColumnNotNullOnProjects') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1259_remove_users_password_when_not_local.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1259_remove_users_password_when_not_local.rb deleted file mode 100644 index d692f77c0fe..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1259_remove_users_password_when_not_local.rb +++ /dev/null @@ -1,28 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# -# -# SonarQube 6.0 -# SONAR-7781 -# -class RemoveUsersPasswordWhenNotLocal < ActiveRecord::Migration - def self.up - execute_java_migration('org.sonar.db.version.v60.RemoveUsersPasswordWhenNotLocal') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1260_add_profile_key_to_activities.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1260_add_profile_key_to_activities.rb deleted file mode 100644 index aad2899f2a3..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1260_add_profile_key_to_activities.rb +++ /dev/null @@ -1,28 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# -# -# SonarQube 6.0 -# SONAR-7794 -# -class AddProfileKeyToActivities < ActiveRecord::Migration - def self.up - execute_java_migration('org.sonar.db.version.v60.AddProfileKeyToActivities') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1261_populate_profile_key_of_activities.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1261_populate_profile_key_of_activities.rb deleted file mode 100644 index cd19ec5afc5..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1261_populate_profile_key_of_activities.rb +++ /dev/null @@ -1,28 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# -# -# SonarQube 6.0 -# SONAR-7794 -# -class PopulateProfileKeyOfActivities < ActiveRecord::Migration - def self.up - execute_java_migration('org.sonar.db.version.v60.PopulateProfileKeyOfActivities') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1262_make_profile_key_not_null_on_activities.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1262_make_profile_key_not_null_on_activities.rb deleted file mode 100644 index 35dbd389dad..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1262_make_profile_key_not_null_on_activities.rb +++ /dev/null @@ -1,28 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# -# -# SonarQube 6.0 -# SONAR-7824 -# -class MakeProfileKeyNotNullOnActivities < ActiveRecord::Migration - def self.up - execute_java_migration('org.sonar.db.version.v60.MakeProfileKeyNotNullOnActivities') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1263_add_user_updated_at_to_rules_profiles.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1263_add_user_updated_at_to_rules_profiles.rb deleted file mode 100644 index 451b5847788..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1263_add_user_updated_at_to_rules_profiles.rb +++ /dev/null @@ -1,28 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# -# -# SonarQube 6.0 -# SONAR-7794 -# -class AddUserUpdatedAtToRulesProfiles < ActiveRecord::Migration - def self.up - execute_java_migration('org.sonar.db.version.v60.AddUserUpdatedAtToRulesProfiles') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1264_populate_user_updated_at_of_rules_profiles.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1264_populate_user_updated_at_of_rules_profiles.rb deleted file mode 100644 index 4f7951d6320..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1264_populate_user_updated_at_of_rules_profiles.rb +++ /dev/null @@ -1,28 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# -# -# SonarQube 6.0 -# SONAR-7794 -# -class PopulateUserUpdatedAtOfRulesProfiles < ActiveRecord::Migration - def self.up - execute_java_migration('org.sonar.db.version.v60.PopulateUserUpdatedAtOfRulesProfiles') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1265_add_analysis_uuid_column_to_measures.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1265_add_analysis_uuid_column_to_measures.rb deleted file mode 100644 index c936a3d25ae..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1265_add_analysis_uuid_column_to_measures.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class AddAnalysisUuidColumnToMeasures < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.AddAnalysisUuidColumnToMeasures') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1266_add_index_on_analysis_uuid_of_measures.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1266_add_index_on_analysis_uuid_of_measures.rb deleted file mode 100644 index afee48952a5..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1266_add_index_on_analysis_uuid_of_measures.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class AddIndexOnAnalysisUuidOfMeasures < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.AddIndexOnAnalysisUuidOfMeasures') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1267_populate_analysis_uuid_on_measures.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1267_populate_analysis_uuid_on_measures.rb deleted file mode 100644 index c0d7c4426b9..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1267_populate_analysis_uuid_on_measures.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class PopulateAnalysisUuidOnMeasures < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.PopulateAnalysisUuidOnMeasures') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1268_clean_measures_with_null_analysis_uuid.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1268_clean_measures_with_null_analysis_uuid.rb deleted file mode 100644 index 95ce502286b..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1268_clean_measures_with_null_analysis_uuid.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class CleanMeasuresWithNullAnalysisUuid < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.CleanMeasuresWithNullAnalysisUuid') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1269_temporarily_drop_index_of_analysis_uuid_on_measures.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1269_temporarily_drop_index_of_analysis_uuid_on_measures.rb deleted file mode 100644 index 1ecbdf3e392..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1269_temporarily_drop_index_of_analysis_uuid_on_measures.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class TemporarilyDropIndexOfAnalysisUuidOnMeasures < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.TemporarilyDropIndexOfAnalysisUuidOnMeasures') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1270_make_analysis_uuid_not_null_on_measures.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1270_make_analysis_uuid_not_null_on_measures.rb deleted file mode 100644 index 36ea14a0d0e..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1270_make_analysis_uuid_not_null_on_measures.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class MakeAnalysisUuidNotNullOnMeasures < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.MakeAnalysisUuidNotNullOnMeasures') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1271_add_again_index_on_analysis_uuid_of_measures.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1271_add_again_index_on_analysis_uuid_of_measures.rb deleted file mode 100644 index 71d768a2193..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1271_add_again_index_on_analysis_uuid_of_measures.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class AddAgainIndexOnAnalysisUuidOfMeasures < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.AddIndexOnAnalysisUuidOfMeasures') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1272_drop_trees_of_snapshots.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1272_drop_trees_of_snapshots.rb deleted file mode 100644 index 508eda2ced9..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1272_drop_trees_of_snapshots.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class DropTreesOfSnapshots < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.DropTreesOfSnapshots') - end -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1273_drop_indices_on_tree_columns_of_snapshots.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1273_drop_indices_on_tree_columns_of_snapshots.rb deleted file mode 100644 index 553e29a45e2..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1273_drop_indices_on_tree_columns_of_snapshots.rb +++ /dev/null @@ -1,30 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class DropIndicesOnTreeColumnsOfSnapshots < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.DropIndicesOnTreeColumnsOfSnapshots') - end - -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1274_drop_tree_columns_from_snapshots.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1274_drop_tree_columns_from_snapshots.rb deleted file mode 100644 index fc746c8505e..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1274_drop_tree_columns_from_snapshots.rb +++ /dev/null @@ -1,30 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class DropTreeColumnsFromSnapshots < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.DropTreeColumnsFromSnapshots') - end - -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1275_drop_index_on_snapshot_id_of_measures.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1275_drop_index_on_snapshot_id_of_measures.rb deleted file mode 100644 index 4f494796782..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1275_drop_index_on_snapshot_id_of_measures.rb +++ /dev/null @@ -1,30 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class DropIndexOnSnapshotIdOfMeasures < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.DropIndexOnSnapshotIdOfMeasures') - end - -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1276_drop_snapshot_id_column_from_measures.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1276_drop_snapshot_id_column_from_measures.rb deleted file mode 100644 index 50b9411d116..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1276_drop_snapshot_id_column_from_measures.rb +++ /dev/null @@ -1,30 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class DropSnapshotIdColumnFromMeasures < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.DropSnapshotIdColumnFromMeasures') - end - -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1277_add_b_columns_to_projects.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1277_add_b_columns_to_projects.rb deleted file mode 100644 index 57838ab3c51..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1277_add_b_columns_to_projects.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2016 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -# -# SonarQube 6.0 -# -class AddBColumnsToProjects < ActiveRecord::Migration - - def self.up - execute_java_migration('org.sonar.db.version.v60.AddBColumnsToProjects') - end -end |