class RemoveUselessIndexesOnGroupRoles < ActiveRecord::Migration
def self.up
- remove_index :group_roles, :name => 'group_roles_group'
- remove_index :group_roles, :name => 'group_roles_role'
+ execute_java_migration('org.sonar.db.version.v56.RemoveUselessIndexesOnGroupRoles')
end
end
class CreatePermTemplatesCharacteristics < ActiveRecord::Migration
def self.up
- create_table 'perm_tpl_characteristics' do |t|
- t.column :template_id, :integer, :null => false
- t.column :permission_key, :string, :null => false, :limit => 64
- t.column :with_project_creator, :boolean, :null => false, :default => false
- t.column :created_at, :big_integer, :null => false
- t.column :updated_at, :big_integer, :null => false
- end
-
- add_index 'perm_tpl_characteristics', ['template_id','permission_key'], :name => 'uniq_perm_tpl_charac', :unique => true
+ execute_java_migration('org.sonar.db.version.v60.CreatePermTemplatesCharacteristics')
end
end
def self.up
execute_java_migration('org.sonar.db.version.v60.MakeUuidColumnsNotNullOnResourceIndex')
-
- add_index :resource_index, :component_uuid, :name => 'resource_index_component'
end
end
class DropResourceIndexRidFromResourceIndex < ActiveRecord::Migration
def self.up
- begin
- remove_index :resource_index, :name => 'resource_index_rid'
- rescue
- #ignore
- end
+ execute_java_migration('org.sonar.db.version.v60.DropResourceIndexRidFromResourceIndex')
end
end
class CreateTemporaryIndicesFor1211 < ActiveRecord::Migration
def self.up
- add_index :ce_activity, :snapshot_id, :name => 'ce_activity_snapshot_id'
- add_index :duplications_index, :project_snapshot_id, :name => 'dup_index_psid'
+ execute_java_migration('org.sonar.db.version.v60.CreateTemporaryIndicesFor1211')
end
end
class DropTemporaryIndicesOf1210 < ActiveRecord::Migration
def self.up
- drop_index_quietly :ce_activity, 'ce_activity_snapshot_id'
- drop_index_quietly :duplications_index, 'dup_index_psid'
+ execute_java_migration('org.sonar.db.version.v60.DropTemporaryIndicesOf1210')
end
- private
-
- def self.drop_index_quietly(table, index)
- begin
- remove_index table, :name => index
- rescue
- #ignore
- end
- end
end
def self.up
execute_java_migration('org.sonar.db.version.v60.MakeComponentUuidColumnsNotNullOnSnapshots')
-
- add_index :snapshots, :component_uuid, :name => 'snapshot_component'
- add_index :snapshots, :root_component_uuid, :name => 'snapshot_root_component'
end
end
class DropSnapshotProjectIdFromSnapshots < ActiveRecord::Migration
def self.up
- begin
- remove_index :snapshots, :name => 'snapshot_project_id'
- rescue
- #ignore
- end
- begin
- remove_index :snapshots, :name => 'snapshots_root_project_id'
- rescue
- #ignore
- end
+ execute_java_migration('org.sonar.db.version.v60.DropSnapshotProjectIdFromSnapshots')
end
end
class AddIndexOnComponentUuidOfMeasures < ActiveRecord::Migration
def self.up
- add_index :project_measures, :component_uuid, :name => 'measures_component_uuid'
+ execute_java_migration('org.sonar.db.version.v60.AddIndexOnComponentUuidOfMeasures')
end
+
end
class DropIndexProjectsUuidFromProjects < ActiveRecord::Migration
def self.up
- begin
- remove_index :projects, :name => 'projects_uuid'
- rescue
- #ignore
- end
+ execute_java_migration('org.sonar.db.version.v60.DropIndexProjectsUuidFromProjects')
end
end
def self.up
execute_java_migration('org.sonar.db.version.v60.MakeUuidColumnsNotNullOnProjects')
-
- add_index :projects, :root_uuid, :name => 'projects_root_uuid'
end
end
class RecreateIndexProjectsUuidFromProjects < ActiveRecord::Migration
def self.up
- add_index :projects, :uuid, :name => 'projects_uuid'
+ execute_java_migration('org.sonar.db.version.v60.RecreateIndexProjectsUuidFromProjects')
end
end
class DropIndexProjectsRootIdFromProjects < ActiveRecord::Migration
def self.up
- begin
- remove_index :projects, :name => 'projects_root_id'
- rescue
- #ignore
- end
+ execute_java_migration('org.sonar.db.version.v60.DropIndexProjectsRootIdFromProjects')
end
end
class AddUniqueIndexOnUuidOfSnapshots < ActiveRecord::Migration
def self.up
- add_index :snapshots, :uuid, :name => 'analyses_uuid', :unique => true
+ execute_java_migration('org.sonar.db.version.v60.AddUniqueIndexOnUuidOfSnapshots')
end
end
def self.up
execute_java_migration('org.sonar.db.version.v60.MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndex')
-
- add_index :duplications_index, [:analysis_uuid, :component_uuid], :name => 'duplication_analysis_component'
end
end
class DropIndexDuplicationsIndexSidFromDuplicationsIndex < ActiveRecord::Migration
def self.up
- begin
- remove_index :duplications_index, :name => 'duplications_index_sid'
- rescue
- #ignore
- end
+ execute_java_migration('org.sonar.db.version.v60.DropIndexDuplicationsIndexSidFromDuplicationsIndex')
end
end
def self.up
execute_java_migration('org.sonar.db.version.v60.MakeAnalysisUuidNotNullOnEvents')
-
- add_index :events, :analysis_uuid, :name => 'events_analysis'
end
end
class DropIndexEventsSnapshotIdFromEvents < ActiveRecord::Migration
def self.up
- begin
- remove_index :events, :name => 'events_snapshot_id'
- rescue
- #ignore
- end
+ execute_java_migration('org.sonar.db.version.v60.DropIndexEventsSnapshotIdFromEvents')
end
end
class AddIndexOnAnalysisUuidOfMeasures < ActiveRecord::Migration
def self.up
- # this index must be present for the performance of next migration
- add_index :project_measures, [:analysis_uuid, :metric_id], :name => 'measures_analysis_metric'
+ execute_java_migration('org.sonar.db.version.v60.AddIndexOnAnalysisUuidOfMeasures')
end
end
class TemporarilyDropIndexOfAnalysisUuidOnMeasures < ActiveRecord::Migration
def self.up
- # the index must be dropped for the compatibility of migration 1270
- # with MSSQL
- remove_index :project_measures, :name => 'measures_analysis_metric'
+ execute_java_migration('org.sonar.db.version.v60.TemporarilyDropIndexOfAnalysisUuidOnMeasures')
end
end
class AddAgainIndexOnAnalysisUuidOfMeasures < ActiveRecord::Migration
def self.up
- add_index :project_measures, [:analysis_uuid, :metric_id], :name => 'measures_analysis_metric'
+ execute_java_migration('org.sonar.db.version.v60.AddIndexOnAnalysisUuidOfMeasures')
end
end
class DropIndicesOnTreeColumnsOfSnapshots < ActiveRecord::Migration
def self.up
- remove_index_quietly 'snapshots_qualifier'
- remove_index_quietly 'snapshots_root'
- remove_index_quietly 'snapshots_parent'
- remove_index_quietly 'snapshot_root_component'
+ execute_java_migration('org.sonar.db.version.v60.DropIndicesOnTreeColumnsOfSnapshots')
end
- private
- def self.remove_index_quietly(index_name)
- begin
- remove_index :snapshots, :name => index_name
- rescue
- #ignore
- end
- end
end
class DropIndexOnSnapshotIdOfMeasures < ActiveRecord::Migration
def self.up
- begin
- remove_index :project_measures, :name => 'measures_sid_metric'
- rescue
- #ignore
- end
+ execute_java_migration('org.sonar.db.version.v60.DropIndexOnSnapshotIdOfMeasures')
end
end
def self.up
execute_java_migration('org.sonar.db.version.v61.CreateTableProperties2')
- add_varchar_index :properties2, :prop_key, :name => 'properties2_key'
end
end
class DropTableProperties < ActiveRecord::Migration
def self.up
- drop_index_quietly :properties, :properties_key
- drop_table :properties
+ execute_java_migration('org.sonar.db.version.v61.DropTableProperties')
end
end
class DropTableActivities < ActiveRecord::Migration
def self.up
- drop_index_quietly 'activities', 'activities_log_key'
- drop_table 'activities'
+ execute_java_migration('org.sonar.db.version.v61.DropTableActivities')
end
end
def self.up
execute_java_migration('org.sonar.db.version.v62.CreateTableOrganizations')
- add_index :organizations, :kee, :name => 'organization_key'
end
end
class IncludeOrganizationUuidInUniqueIndexOfGroupRoles < ActiveRecord::Migration
def self.up
- drop_index_quietly :group_roles, :uniq_group_roles
-
- add_index 'group_roles', ['organization_uuid', 'group_id', 'resource_id', 'role'], :unique => true, :name => 'uniq_group_roles'
+ execute_java_migration('org.sonar.db.version.v62.IncludeOrganizationUuidInUniqueIndexOfGroupRoles')
end
end
def self.up
execute_java_migration('org.sonar.db.version.v63.MakeUuidNotNullOnEvents')
- add_index 'events', :uuid, :name => 'events_uuid', :unique => true
end
end
import org.sonar.db.version.v55.FeedRulesTypes;
import org.sonar.db.version.v56.FixLengthOfIssuesMessageOnOracle;
import org.sonar.db.version.v56.FixTypeOfRuleTypeOnMysql;
+import org.sonar.db.version.v56.RemoveUselessIndexesOnGroupRoles;
import org.sonar.db.version.v56.UpdateUsersExternalIdentityWhenEmpty;
import org.sonar.db.version.v60.AddAnalysisUuidColumnToCeActivity;
import org.sonar.db.version.v60.AddAnalysisUuidColumnToEvents;
import org.sonar.db.version.v60.AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndex;
import org.sonar.db.version.v60.AddComponentUuidColumnToMeasures;
import org.sonar.db.version.v60.AddComponentUuidColumnsToSnapshots;
+import org.sonar.db.version.v60.AddIndexOnAnalysisUuidOfMeasures;
+import org.sonar.db.version.v60.AddIndexOnComponentUuidOfMeasures;
import org.sonar.db.version.v60.AddLastUsedColumnToRulesProfiles;
import org.sonar.db.version.v60.AddProfileKeyToActivities;
+import org.sonar.db.version.v60.AddUniqueIndexOnUuidOfSnapshots;
import org.sonar.db.version.v60.AddUserUpdatedAtToRulesProfiles;
import org.sonar.db.version.v60.AddUuidColumnToSnapshots;
import org.sonar.db.version.v60.AddUuidColumnsToProjects;
import org.sonar.db.version.v60.CleanOrphanRowsInResourceIndex;
import org.sonar.db.version.v60.CleanOrphanRowsInSnapshots;
import org.sonar.db.version.v60.CleanUsurperRootComponents;
+import org.sonar.db.version.v60.CreatePermTemplatesCharacteristics;
+import org.sonar.db.version.v60.CreateTemporaryIndicesFor1211;
import org.sonar.db.version.v60.DeleteOrphanDuplicationsIndexRowsWithoutComponentOrAnalysis;
import org.sonar.db.version.v60.DeleteOrphanMeasuresWithoutComponent;
import org.sonar.db.version.v60.DropIdColumnsFromProjects;
import org.sonar.db.version.v60.DropIdColumnsFromResourceIndex;
import org.sonar.db.version.v60.DropIdColumnsFromSnapshots;
+import org.sonar.db.version.v60.DropIndexDuplicationsIndexSidFromDuplicationsIndex;
+import org.sonar.db.version.v60.DropIndexEventsSnapshotIdFromEvents;
+import org.sonar.db.version.v60.DropIndexOnSnapshotIdOfMeasures;
+import org.sonar.db.version.v60.DropIndexProjectsRootIdFromProjects;
+import org.sonar.db.version.v60.DropIndexProjectsUuidFromProjects;
+import org.sonar.db.version.v60.DropIndicesOnTreeColumnsOfSnapshots;
import org.sonar.db.version.v60.DropProjectIdColumnFromMeasures;
import org.sonar.db.version.v60.DropRememberMeColumnsFromUsers;
+import org.sonar.db.version.v60.DropResourceIndexRidFromResourceIndex;
import org.sonar.db.version.v60.DropSnapshotIdColumnFromCeActivity;
import org.sonar.db.version.v60.DropSnapshotIdColumnFromEvents;
import org.sonar.db.version.v60.DropSnapshotIdColumnFromMeasures;
import org.sonar.db.version.v60.DropSnapshotIdColumnsFromDuplicationsIndex;
+import org.sonar.db.version.v60.DropSnapshotProjectIdFromSnapshots;
+import org.sonar.db.version.v60.DropTemporaryIndicesOf1210;
import org.sonar.db.version.v60.DropTreeColumnsFromSnapshots;
import org.sonar.db.version.v60.DropTreesOfSnapshots;
import org.sonar.db.version.v60.DropUnusedMeasuresColumns;
import org.sonar.db.version.v60.PopulateUuidColumnsOfProjects;
import org.sonar.db.version.v60.PopulateUuidColumnsOfResourceIndex;
import org.sonar.db.version.v60.PopulateUuidPathColumnOnProjects;
+import org.sonar.db.version.v60.RecreateIndexProjectsUuidFromProjects;
import org.sonar.db.version.v60.RemoveUsersPasswordWhenNotLocal;
+import org.sonar.db.version.v60.TemporarilyDropIndexOfAnalysisUuidOnMeasures;
import org.sonar.db.version.v61.AddBUuidPathToProjects;
import org.sonar.db.version.v61.AddErrorColumnsToCeActivity;
import org.sonar.db.version.v61.CopyActivitiesToQprofileChanges;
import org.sonar.db.version.v61.DeleteProjectDashboards;
import org.sonar.db.version.v61.DeleteReportsFromCeQueue;
import org.sonar.db.version.v61.DropIsGlobalFromDashboards;
+import org.sonar.db.version.v61.DropTableActivities;
+import org.sonar.db.version.v61.DropTableProperties;
import org.sonar.db.version.v61.PopulateTableProperties2;
import org.sonar.db.version.v61.RemoveViewsDefinitionFromProperties;
import org.sonar.db.version.v61.ShrinkModuleUuidPathOfProjects;
import org.sonar.db.version.v62.DropIssueFiltersTables;
import org.sonar.db.version.v62.DropMeasureFiltersTables;
import org.sonar.db.version.v62.DropRelatedDashboardTables;
+import org.sonar.db.version.v62.IncludeOrganizationUuidInUniqueIndexOfGroupRoles;
import org.sonar.db.version.v62.MakeOrganizationUuidNotNullOnGroupRoles;
import org.sonar.db.version.v62.MakeOrganizationUuidNotNullOnGroups;
import org.sonar.db.version.v62.MakeOrganizationUuidNotNullOnPermissionTemplates;
DeleteManualRules.class,
// 5.6
+ RemoveUselessIndexesOnGroupRoles.class,
FixTypeOfRuleTypeOnMysql.class,
FixLengthOfIssuesMessageOnOracle.class,
UpdateUsersExternalIdentityWhenEmpty.class,
MakeProfileKeyNotNullOnActivities.class,
AddUserUpdatedAtToRulesProfiles.class,
PopulateUserUpdatedAtOfRulesProfiles.class,
+ CreateTemporaryIndicesFor1211.class,
+ AddIndexOnComponentUuidOfMeasures.class,
+ RecreateIndexProjectsUuidFromProjects.class,
+ AddUniqueIndexOnUuidOfSnapshots.class,
+ AddIndexOnAnalysisUuidOfMeasures.class,
// SNAPSHOTS.UUID
AddUuidColumnToSnapshots.class,
DropTreeColumnsFromSnapshots.class,
DropSnapshotIdColumnFromMeasures.class,
AddBColumnsToProjects.class,
+ CreatePermTemplatesCharacteristics.class,
+ DropTemporaryIndicesOf1210.class,
+ DropResourceIndexRidFromResourceIndex.class,
+ DropSnapshotProjectIdFromSnapshots.class,
+ DropIndexProjectsUuidFromProjects.class,
+ DropIndexProjectsRootIdFromProjects.class,
+ DropIndexDuplicationsIndexSidFromDuplicationsIndex.class,
+ DropIndexEventsSnapshotIdFromEvents.class,
+ TemporarilyDropIndexOfAnalysisUuidOnMeasures.class,
+ DropIndexOnSnapshotIdOfMeasures.class,
+ DropIndicesOnTreeColumnsOfSnapshots.class,
// 6.1
DeleteProjectDashboards.class,
CreateTableQprofileChanges.class,
CopyActivitiesToQprofileChanges.class,
CreateTableRuleRepositories.class,
+ DropTableActivities.class,
+ DropTableProperties.class,
// 6.2
CreateTableOrganizations.class,
DropMeasureFiltersTables.class,
DropIssueFiltersTables.class,
CreateTableWebhookDeliveries.class,
+ IncludeOrganizationUuidInUniqueIndexOfGroupRoles.class,
// 6.3
AddUuidToEvents.class,
--- /dev/null
+/*
+ * 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.db.version.v56;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.version.DdlChange;
+import org.sonar.db.version.DropIndexBuilder;
+
+/**
+ * SONAR-6613
+ */
+public class RemoveUselessIndexesOnGroupRoles extends DdlChange {
+
+ private static final String TABLE_NAME = "group_roles";
+
+ public RemoveUselessIndexesOnGroupRoles(Database db) {
+ super(db);
+ }
+
+ @Override
+ public void execute(Context context) throws SQLException {
+ context.execute(new DropIndexBuilder(getDialect())
+ .setTable(TABLE_NAME)
+ .setName("group_roles_group")
+ .build());
+
+ context.execute(new DropIndexBuilder(getDialect())
+ .setTable(TABLE_NAME)
+ .setName("group_roles_role")
+ .build());
+ }
+}
--- /dev/null
+/*
+ * 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.db.version.v60;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.version.CreateIndexBuilder;
+import org.sonar.db.version.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).build())
+ .addColumn(newIntegerColumnDefBuilder().setColumnName("metric_id").build())
+ .build());
+ }
+}
--- /dev/null
+/*
+ * 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.db.version.v60;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.version.CreateIndexBuilder;
+import org.sonar.db.version.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).build())
+ .build());
+ }
+
+}
--- /dev/null
+/*
+ * 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.db.version.v60;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.version.CreateIndexBuilder;
+import org.sonar.db.version.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).build())
+ .setUnique(true)
+ .build());
+ }
+}
+
+
+
--- /dev/null
+/*
+ * 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.db.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.DdlChange;
+import org.sonar.db.version.IntegerColumnDef;
+import org.sonar.db.version.VarcharColumnDef;
+
+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).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());
+ }
+}
--- /dev/null
+/*
+ * 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.db.version.v60;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.version.CreateIndexBuilder;
+import org.sonar.db.version.DdlChange;
+
+import static org.sonar.db.version.IntegerColumnDef.newIntegerColumnDefBuilder;
+
+public class CreateTemporaryIndicesFor1211 extends DdlChange {
+
+ public static final String INDEX_ON_CE_ACTIVITY = "ce_activity_snapshot_id";
+ public 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());
+ }
+}
--- /dev/null
+/*
+ * 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.db.version.v60;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.version.DdlChange;
+import org.sonar.db.version.DropIndexBuilder;
+
+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());
+ }
+}
--- /dev/null
+/*
+ * 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.db.version.v60;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.version.DdlChange;
+import org.sonar.db.version.DropIndexBuilder;
+
+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());
+ }
+}
+
--- /dev/null
+/*
+ * 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.db.version.v60;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.version.DdlChange;
+import org.sonar.db.version.DropIndexBuilder;
+
+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());
+ }
+}
--- /dev/null
+/*
+ * 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.db.version.v60;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.version.DdlChange;
+import org.sonar.db.version.DropIndexBuilder;
+
+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());
+ }
+}
--- /dev/null
+/*
+ * 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.db.version.v60;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.version.DdlChange;
+import org.sonar.db.version.DropIndexBuilder;
+
+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());
+ }
+}
--- /dev/null
+/*
+ * 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.db.version.v60;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.version.DdlChange;
+import org.sonar.db.version.DropIndexBuilder;
+
+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());
+ }
+}
--- /dev/null
+/*
+ * 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.db.version.v60;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.version.DdlChange;
+import org.sonar.db.version.DropIndexBuilder;
+
+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());
+ }
+
+}
--- /dev/null
+/*
+ * 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.db.version.v60;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.version.DdlChange;
+import org.sonar.db.version.DropIndexBuilder;
+
+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());
+ }
+}
--- /dev/null
+/*
+ * 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.db.version.v60;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.version.DdlChange;
+import org.sonar.db.version.DropIndexBuilder;
+
+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());
+ }
+
+}
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.DdlChange;
+import org.sonar.db.version.VarcharColumnDef;
import static org.sonar.db.version.VarcharColumnDef.UUID_VARCHAR_SIZE;
import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder;
@Override
public void execute(Context context) throws SQLException {
+ VarcharColumnDef analysisUuidColumn = newVarcharColumnDefBuilder().setColumnName("analysis_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).build();
context.execute(new AlterColumnsBuilder(getDatabase().getDialect(), TABLE_EVENTS)
- .updateColumn(newVarcharColumnDefBuilder().setColumnName("analysis_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).build())
+ .updateColumn(analysisUuidColumn)
+ .build());
+
+ context.execute(new CreateIndexBuilder(getDialect())
+ .setTable(TABLE_EVENTS)
+ .setName("events_analysis")
+ .addColumn(analysisUuidColumn)
.build());
}
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.DdlChange;
+import org.sonar.db.version.VarcharColumnDef;
import static org.sonar.db.version.VarcharColumnDef.UUID_VARCHAR_SIZE;
import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder;
@Override
public void execute(Context context) throws SQLException {
+ VarcharColumnDef analysisUuid = newVarcharColumnDefBuilder().setColumnName("analysis_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).build();
+ VarcharColumnDef componentUuid = newVarcharColumnDefBuilder().setColumnName("component_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).build();
context.execute(new AlterColumnsBuilder(getDatabase().getDialect(), TABLE_DUPLICATIONS_INDEX)
- .updateColumn(newVarcharColumnDefBuilder().setColumnName("component_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).build())
- .updateColumn(newVarcharColumnDefBuilder().setColumnName("analysis_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).build())
+ .updateColumn(componentUuid)
+ .updateColumn(analysisUuid)
+ .build());
+
+ context.execute(new CreateIndexBuilder(getDialect())
+ .setTable(TABLE_DUPLICATIONS_INDEX)
+ .setName("duplication_analysis_component")
+ .addColumn(analysisUuid)
+ .addColumn(componentUuid)
.build());
}
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.DdlChange;
+import org.sonar.db.version.VarcharColumnDef;
import static org.sonar.db.version.VarcharColumnDef.UUID_VARCHAR_SIZE;
import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder;
@Override
public void execute(Context context) throws SQLException {
+ VarcharColumnDef componentUuid = newVarcharColumnDefBuilder().setColumnName("component_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).build();
+ VarcharColumnDef rootComponentUuid = newVarcharColumnDefBuilder().setColumnName("root_component_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).build();
context.execute(new AlterColumnsBuilder(getDatabase().getDialect(), TABLE_SNAPSHOTS)
- .updateColumn(newVarcharColumnDefBuilder().setColumnName("component_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).build())
- .updateColumn(newVarcharColumnDefBuilder().setColumnName("root_component_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).build())
+ .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());
}
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.DdlChange;
+import org.sonar.db.version.VarcharColumnDef;
import static org.sonar.db.version.VarcharColumnDef.UUID_VARCHAR_SIZE;
import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder;
@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).build())
- .updateColumn(newVarcharColumnDefBuilder().setColumnName("root_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).build())
+ .updateColumn(rootUuid)
+ .build());
+
+ context.execute(new CreateIndexBuilder(getDialect())
+ .setTable(TABLE_PROJECTS)
+ .setName("projects_root_uuid")
+ .addColumn(rootUuid)
.build());
}
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.DdlChange;
+import org.sonar.db.version.VarcharColumnDef;
import static org.sonar.db.version.VarcharColumnDef.UUID_VARCHAR_SIZE;
import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder;
@Override
public void execute(Context context) throws SQLException {
+ VarcharColumnDef componentUuid = newVarcharColumnDefBuilder().setColumnName("component_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).build();
context.execute(new AlterColumnsBuilder(getDialect(), TABLE_RESOURCE_INDEX)
- .updateColumn(newVarcharColumnDefBuilder().setColumnName("component_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).build())
+ .updateColumn(componentUuid)
.updateColumn(newVarcharColumnDefBuilder().setColumnName("root_component_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).build())
.build());
+
+ context.execute(new CreateIndexBuilder(getDialect())
+ .setTable(TABLE_RESOURCE_INDEX)
+ .setName("resource_index_component")
+ .addColumn(componentUuid)
+ .build());
}
}
--- /dev/null
+/*
+ * 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.db.version.v60;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.version.CreateIndexBuilder;
+import org.sonar.db.version.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).build())
+ .build());
+ }
+}
--- /dev/null
+/*
+ * 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.db.version.v60;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.version.DdlChange;
+import org.sonar.db.version.DropIndexBuilder;
+
+/**
+ * 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());
+ }
+}
import java.sql.SQLException;
import java.util.List;
import org.sonar.db.Database;
+import org.sonar.db.version.CreateIndexBuilder;
import org.sonar.db.version.CreateTableBuilder;
import org.sonar.db.version.DdlChange;
+import org.sonar.db.version.VarcharColumnDef;
import static org.sonar.db.version.BigIntegerColumnDef.newBigIntegerColumnDefBuilder;
import static org.sonar.db.version.BooleanColumnDef.newBooleanColumnDefBuilder;
import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder;
public class CreateTableProperties2 extends DdlChange {
+
+ private static final String TABLE_NAME = "properties2";
+
public CreateTableProperties2(Database db) {
super(db);
}
@Override
public void execute(Context context) throws SQLException {
- List<String> stmts = new CreateTableBuilder(getDialect(), "properties2")
- .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT)
- .addColumn(newVarcharColumnDefBuilder().setColumnName("prop_key").setLimit(512).setIsNullable(false).build())
- .addColumn(newBigIntegerColumnDefBuilder().setColumnName("resource_id").setIsNullable(true).build())
- .addColumn(newBigIntegerColumnDefBuilder().setColumnName("user_id").setIsNullable(true).build())
- .addColumn(newBooleanColumnDefBuilder().setColumnName("is_empty").setIsNullable(false).build())
- .addColumn(newVarcharColumnDefBuilder().setColumnName("text_value").setLimit(MAX_SIZE).setIsNullable(true).build())
- .addColumn(newClobColumnDefBuilder().setColumnName("clob_value").setIsNullable(true).build())
- .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build())
- // table with be renamed to properties in following migration, use final constraint name right away
- .withPkConstraintName("pk_properties")
- .build();
+ VarcharColumnDef propKey = newVarcharColumnDefBuilder().setColumnName("prop_key").setLimit(512).setIsNullable(false).build();
+ List<String> stmts = new CreateTableBuilder(getDialect(), TABLE_NAME)
+ .addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT)
+ .addColumn(propKey)
+ .addColumn(newBigIntegerColumnDefBuilder().setColumnName("resource_id").setIsNullable(true).build())
+ .addColumn(newBigIntegerColumnDefBuilder().setColumnName("user_id").setIsNullable(true).build())
+ .addColumn(newBooleanColumnDefBuilder().setColumnName("is_empty").setIsNullable(false).build())
+ .addColumn(newVarcharColumnDefBuilder().setColumnName("text_value").setLimit(MAX_SIZE).setIsNullable(true).build())
+ .addColumn(newClobColumnDefBuilder().setColumnName("clob_value").setIsNullable(true).build())
+ .addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build())
+ // table with be renamed to properties in following migration, use final constraint name right away
+ .withPkConstraintName("pk_properties")
+ .build();
context.execute(stmts);
+
+ context.execute(new CreateIndexBuilder(getDialect())
+ .setTable(TABLE_NAME)
+ .setName("properties2_key")
+ .addColumn(propKey)
+ .build());
}
}
--- /dev/null
+/*
+ * 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.db.version.v61;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.version.DdlChange;
+import org.sonar.db.version.DropIndexBuilder;
+import org.sonar.db.version.DropTableBuilder;
+
+public class DropTableActivities extends DdlChange {
+
+ private static final String TABLE_ACTIVITIES = "activities";
+
+ public DropTableActivities(Database db) {
+ super(db);
+ }
+
+ @Override
+ public void execute(Context context) throws SQLException {
+ context.execute(new DropIndexBuilder(getDialect())
+ .setTable(TABLE_ACTIVITIES)
+ .setName("activities_log_key")
+ .build());
+
+ context.execute(new DropTableBuilder(getDialect(), TABLE_ACTIVITIES).build());
+ }
+
+}
--- /dev/null
+/*
+ * 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.db.version.v61;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.version.DdlChange;
+import org.sonar.db.version.DropIndexBuilder;
+import org.sonar.db.version.DropTableBuilder;
+
+public class DropTableProperties extends DdlChange {
+
+ private static final String TABLE_PROPERTIES = "properties";
+
+ public DropTableProperties(Database db) {
+ super(db);
+ }
+
+ @Override
+ public void execute(Context context) throws SQLException {
+ context.execute(new DropIndexBuilder(getDialect())
+ .setTable(TABLE_PROPERTIES)
+ .setName("properties_key")
+ .build());
+
+ context.execute(new DropTableBuilder(getDialect(), TABLE_PROPERTIES).build());
+ }
+
+}
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.DdlChange;
+import org.sonar.db.version.VarcharColumnDef;
import static org.sonar.db.version.BigIntegerColumnDef.newBigIntegerColumnDefBuilder;
import static org.sonar.db.version.VarcharColumnDef.UUID_SIZE;
import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder;
public class CreateTableOrganizations extends DdlChange {
+
+ private static final String TABLE_NAME = "organizations";
+
public CreateTableOrganizations(Database db) {
super(db);
}
@Override
public void execute(Context context) throws SQLException {
+ VarcharColumnDef keeColumn = newVarcharColumnDefBuilder().setColumnName("kee").setLimit(32).setIsNullable(false).build();
context.execute(
- new CreateTableBuilder(getDialect(), "organizations")
+ new CreateTableBuilder(getDialect(), TABLE_NAME)
.addPkColumn(newVarcharColumnDefBuilder().setColumnName("uuid").setLimit(UUID_SIZE).setIsNullable(false).build())
- .addColumn(newVarcharColumnDefBuilder().setColumnName("kee").setLimit(32).setIsNullable(false).build())
+ .addColumn(keeColumn)
.addColumn(newVarcharColumnDefBuilder().setColumnName("name").setLimit(64).setIsNullable(false).build())
.addColumn(newVarcharColumnDefBuilder().setColumnName("description").setLimit(256).setIsNullable(true).build())
.addColumn(newVarcharColumnDefBuilder().setColumnName("url").setLimit(256).setIsNullable(true).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("organization_key")
+ .addColumn(keeColumn)
+ .build());
}
}
--- /dev/null
+/*
+ * 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.db.version.v62;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.version.CreateIndexBuilder;
+import org.sonar.db.version.DdlChange;
+import org.sonar.db.version.DropIndexBuilder;
+
+import static org.sonar.db.version.IntegerColumnDef.newIntegerColumnDefBuilder;
+import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder;
+
+public class IncludeOrganizationUuidInUniqueIndexOfGroupRoles extends DdlChange {
+
+ private static final String TABLE_GROUP_ROLES = "group_roles";
+
+ public IncludeOrganizationUuidInUniqueIndexOfGroupRoles(Database db) {
+ super(db);
+ }
+
+ @Override
+ public void execute(Context context) throws SQLException {
+ context.execute(new DropIndexBuilder(getDialect())
+ .setTable(TABLE_GROUP_ROLES)
+ .setName("uniq_group_roles")
+ .build());
+
+ context.execute(new CreateIndexBuilder(getDialect())
+ .setTable(TABLE_GROUP_ROLES)
+ .setName("uniq_group_roles")
+ .setUnique(true)
+ .addColumn(newVarcharColumnDefBuilder().setColumnName("organization_uuid").setLimit(40).build())
+ .addColumn(newIntegerColumnDefBuilder().setColumnName("group_id").build())
+ .addColumn(newIntegerColumnDefBuilder().setColumnName("resource_id").build())
+ .addColumn(newVarcharColumnDefBuilder().setColumnName("role").setLimit(64).build())
+ .build());
+ }
+}
* 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.db.version.v63;
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.DdlChange;
+import org.sonar.db.version.VarcharColumnDef;
import static org.sonar.db.version.VarcharColumnDef.UUID_SIZE;
import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder;
@Override
public void execute(Context context) throws SQLException {
+ VarcharColumnDef uuidColumn = newVarcharColumnDefBuilder().setColumnName("uuid").setLimit(UUID_SIZE).setIsNullable(false).build();
context.execute(new AlterColumnsBuilder(getDatabase().getDialect(), TABLE)
- .updateColumn(newVarcharColumnDefBuilder().setColumnName("uuid").setLimit(UUID_SIZE).setIsNullable(false).build())
+ .updateColumn(uuidColumn)
+ .build());
+
+ context.execute(new CreateIndexBuilder(getDialect())
+ .setTable(TABLE)
+ .setName("events_uuid")
+ .setUnique(true)
+ .addColumn(uuidColumn)
.build());
}
}
public void verify_count_of_added_MigrationStep_types() {
ComponentContainer container = new ComponentContainer();
new MigrationStepModule().configure(container);
- assertThat(container.size()).isEqualTo(167);
+ assertThat(container.size()).isEqualTo(187);
}
}