aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2014-03-06 15:18:35 +0100
committerSimon Brandhof <simon.brandhof@gmail.com>2014-03-06 15:18:35 +0100
commit368fd6f6e73afee8b229dd211f5e7eb4475afdff (patch)
treeae7b6f7964822bd6db5ec83df135dd7280f2b27f
parent94ed63a7c64ddebf9056604535e4439a82ceecae (diff)
downloadsonarqube-368fd6f6e73afee8b229dd211f5e7eb4475afdff.tar.gz
sonarqube-368fd6f6e73afee8b229dd211f5e7eb4475afdff.zip
Refactor org.sonar.server.db.migrations.MassUpdater
-rw-r--r--sonar-server/src/main/java/org/sonar/server/db/migrations/MassUpdater.java (renamed from sonar-server/src/main/java/org/sonar/server/db/migrations/debt/MassUpdater.java)27
-rw-r--r--sonar-server/src/main/java/org/sonar/server/db/migrations/SqlUtil.java (renamed from sonar-server/src/main/java/org/sonar/server/db/migrations/util/SqlUtil.java)20
-rw-r--r--sonar-server/src/main/java/org/sonar/server/db/migrations/debt/DevelopmentCostMeasuresMigration.java30
-rw-r--r--sonar-server/src/main/java/org/sonar/server/db/migrations/debt/IssueChangelogMigration.java30
-rw-r--r--sonar-server/src/main/java/org/sonar/server/db/migrations/debt/IssueMigration.java27
-rw-r--r--sonar-server/src/main/java/org/sonar/server/db/migrations/debt/TechnicalDebtMeasuresMigration.java48
-rw-r--r--sonar-server/src/main/java/org/sonar/server/db/migrations/violation/ViolationConverter.java2
-rw-r--r--sonar-server/src/main/java/org/sonar/server/db/migrations/violation/ViolationMigration.java2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/db/migrate/486_add_resource_path_column.rb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/db/migrate/488_add_project_deprecated_key_column.rb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/db/migrate/489_add_rule_tags.rb8
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/db/migrate/490_migrate_package_resources.rb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/db/migrate/492_remove_rule_notes_and_active_rule_notes.rb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/db/migrate/493_delete_display_treemap_from_measure_filters.rb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/db/migrate/494_delete_properties_on_unknown_components.rb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/db/migrate/495_migrate_base_id_to_base_from_measure_filters.rb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/db/migrate/496_delete_language_property.rb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/db/migrate/497_update_issue_message_by_rule_name_when_no_message.rb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/db/migrate/498_remove_duplicate_active_rules.rb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/db/migrate/510_create_quality_gates.rb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/db/migrate/511_create_quality_gate_conditions.rb4
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/db/migrate/513_update_issue_debt_to_minutes.rb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/db/migrate/514_update_issue_changelog_debt_to_minutes.rb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/db/migrate/515_update_measures_debt_to_minutes.rb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/db/migrate/516_update_development_cost_to_minutes.rb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/db/migrate/517_update_work_units_by_size_point_property_to_minutes.rb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/db/migrate/518_update_alerts_on_debt_to_minutes.rb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/db/migrate/519_update_measure_filters_on_debt_to_minutes.rb2
-rw-r--r--sonar-server/src/test/java/org/sonar/server/db/migrations/SqlUtilTest.java (renamed from sonar-server/src/test/java/org/sonar/server/db/migrations/util/SqlUtilTest.java)3
29 files changed, 114 insertions, 123 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/db/migrations/debt/MassUpdater.java b/sonar-server/src/main/java/org/sonar/server/db/migrations/MassUpdater.java
index 0852ed86224..6c244d21857 100644
--- a/sonar-server/src/main/java/org/sonar/server/db/migrations/debt/MassUpdater.java
+++ b/sonar-server/src/main/java/org/sonar/server/db/migrations/MassUpdater.java
@@ -18,7 +18,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.server.db.migrations.debt;
+package org.sonar.server.db.migrations;
import org.apache.commons.dbutils.DbUtils;
import org.slf4j.Logger;
@@ -26,34 +26,34 @@ 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.*;
+/**
+ * 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);
-
- static final int GROUP_SIZE = 1000;
-
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;
}
- interface InputLoader<S> {
+ public static interface InputLoader<S> {
String selectSql();
S load(ResultSet rs) throws SQLException;
}
- interface InputConverter<S> {
+ public static interface InputConverter<S> {
String updateSql();
- void convert(S input, PreparedStatement statement) throws SQLException;
+ void convert(S input, PreparedStatement updateStatement) throws SQLException;
}
public <S> void execute(InputLoader<S> inputLoader, InputConverter<S> converter) {
@@ -62,15 +62,12 @@ public class MassUpdater {
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());
-
- 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)) {
@@ -98,9 +95,7 @@ public class MassUpdater {
writeConnection.commit();
}
} finally {
- if (writeStatement != null) {
- writeStatement.close();
- }
+ DbUtils.closeQuietly(writeStatement);
DbUtils.closeQuietly(writeConnection);
DbUtils.closeQuietly(readConnection, stmt, rs);
diff --git a/sonar-server/src/main/java/org/sonar/server/db/migrations/util/SqlUtil.java b/sonar-server/src/main/java/org/sonar/server/db/migrations/SqlUtil.java
index 2229a411a22..5bdba077d10 100644
--- a/sonar-server/src/main/java/org/sonar/server/db/migrations/util/SqlUtil.java
+++ b/sonar-server/src/main/java/org/sonar/server/db/migrations/SqlUtil.java
@@ -17,7 +17,7 @@
* 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;
+package org.sonar.server.db.migrations;
import org.slf4j.Logger;
@@ -44,6 +44,24 @@ public class SqlUtil {
}
@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;
diff --git a/sonar-server/src/main/java/org/sonar/server/db/migrations/debt/DevelopmentCostMeasuresMigration.java b/sonar-server/src/main/java/org/sonar/server/db/migrations/debt/DevelopmentCostMeasuresMigration.java
index 1fb759bbfaa..717e3b66017 100644
--- a/sonar-server/src/main/java/org/sonar/server/db/migrations/debt/DevelopmentCostMeasuresMigration.java
+++ b/sonar-server/src/main/java/org/sonar/server/db/migrations/debt/DevelopmentCostMeasuresMigration.java
@@ -23,28 +23,20 @@ package org.sonar.server.db.migrations.debt;
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;
@@ -59,27 +51,29 @@ public class DevelopmentCostMeasuresMigration implements DatabaseMigration {
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);
}
}
);
diff --git a/sonar-server/src/main/java/org/sonar/server/db/migrations/debt/IssueChangelogMigration.java b/sonar-server/src/main/java/org/sonar/server/db/migrations/debt/IssueChangelogMigration.java
index 4b0d487cdd8..720d6113f7f 100644
--- a/sonar-server/src/main/java/org/sonar/server/db/migrations/debt/IssueChangelogMigration.java
+++ b/sonar-server/src/main/java/org/sonar/server/db/migrations/debt/IssueChangelogMigration.java
@@ -26,7 +26,8 @@ import org.sonar.api.config.Settings;
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;
@@ -37,18 +38,10 @@ import java.util.regex.Pattern;
/**
* 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;
@@ -70,28 +63,29 @@ public class IssueChangelogMigration implements DatabaseMigration {
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);
}
}
);
diff --git a/sonar-server/src/main/java/org/sonar/server/db/migrations/debt/IssueMigration.java b/sonar-server/src/main/java/org/sonar/server/db/migrations/debt/IssueMigration.java
index f9b4fa40f8c..c8f379b55c6 100644
--- a/sonar-server/src/main/java/org/sonar/server/db/migrations/debt/IssueMigration.java
+++ b/sonar-server/src/main/java/org/sonar/server/db/migrations/debt/IssueMigration.java
@@ -25,7 +25,8 @@ import org.sonar.api.config.Settings;
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;
@@ -34,16 +35,10 @@ import java.sql.SQLException;
/**
* 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;
@@ -65,28 +60,28 @@ public class IssueMigration implements DatabaseMigration {
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);
}
}
);
diff --git a/sonar-server/src/main/java/org/sonar/server/db/migrations/debt/TechnicalDebtMeasuresMigration.java b/sonar-server/src/main/java/org/sonar/server/db/migrations/debt/TechnicalDebtMeasuresMigration.java
index bebc3f9b0a8..b1772092e16 100644
--- a/sonar-server/src/main/java/org/sonar/server/db/migrations/debt/TechnicalDebtMeasuresMigration.java
+++ b/sonar-server/src/main/java/org/sonar/server/db/migrations/debt/TechnicalDebtMeasuresMigration.java
@@ -23,7 +23,8 @@ package org.sonar.server.db.migrations.debt;
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;
@@ -32,20 +33,13 @@ import java.sql.Types;
/**
* 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
@@ -77,13 +71,13 @@ public class TechnicalDebtMeasuresMigration implements DatabaseMigration {
@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;
}
},
@@ -94,14 +88,14 @@ public class TechnicalDebtMeasuresMigration implements DatabaseMigration {
}
@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);
}
}
);
diff --git a/sonar-server/src/main/java/org/sonar/server/db/migrations/violation/ViolationConverter.java b/sonar-server/src/main/java/org/sonar/server/db/migrations/violation/ViolationConverter.java
index e23bdcced87..1cc1496a8c0 100644
--- a/sonar-server/src/main/java/org/sonar/server/db/migrations/violation/ViolationConverter.java
+++ b/sonar-server/src/main/java/org/sonar/server/db/migrations/violation/ViolationConverter.java
@@ -28,7 +28,7 @@ import org.apache.commons.dbutils.QueryRunner;
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;
diff --git a/sonar-server/src/main/java/org/sonar/server/db/migrations/violation/ViolationMigration.java b/sonar-server/src/main/java/org/sonar/server/db/migrations/violation/ViolationMigration.java
index b35dd88484c..d534b0169b1 100644
--- a/sonar-server/src/main/java/org/sonar/server/db/migrations/violation/ViolationMigration.java
+++ b/sonar-server/src/main/java/org/sonar/server/db/migrations/violation/ViolationMigration.java
@@ -25,7 +25,7 @@ import org.sonar.api.config.Settings;
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;
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/486_add_resource_path_column.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/486_add_resource_path_column.rb
index 6ae9514930e..96913af5a11 100644
--- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/486_add_resource_path_column.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/486_add_resource_path_column.rb
@@ -25,6 +25,6 @@
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
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/488_add_project_deprecated_key_column.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/488_add_project_deprecated_key_column.rb
index 9d22d40d9b9..1fb5f53f723 100644
--- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/488_add_project_deprecated_key_column.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/488_add_project_deprecated_key_column.rb
@@ -25,6 +25,6 @@
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
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/489_add_rule_tags.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/489_add_rule_tags.rb
index 83098a0b3d1..368b9ae1243 100644
--- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/489_add_rule_tags.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/489_add_rule_tags.rb
@@ -19,7 +19,7 @@
#
#
-# Sonar 4.2
+# SonarQube 4.2
#
class AddRuleTags < ActiveRecord::Migration
@@ -32,11 +32,7 @@ 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
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/490_migrate_package_resources.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/490_migrate_package_resources.rb
index 4e217a59574..9acb81749bf 100644
--- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/490_migrate_package_resources.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/490_migrate_package_resources.rb
@@ -19,7 +19,7 @@
#
#
-# Sonar 4.2
+# SonarQube 4.2
# SONAR-926
#
class MigratePackageResources < ActiveRecord::Migration
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/492_remove_rule_notes_and_active_rule_notes.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/492_remove_rule_notes_and_active_rule_notes.rb
index f3e4c8494e8..4a6e95dc9f8 100644
--- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/492_remove_rule_notes_and_active_rule_notes.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/492_remove_rule_notes_and_active_rule_notes.rb
@@ -19,7 +19,7 @@
#
#
-# Sonar 4.2
+# SonarQube 4.2
# SONAR-4923
#
class RemoveRuleNotesAndActiveRuleNotes < ActiveRecord::Migration
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/493_delete_display_treemap_from_measure_filters.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/493_delete_display_treemap_from_measure_filters.rb
index a1beba69a7e..2af2d50595a 100644
--- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/493_delete_display_treemap_from_measure_filters.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/493_delete_display_treemap_from_measure_filters.rb
@@ -19,7 +19,7 @@
#
#
-# Sonar 4.2
+# SonarQube 4.2
# SONAR-4997
#
class DeleteDisplayTreemapFromMeasureFilters < ActiveRecord::Migration
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/494_delete_properties_on_unknown_components.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/494_delete_properties_on_unknown_components.rb
index b43db8d3290..a83d18a7995 100644
--- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/494_delete_properties_on_unknown_components.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/494_delete_properties_on_unknown_components.rb
@@ -19,7 +19,7 @@
#
#
-# Sonar 4.2
+# SonarQube 4.2
# SONAR-5013
#
class DeletePropertiesOnUnknownComponents < ActiveRecord::Migration
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/495_migrate_base_id_to_base_from_measure_filters.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/495_migrate_base_id_to_base_from_measure_filters.rb
index 8df6d80e63c..da18e7a4662 100644
--- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/495_migrate_base_id_to_base_from_measure_filters.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/495_migrate_base_id_to_base_from_measure_filters.rb
@@ -19,7 +19,7 @@
#
#
-# Sonar 4.2
+# SonarQube 4.2
# SONAR-4921
#
class MigrateBaseIdToBaseFromMeasureFilters < ActiveRecord::Migration
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/496_delete_language_property.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/496_delete_language_property.rb
index 11c858cb849..6b3386afdee 100644
--- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/496_delete_language_property.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/496_delete_language_property.rb
@@ -19,7 +19,7 @@
#
#
-# Sonar 4.2
+# SonarQube 4.2
# SONAR-926
# The property sonar.language must not be set in global settings
#
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/497_update_issue_message_by_rule_name_when_no_message.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/497_update_issue_message_by_rule_name_when_no_message.rb
index e72c4a636f7..50298ae0a3e 100644
--- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/497_update_issue_message_by_rule_name_when_no_message.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/497_update_issue_message_by_rule_name_when_no_message.rb
@@ -19,7 +19,7 @@
#
#
-# Sonar 4.2
+# SonarQube 4.2
# SONAR-4785
#
class UpdateIssueMessageByRuleNameWhenNoMessage < ActiveRecord::Migration
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/498_remove_duplicate_active_rules.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/498_remove_duplicate_active_rules.rb
index ceaa5c60c82..bd78e4df76c 100644
--- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/498_remove_duplicate_active_rules.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/498_remove_duplicate_active_rules.rb
@@ -19,7 +19,7 @@
#
#
-# Sonar 4.2
+# SonarQube 4.2
# SONAR-5067
#
class RemoveDuplicateActiveRules < ActiveRecord::Migration
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/510_create_quality_gates.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/510_create_quality_gates.rb
index 14083cf71a1..f6d48aad693 100644
--- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/510_create_quality_gates.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/510_create_quality_gates.rb
@@ -19,7 +19,7 @@
#
#
-# Sonar 4.3
+# SonarQube 4.3
#
class CreateQualityGates < ActiveRecord::Migration
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/511_create_quality_gate_conditions.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/511_create_quality_gate_conditions.rb
index cdf967166a9..9dcefe4fb18 100644
--- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/511_create_quality_gate_conditions.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/511_create_quality_gate_conditions.rb
@@ -17,6 +17,10 @@
# 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
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/513_update_issue_debt_to_minutes.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/513_update_issue_debt_to_minutes.rb
index 7984fae85a6..8c2bc9aab70 100644
--- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/513_update_issue_debt_to_minutes.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/513_update_issue_debt_to_minutes.rb
@@ -19,7 +19,7 @@
#
#
-# Sonar 4.3
+# SonarQube 4.3
# SONAR-4996
#
class UpdateIssueDebtToMinutes < ActiveRecord::Migration
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/514_update_issue_changelog_debt_to_minutes.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/514_update_issue_changelog_debt_to_minutes.rb
index a974294ec69..6ca54b8adde 100644
--- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/514_update_issue_changelog_debt_to_minutes.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/514_update_issue_changelog_debt_to_minutes.rb
@@ -19,7 +19,7 @@
#
#
-# Sonar 4.3
+# SonarQube 4.3
# SONAR-4996
#
class UpdateIssueChangelogDebtToMinutes < ActiveRecord::Migration
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/515_update_measures_debt_to_minutes.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/515_update_measures_debt_to_minutes.rb
index 9c4423a7d2d..e3edd5ec3f4 100644
--- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/515_update_measures_debt_to_minutes.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/515_update_measures_debt_to_minutes.rb
@@ -19,7 +19,7 @@
#
#
-# Sonar 4.3
+# SonarQube 4.3
# SONAR-4996
#
class UpdateMeasuresDebtToMinutes < ActiveRecord::Migration
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/516_update_development_cost_to_minutes.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/516_update_development_cost_to_minutes.rb
index 8c2ba6a2a08..1997feda982 100644
--- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/516_update_development_cost_to_minutes.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/516_update_development_cost_to_minutes.rb
@@ -19,7 +19,7 @@
#
#
-# Sonar 4.3
+# SonarQube 4.3
# SONAR-4996
#
class UpdateDevelopmentCostToMinutes < ActiveRecord::Migration
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/517_update_work_units_by_size_point_property_to_minutes.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/517_update_work_units_by_size_point_property_to_minutes.rb
index 96f7140dea2..82690fd5b1f 100644
--- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/517_update_work_units_by_size_point_property_to_minutes.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/517_update_work_units_by_size_point_property_to_minutes.rb
@@ -19,7 +19,7 @@
#
#
-# Sonar 4.3
+# SonarQube 4.3
# SONAR-4996
#
class UpdateWorkUnitsBySizePointPropertyToMinutes < ActiveRecord::Migration
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/518_update_alerts_on_debt_to_minutes.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/518_update_alerts_on_debt_to_minutes.rb
index 6b7817f7f66..f2ce5175684 100644
--- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/518_update_alerts_on_debt_to_minutes.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/518_update_alerts_on_debt_to_minutes.rb
@@ -19,7 +19,7 @@
#
#
-# Sonar 4.3
+# SonarQube 4.3
# SONAR-4996
#
class UpdateAlertsOnDebtToMinutes < ActiveRecord::Migration
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/519_update_measure_filters_on_debt_to_minutes.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/519_update_measure_filters_on_debt_to_minutes.rb
index 0668cce6118..68ecc84a311 100644
--- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/519_update_measure_filters_on_debt_to_minutes.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/519_update_measure_filters_on_debt_to_minutes.rb
@@ -19,7 +19,7 @@
#
#
-# Sonar 4.3
+# SonarQube 4.3
# SONAR-4996
#
class UpdateMeasureFiltersOnDebtToMinutes < ActiveRecord::Migration
diff --git a/sonar-server/src/test/java/org/sonar/server/db/migrations/util/SqlUtilTest.java b/sonar-server/src/test/java/org/sonar/server/db/migrations/SqlUtilTest.java
index 944da4e0497..e84cc339b93 100644
--- a/sonar-server/src/test/java/org/sonar/server/db/migrations/util/SqlUtilTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/db/migrations/SqlUtilTest.java
@@ -17,10 +17,11 @@
* 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;
+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;