aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2016-12-06 20:56:55 +0100
committerSimon Brandhof <simon.brandhof@sonarsource.com>2016-12-12 13:05:19 +0100
commitcb07ea331a5e4e7bc650d59dd2e7583e82658ad8 (patch)
tree8168b14e6a7f3d4fa95a8010b58bb7ad37954b51
parentfe7f91cc2b7bd9b45a1925583c4988b882d90e44 (diff)
downloadsonarqube-cb07ea331a5e4e7bc650d59dd2e7583e82658ad8.tar.gz
sonarqube-cb07ea331a5e4e7bc650d59dd2e7583e82658ad8.zip
SONAR-5471 create webhook_deliveries indices in java
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1423_create_table_webhook_deliveries.rb2
-rw-r--r--sonar-db/src/main/java/org/sonar/db/version/v62/CreateTableWebhookDeliveries.java27
-rw-r--r--sonar-db/src/test/java/org/sonar/db/version/v62/CreateTableWebhookDeliveriesTest.java2
3 files changed, 26 insertions, 5 deletions
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1423_create_table_webhook_deliveries.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1423_create_table_webhook_deliveries.rb
index 66851b912d3..cbb361a92e7 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1423_create_table_webhook_deliveries.rb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1423_create_table_webhook_deliveries.rb
@@ -25,7 +25,5 @@ class CreateTableWebhookDeliveries < ActiveRecord::Migration
def self.up
execute_java_migration('org.sonar.db.version.v62.CreateTableWebhookDeliveries')
- add_index 'webhook_deliveries', :component_uuid, :name => 'component_uuid'
- add_index 'webhook_deliveries', :ce_task_uuid, :name => 'ce_task_uuid'
end
end
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v62/CreateTableWebhookDeliveries.java b/sonar-db/src/main/java/org/sonar/db/version/v62/CreateTableWebhookDeliveries.java
index 5e241a733f4..223914a589f 100644
--- a/sonar-db/src/main/java/org/sonar/db/version/v62/CreateTableWebhookDeliveries.java
+++ b/sonar-db/src/main/java/org/sonar/db/version/v62/CreateTableWebhookDeliveries.java
@@ -21,8 +21,10 @@ 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.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;
@@ -32,17 +34,23 @@ import static org.sonar.db.version.VarcharColumnDef.UUID_SIZE;
import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder;
public class CreateTableWebhookDeliveries extends DdlChange {
+
+ private static final String TABLE_NAME = "webhook_deliveries";
+
public CreateTableWebhookDeliveries(Database db) {
super(db);
}
@Override
public void execute(Context context) throws SQLException {
+ VarcharColumnDef componentUuidColumn = newVarcharColumnDefBuilder().setColumnName("component_uuid").setLimit(UUID_SIZE).setIsNullable(false).build();
+ VarcharColumnDef ceTaskUuidColumn = newVarcharColumnDefBuilder().setColumnName("ce_task_uuid").setLimit(UUID_SIZE).setIsNullable(false).build();
+
context.execute(
- new CreateTableBuilder(getDialect(), "webhook_deliveries")
+ new CreateTableBuilder(getDialect(), TABLE_NAME)
.addPkColumn(newVarcharColumnDefBuilder().setColumnName("uuid").setLimit(UUID_SIZE).setIsNullable(false).build())
- .addColumn(newVarcharColumnDefBuilder().setColumnName("component_uuid").setLimit(UUID_SIZE).setIsNullable(false).build())
- .addColumn(newVarcharColumnDefBuilder().setColumnName("ce_task_uuid").setLimit(UUID_SIZE).setIsNullable(false).build())
+ .addColumn(componentUuidColumn)
+ .addColumn(ceTaskUuidColumn)
.addColumn(newVarcharColumnDefBuilder().setColumnName("name").setLimit(100).setIsNullable(false).build())
.addColumn(newVarcharColumnDefBuilder().setColumnName("url").setLimit(2000).setIsNullable(false).build())
.addColumn(newBooleanColumnDefBuilder().setColumnName("success").setIsNullable(false).build())
@@ -52,5 +60,18 @@ public class CreateTableWebhookDeliveries extends DdlChange {
.addColumn(newClobColumnDefBuilder().setColumnName("error_stacktrace").setIsNullable(true).build())
.addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build())
.build());
+
+ context.execute(
+ new CreateIndexBuilder(getDialect())
+ .setTable(TABLE_NAME)
+ .setName("component_uuid")
+ .addColumn(componentUuidColumn)
+ .build());
+ context.execute(
+ new CreateIndexBuilder(getDialect())
+ .setTable(TABLE_NAME)
+ .setName("ce_task_uuid")
+ .addColumn(ceTaskUuidColumn)
+ .build());
}
}
diff --git a/sonar-db/src/test/java/org/sonar/db/version/v62/CreateTableWebhookDeliveriesTest.java b/sonar-db/src/test/java/org/sonar/db/version/v62/CreateTableWebhookDeliveriesTest.java
index 26e057bfc4b..6783927dd26 100644
--- a/sonar-db/src/test/java/org/sonar/db/version/v62/CreateTableWebhookDeliveriesTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/version/v62/CreateTableWebhookDeliveriesTest.java
@@ -59,6 +59,8 @@ public class CreateTableWebhookDeliveriesTest {
dbTester.assertColumnDefinition(TABLE, "error_stacktrace", Types.CLOB, null, true);
dbTester.assertColumnDefinition(TABLE, "created_at", Types.BIGINT, null, false);
dbTester.assertPrimaryKey(TABLE, "pk_" + TABLE, "uuid");
+ dbTester.assertIndex(TABLE, "component_uuid", "component_uuid");
+ dbTester.assertIndex(TABLE, "ce_task_uuid", "ce_task_uuid");
}
@Test