--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2013 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.
+ */
+
+package org.sonar.server.db.migrations;
+
+import org.apache.commons.dbutils.DbUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.sonar.api.utils.MessageException;
+import org.sonar.core.persistence.Database;
+import org.sonar.core.persistence.dialect.MySql;
+
+import java.sql.*;
+
+/**
+ * Update a table by iterating a sub-set of rows. For each row a SQL UPDATE request
+ * is executed.
+ */
+public class MassUpdater {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(MassUpdater.class);
+ private static final String FAILURE_MESSAGE = "Fail to migrate data";
+ private static final int GROUP_SIZE = 1000;
+ private final Database db;
+
+ public MassUpdater(Database db) {
+ this.db = db;
+ }
+
+ public static interface InputLoader<S> {
+ String selectSql();
+
+ S load(ResultSet rs) throws SQLException;
+ }
+
+ public static interface InputConverter<S> {
+ String updateSql();
+
+ void convert(S input, PreparedStatement updateStatement) throws SQLException;
+ }
+
+ public <S> void execute(InputLoader<S> inputLoader, InputConverter<S> converter) {
+ long count = 0;
+ try {
+ Connection readConnection = db.getDataSource().getConnection();
+ Statement stmt = null;
+ ResultSet rs = null;
+ Connection writeConnection = db.getDataSource().getConnection();
+ PreparedStatement writeStatement = null;
+ try {
+ readConnection.setAutoCommit(false);
+ writeConnection.setAutoCommit(false);
+ writeStatement = writeConnection.prepareStatement(converter.updateSql());
+ stmt = readConnection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
+ stmt.setFetchSize(GROUP_SIZE);
+ if (db.getDialect().getId().equals(MySql.ID)) {
+ stmt.setFetchSize(Integer.MIN_VALUE);
+ } else {
+ stmt.setFetchSize(GROUP_SIZE);
+ }
+ rs = stmt.executeQuery(inputLoader.selectSql());
+
+ int cursor = 0;
+ while (rs.next()) {
+ converter.convert(inputLoader.load(rs), writeStatement);
+ writeStatement.addBatch();
+
+ cursor++;
+ count++;
+ if (cursor == GROUP_SIZE) {
+ writeStatement.executeBatch();
+ writeConnection.commit();
+ cursor = 0;
+ }
+ }
+ if (cursor > 0) {
+ writeStatement.executeBatch();
+ writeConnection.commit();
+ }
+ } finally {
+ DbUtils.closeQuietly(writeStatement);
+ DbUtils.closeQuietly(writeConnection);
+ DbUtils.closeQuietly(readConnection, stmt, rs);
+
+ LOGGER.info("{} rows have been updated", count);
+ }
+ } catch (SQLException e) {
+ LOGGER.error(FAILURE_MESSAGE, e);
+ SqlUtil.log(LOGGER, e);
+ throw MessageException.of(FAILURE_MESSAGE);
+
+ } catch (Exception e) {
+ LOGGER.error(FAILURE_MESSAGE, e);
+ throw MessageException.of(FAILURE_MESSAGE);
+ }
+ }
+
+}
--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2013 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.
+ */
+package org.sonar.server.db.migrations;
+
+import org.slf4j.Logger;
+
+import javax.annotation.CheckForNull;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+public class SqlUtil {
+
+ private SqlUtil() {
+ // only static methods
+ }
+
+ /**
+ * Logback does not log exceptions associated to {@link java.sql.SQLException#getNextException()}.
+ * See http://jira.qos.ch/browse/LOGBACK-775
+ */
+ public static void log(Logger logger, SQLException e) {
+ SQLException next = e.getNextException();
+ while (next != null) {
+ logger.error("SQL error: {}. Message: {}", next.getSQLState(), next.getMessage());
+ next = next.getNextException();
+ }
+ }
+
+ @CheckForNull
+ public static Long getLong(ResultSet rs, int columnIndex) throws SQLException {
+ long l = rs.getLong(columnIndex);
+ return rs.wasNull() ? null : l;
+ }
+
+ @CheckForNull
+ public static Double getDouble(ResultSet rs, int columnIndex) throws SQLException {
+ double d = rs.getDouble(columnIndex);
+ return rs.wasNull() ? null : d;
+ }
+
+ @CheckForNull
+ public static Integer getInt(ResultSet rs, int columnIndex) throws SQLException {
+ int i = rs.getInt(columnIndex);
+ return rs.wasNull() ? null : i;
+ }
+
+ @CheckForNull
+ public static Long getLong(ResultSet rs, String columnName) throws SQLException {
+ long l = rs.getLong(columnName);
+ return rs.wasNull() ? null : l;
+ }
+
+ @CheckForNull
+ public static Double getDouble(ResultSet rs, String columnName) throws SQLException {
+ double d = rs.getDouble(columnName);
+ return rs.wasNull() ? null : d;
+ }
+
+ @CheckForNull
+ public static Integer getInt(ResultSet rs, String columnName) throws SQLException {
+ int i = rs.getInt(columnName);
+ return rs.wasNull() ? null : i;
+ }
+}
import org.sonar.api.config.Settings;
import org.sonar.core.persistence.Database;
import org.sonar.server.db.migrations.DatabaseMigration;
-import org.sonar.server.db.migrations.util.SqlUtil;
+import org.sonar.server.db.migrations.MassUpdater;
+import org.sonar.server.db.migrations.SqlUtil;
import javax.annotation.CheckForNull;
-
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
/**
* Used in the Active Record Migration 516
+ * @since 4.3
*/
public class DevelopmentCostMeasuresMigration implements DatabaseMigration {
- private static final String ID = "id";
- private static final String VALUE = "value";
-
- private static final String SELECT_SQL = "SELECT pm.id AS " + ID + ", pm.value AS " + VALUE +
- " FROM project_measures pm INNER JOIN metrics m on m.id=pm.metric_id " +
- " WHERE m.name='development_cost' AND pm.value IS NOT NULL";
-
- private static final String UPDATE_SQL = "UPDATE project_measures SET value=NULL,text_value=? WHERE id=?";
-
private final WorkDurationConvertor workDurationConvertor;
private final Database db;
new MassUpdater.InputLoader<Row>() {
@Override
public String selectSql() {
- return SELECT_SQL;
+ return "SELECT pm.id, pm.value " +
+ " FROM project_measures pm INNER JOIN metrics m on m.id=pm.metric_id " +
+ " WHERE m.name='development_cost' AND pm.value IS NOT NULL";
}
@Override
public Row load(ResultSet rs) throws SQLException {
Row row = new Row();
- row.id = SqlUtil.getLong(rs, ID);
- row.value = SqlUtil.getDouble(rs, VALUE);
+ row.id = SqlUtil.getLong(rs, 1);
+ row.value = SqlUtil.getDouble(rs, 2);
return row;
}
},
new MassUpdater.InputConverter<Row>() {
@Override
public String updateSql() {
- return UPDATE_SQL;
+ return "UPDATE project_measures SET value=NULL,text_value=? WHERE id=?";
}
@Override
- public void convert(Row row, PreparedStatement statement) throws SQLException {
- statement.setString(1, convertDebtForDays(row.value));
- statement.setLong(2, row.id);
+ public void convert(Row row, PreparedStatement updateStatement) throws SQLException {
+ updateStatement.setString(1, convertDebtForDays(row.value));
+ updateStatement.setLong(2, row.id);
}
}
);
import org.sonar.api.utils.System2;
import org.sonar.core.persistence.Database;
import org.sonar.server.db.migrations.DatabaseMigration;
-import org.sonar.server.db.migrations.util.SqlUtil;
+import org.sonar.server.db.migrations.MassUpdater;
+import org.sonar.server.db.migrations.SqlUtil;
import java.sql.Date;
import java.sql.PreparedStatement;
/**
* Used in the Active Record Migration 514
+ * @since 4.3
*/
public class IssueChangelogMigration implements DatabaseMigration {
- private static final String ID = "id";
- private static final String CHANGE_DATA = "changeData";
-
- private static final String SELECT_SQL = "SELECT ic.id AS " + ID + ", ic.change_data AS " + CHANGE_DATA +
- " FROM issue_changes ic " +
- " WHERE ic.change_type = 'diff' AND ic.change_data LIKE '%technicalDebt%'";
-
- private static final String UPDATE_SQL = "UPDATE issue_changes SET change_data=?,updated_at=? WHERE id=?";
-
private final WorkDurationConvertor workDurationConvertor;
private final System2 system2;
private final Database db;
new MassUpdater.InputLoader<Row>() {
@Override
public String selectSql() {
- return SELECT_SQL;
+ return "SELECT ic.id, ic.change_data FROM issue_changes ic " +
+ " WHERE ic.change_type = 'diff' AND ic.change_data LIKE '%technicalDebt%'";
}
@Override
public Row load(ResultSet rs) throws SQLException {
Row row = new Row();
- row.id = SqlUtil.getLong(rs, ID);
- row.changeData = rs.getString(CHANGE_DATA);
+ row.id = SqlUtil.getLong(rs, 1);
+ row.changeData = rs.getString(2);
return row;
}
},
new MassUpdater.InputConverter<Row>() {
@Override
public String updateSql() {
- return UPDATE_SQL;
+ return "UPDATE issue_changes SET change_data=?,updated_at=? WHERE id=?";
}
@Override
- public void convert(Row row, PreparedStatement statement) throws SQLException {
- statement.setString(1, convertChangelog(row.changeData));
- statement.setDate(2, new Date(system2.now()));
- statement.setLong(3, row.id);
+ public void convert(Row row, PreparedStatement updateStatement) throws SQLException {
+ updateStatement.setString(1, convertChangelog(row.changeData));
+ updateStatement.setDate(2, new Date(system2.now()));
+ updateStatement.setLong(3, row.id);
}
}
);
import org.sonar.api.utils.System2;
import org.sonar.core.persistence.Database;
import org.sonar.server.db.migrations.DatabaseMigration;
-import org.sonar.server.db.migrations.util.SqlUtil;
+import org.sonar.server.db.migrations.MassUpdater;
+import org.sonar.server.db.migrations.SqlUtil;
import java.sql.Date;
import java.sql.PreparedStatement;
/**
* Used in the Active Record Migration 513
+ * @since 4.3
*/
public class IssueMigration implements DatabaseMigration {
- private static final String ID = "id";
- private static final String DEBT = "debt";
-
- private static final String SELECT_SQL = "SELECT i.id AS " + ID + ", i.technical_debt AS " + DEBT +
- " FROM issues i WHERE i.technical_debt IS NOT NULL";
- private static final String UPDATE_SQL = "UPDATE issues SET technical_debt=?,updated_at=? WHERE id=?";
-
private final WorkDurationConvertor workDurationConvertor;
private final System2 system2;
private final Database db;
new MassUpdater.InputLoader<Row>() {
@Override
public String selectSql() {
- return SELECT_SQL;
+ return "SELECT i.id, i.technical_debt FROM issues i WHERE i.technical_debt IS NOT NULL";
}
@Override
public Row load(ResultSet rs) throws SQLException {
Row row = new Row();
- row.id = SqlUtil.getLong(rs, ID);
- row.debt = SqlUtil.getLong(rs, DEBT);
+ row.id = SqlUtil.getLong(rs, 1);
+ row.debt = SqlUtil.getLong(rs, 2);
return row;
}
},
new MassUpdater.InputConverter<Row>() {
@Override
public String updateSql() {
- return UPDATE_SQL;
+ return "UPDATE issues SET technical_debt=?,updated_at=? WHERE id=?";
}
@Override
- public void convert(Row row, PreparedStatement statement) throws SQLException {
- statement.setLong(1, workDurationConvertor.createFromLong(row.debt));
- statement.setDate(2, new Date(system2.now()));
- statement.setLong(3, row.id);
+ public void convert(Row row, PreparedStatement updateStatement) throws SQLException {
+ updateStatement.setLong(1, workDurationConvertor.createFromLong(row.debt));
+ updateStatement.setDate(2, new Date(system2.now()));
+ updateStatement.setLong(3, row.id);
}
}
);
+++ /dev/null
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2013 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.
- */
-
-package org.sonar.server.db.migrations.debt;
-
-import org.apache.commons.dbutils.DbUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.sonar.api.utils.MessageException;
-import org.sonar.core.persistence.Database;
-import org.sonar.core.persistence.dialect.MySql;
-import org.sonar.server.db.migrations.util.SqlUtil;
-
-import java.sql.*;
-
-public class MassUpdater {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(MassUpdater.class);
-
- static final int GROUP_SIZE = 1000;
-
- private static final String FAILURE_MESSAGE = "Fail to migrate data";
-
- private final Database db;
-
- public MassUpdater(Database db) {
- this.db = db;
- }
-
- interface InputLoader<S> {
- String selectSql();
-
- S load(ResultSet rs) throws SQLException;
- }
-
- interface InputConverter<S> {
- String updateSql();
-
- void convert(S input, PreparedStatement statement) throws SQLException;
- }
-
- public <S> void execute(InputLoader<S> inputLoader, InputConverter<S> converter) {
- long count = 0;
- try {
- Connection readConnection = db.getDataSource().getConnection();
- Statement stmt = null;
- ResultSet rs = null;
-
- Connection writeConnection = db.getDataSource().getConnection();
- PreparedStatement writeStatement = null;
- try {
- writeConnection.setAutoCommit(false);
- writeStatement = writeConnection.prepareStatement(converter.updateSql());
-
- readConnection.setAutoCommit(false);
-
- stmt = readConnection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
- stmt.setFetchSize(GROUP_SIZE);
- if (db.getDialect().getId().equals(MySql.ID)) {
- stmt.setFetchSize(Integer.MIN_VALUE);
- } else {
- stmt.setFetchSize(GROUP_SIZE);
- }
- rs = stmt.executeQuery(inputLoader.selectSql());
-
- int cursor = 0;
- while (rs.next()) {
- converter.convert(inputLoader.load(rs), writeStatement);
- writeStatement.addBatch();
-
- cursor++;
- count++;
- if (cursor == GROUP_SIZE) {
- writeStatement.executeBatch();
- writeConnection.commit();
- cursor = 0;
- }
- }
- if (cursor > 0) {
- writeStatement.executeBatch();
- writeConnection.commit();
- }
- } finally {
- if (writeStatement != null) {
- writeStatement.close();
- }
- DbUtils.closeQuietly(writeConnection);
- DbUtils.closeQuietly(readConnection, stmt, rs);
-
- LOGGER.info("{} rows have been updated", count);
- }
- } catch (SQLException e) {
- LOGGER.error(FAILURE_MESSAGE, e);
- SqlUtil.log(LOGGER, e);
- throw MessageException.of(FAILURE_MESSAGE);
-
- } catch (Exception e) {
- LOGGER.error(FAILURE_MESSAGE, e);
- throw MessageException.of(FAILURE_MESSAGE);
- }
- }
-
-}
import org.sonar.api.config.Settings;
import org.sonar.core.persistence.Database;
import org.sonar.server.db.migrations.DatabaseMigration;
-import org.sonar.server.db.migrations.util.SqlUtil;
+import org.sonar.server.db.migrations.MassUpdater;
+import org.sonar.server.db.migrations.SqlUtil;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
/**
* Used in the Active Record Migration 515
+ * @since 4.3
*/
public class TechnicalDebtMeasuresMigration implements DatabaseMigration {
- private static final String ID = "id";
- private static final String VALUE = "value";
- private static final String VAR1 = "var1";
- private static final String VAR2 = "var2";
- private static final String VAR3 = "var3";
- private static final String VAR4 = "var4";
- private static final String VAR5 = "var5";
-
- private static final String SELECT_SQL = "SELECT pm.id AS " + ID + ", pm.value AS " + VALUE +
- ", pm.variation_value_1 AS " + VAR1 + ", pm.variation_value_2 AS " + VAR2 + ", pm.variation_value_3 AS " + VAR3 +
- ", pm.variation_value_4 AS " + VAR4 + ", pm.variation_value_5 AS " + VAR5 +
+ private static final String SELECT_SQL = "SELECT pm.id, pm.value " +
+ ", pm.variation_value_1 , pm.variation_value_2, pm.variation_value_3 " +
+ ", pm.variation_value_4 , pm.variation_value_5 " +
" FROM project_measures pm INNER JOIN metrics m on m.id=pm.metric_id " +
" WHERE (m.name='sqale_index' or m.name='new_technical_debt' " +
// SQALE measures
@Override
public Row load(ResultSet rs) throws SQLException {
Row row = new Row();
- row.id = SqlUtil.getLong(rs, ID);
- row.value = SqlUtil.getDouble(rs, VALUE);
- row.var1 = SqlUtil.getDouble(rs, VAR1);
- row.var2 = SqlUtil.getDouble(rs, VAR2);
- row.var3 = SqlUtil.getDouble(rs, VAR3);
- row.var4 = SqlUtil.getDouble(rs, VAR4);
- row.var5 = SqlUtil.getDouble(rs, VAR5);
+ row.id = SqlUtil.getLong(rs, 1);
+ row.value = SqlUtil.getDouble(rs, 2);
+ row.var1 = SqlUtil.getDouble(rs, 3);
+ row.var2 = SqlUtil.getDouble(rs, 4);
+ row.var3 = SqlUtil.getDouble(rs, 5);
+ row.var4 = SqlUtil.getDouble(rs, 6);
+ row.var5 = SqlUtil.getDouble(rs, 7);
return row;
}
},
}
@Override
- public void convert(Row row, PreparedStatement statement) throws SQLException {
- setDouble(statement, 1, row.value);
- setDouble(statement, 2, row.var1);
- setDouble(statement, 3, row.var2);
- setDouble(statement, 4, row.var3);
- setDouble(statement, 5, row.var4);
- setDouble(statement, 6, row.var5);
- statement.setLong(7, row.id);
+ public void convert(Row row, PreparedStatement updateStatement) throws SQLException {
+ setDouble(updateStatement, 1, row.value);
+ setDouble(updateStatement, 2, row.var1);
+ setDouble(updateStatement, 3, row.var2);
+ setDouble(updateStatement, 4, row.var3);
+ setDouble(updateStatement, 5, row.var4);
+ setDouble(updateStatement, 6, row.var5);
+ updateStatement.setLong(7, row.id);
}
}
);
+++ /dev/null
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2013 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.
- */
-package org.sonar.server.db.migrations.util;
-
-import org.slf4j.Logger;
-
-import javax.annotation.CheckForNull;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-public class SqlUtil {
-
- private SqlUtil() {
- // only static methods
- }
-
- /**
- * Logback does not log exceptions associated to {@link java.sql.SQLException#getNextException()}.
- * See http://jira.qos.ch/browse/LOGBACK-775
- */
- public static void log(Logger logger, SQLException e) {
- SQLException next = e.getNextException();
- while (next != null) {
- logger.error("SQL error: {}. Message: {}", next.getSQLState(), next.getMessage());
- next = next.getNextException();
- }
- }
-
- @CheckForNull
- public static Long getLong(ResultSet rs, String columnName) throws SQLException {
- long l = rs.getLong(columnName);
- return rs.wasNull() ? null : l;
- }
-
- @CheckForNull
- public static Double getDouble(ResultSet rs, String columnName) throws SQLException {
- double d = rs.getDouble(columnName);
- return rs.wasNull() ? null : d;
- }
-
- @CheckForNull
- public static Integer getInt(ResultSet rs, String columnName) throws SQLException {
- int i = rs.getInt(columnName);
- return rs.wasNull() ? null : i;
- }
-}
import org.apache.commons.dbutils.handlers.AbstractListHandler;
import org.sonar.api.rule.Severity;
import org.sonar.core.persistence.Database;
-import org.sonar.server.db.migrations.util.SqlUtil;
+import org.sonar.server.db.migrations.SqlUtil;
import java.sql.Connection;
import java.sql.Date;
import org.sonar.api.utils.MessageException;
import org.sonar.core.persistence.Database;
import org.sonar.server.db.migrations.DatabaseMigration;
-import org.sonar.server.db.migrations.util.SqlUtil;
+import org.sonar.server.db.migrations.SqlUtil;
import java.sql.SQLException;
class AddResourcePathColumn < ActiveRecord::Migration
def self.up
- add_column 'projects', :path, :string, :null => true, :limit => 2000
+ add_column 'projects', :path, :string, :null => true, :limit => 2000
end
end
class AddProjectDeprecatedKeyColumn < ActiveRecord::Migration
def self.up
- add_column 'projects', 'deprecated_kee', :string, :null => true, :limit => 400
+ add_column 'projects', 'deprecated_kee', :string, :null => true, :limit => 400
end
end
#
#
-# Sonar 4.2
+# SonarQube 4.2
#
class AddRuleTags < ActiveRecord::Migration
t.column :rule_tag_id, :integer, :null => false
t.column :tag_type, :string, :null => true, :limit => 20
end
- begin
- add_index 'rules_rule_tags', ['rule_id', 'rule_tag_id'], :unique => true, :name => 'uniq_rule_tags'
- rescue
- # ignore
- end
+ add_index 'rules_rule_tags', ['rule_id', 'rule_tag_id'], :unique => true, :name => 'uniq_rule_tags'
end
end
#
#
-# Sonar 4.2
+# SonarQube 4.2
# SONAR-926
#
class MigratePackageResources < ActiveRecord::Migration
#
#
-# Sonar 4.2
+# SonarQube 4.2
# SONAR-4923
#
class RemoveRuleNotesAndActiveRuleNotes < ActiveRecord::Migration
#
#
-# Sonar 4.2
+# SonarQube 4.2
# SONAR-4997
#
class DeleteDisplayTreemapFromMeasureFilters < ActiveRecord::Migration
#
#
-# Sonar 4.2
+# SonarQube 4.2
# SONAR-5013
#
class DeletePropertiesOnUnknownComponents < ActiveRecord::Migration
#
#
-# Sonar 4.2
+# SonarQube 4.2
# SONAR-4921
#
class MigrateBaseIdToBaseFromMeasureFilters < ActiveRecord::Migration
#
#
-# Sonar 4.2
+# SonarQube 4.2
# SONAR-926
# The property sonar.language must not be set in global settings
#
#
#
-# Sonar 4.2
+# SonarQube 4.2
# SONAR-4785
#
class UpdateIssueMessageByRuleNameWhenNoMessage < ActiveRecord::Migration
#
#
-# Sonar 4.2
+# SonarQube 4.2
# SONAR-5067
#
class RemoveDuplicateActiveRules < ActiveRecord::Migration
#
#
-# Sonar 4.3
+# SonarQube 4.3
#
class CreateQualityGates < ActiveRecord::Migration
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
+
+#
+# SonarQube 4.3
+#
class CreateQualityGateConditions < ActiveRecord::Migration
def self.up
#
#
-# Sonar 4.3
+# SonarQube 4.3
# SONAR-4996
#
class UpdateIssueDebtToMinutes < ActiveRecord::Migration
#
#
-# Sonar 4.3
+# SonarQube 4.3
# SONAR-4996
#
class UpdateIssueChangelogDebtToMinutes < ActiveRecord::Migration
#
#
-# Sonar 4.3
+# SonarQube 4.3
# SONAR-4996
#
class UpdateMeasuresDebtToMinutes < ActiveRecord::Migration
#
#
-# Sonar 4.3
+# SonarQube 4.3
# SONAR-4996
#
class UpdateDevelopmentCostToMinutes < ActiveRecord::Migration
#
#
-# Sonar 4.3
+# SonarQube 4.3
# SONAR-4996
#
class UpdateWorkUnitsBySizePointPropertyToMinutes < ActiveRecord::Migration
#
#
-# Sonar 4.3
+# SonarQube 4.3
# SONAR-4996
#
class UpdateAlertsOnDebtToMinutes < ActiveRecord::Migration
#
#
-# Sonar 4.3
+# SonarQube 4.3
# SONAR-4996
#
class UpdateMeasureFiltersOnDebtToMinutes < ActiveRecord::Migration
--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2013 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.
+ */
+package org.sonar.server.db.migrations;
+
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.sonar.server.db.migrations.SqlUtil;
+
+import java.sql.SQLException;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
+public class SqlUtilTest {
+
+ @Test
+ public void log_all_sql_exceptions() {
+ SQLException root = new SQLException("this is root", "123");
+ SQLException next = new SQLException("this is next", "456");
+ root.setNextException(next);
+
+ Logger logger = mock(Logger.class);
+ SqlUtil.log(logger, root);
+
+ verify(logger).error("SQL error: {}. Message: {}", "456", "this is next");
+ }
+}
+++ /dev/null
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2013 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.
- */
-package org.sonar.server.db.migrations.util;
-
-import org.junit.Test;
-import org.slf4j.Logger;
-
-import java.sql.SQLException;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-
-public class SqlUtilTest {
-
- @Test
- public void log_all_sql_exceptions() {
- SQLException root = new SQLException("this is root", "123");
- SQLException next = new SQLException("this is next", "456");
- root.setNextException(next);
-
- Logger logger = mock(Logger.class);
- SqlUtil.log(logger, root);
-
- verify(logger).error("SQL error: {}. Message: {}", "456", "this is next");
- }
-}