镜像来自
https://github.com/SonarSource/sonarqube.git
synced 2024-08-27 17:54:34 +02:00
SONAR-8353 create table webhook_deliveries
This commit is contained in:
父節點
901b8810a4
當前提交
6c69f5bcce
@ -0,0 +1,31 @@
|
||||
#
|
||||
# SonarQube, open source software quality management tool.
|
||||
# Copyright (C) 2008-2014 SonarSource
|
||||
# mailto:contact AT sonarsource DOT com
|
||||
#
|
||||
# SonarQube is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 3 of the License, or (at your option) any later version.
|
||||
#
|
||||
# SonarQube is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#
|
||||
|
||||
#
|
||||
# SonarQube 6.2
|
||||
#
|
||||
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
|
@ -30,7 +30,7 @@ import org.sonar.db.MyBatis;
|
||||
|
||||
public class DatabaseVersion {
|
||||
|
||||
public static final int LAST_VERSION = 1_422;
|
||||
public static final int LAST_VERSION = 1_423;
|
||||
|
||||
/**
|
||||
* The minimum supported version which can be upgraded. Lower
|
||||
@ -105,7 +105,8 @@ public class DatabaseVersion {
|
||||
"snapshots",
|
||||
"users",
|
||||
"user_roles",
|
||||
"user_tokens");
|
||||
"user_tokens",
|
||||
"webhook_deliveries");
|
||||
|
||||
private MyBatis mybatis;
|
||||
|
||||
|
@ -166,6 +166,7 @@ import org.sonar.db.version.v62.AddOrganizationUuidToPermissionTemplates;
|
||||
import org.sonar.db.version.v62.AddOrganizationUuidToUserRoles;
|
||||
import org.sonar.db.version.v62.CreateDefaultOrganization;
|
||||
import org.sonar.db.version.v62.CreateTableOrganizations;
|
||||
import org.sonar.db.version.v62.CreateTableWebhookDeliveries;
|
||||
import org.sonar.db.version.v62.DeletePermissionShareDashboard;
|
||||
import org.sonar.db.version.v62.DropIssueFiltersTables;
|
||||
import org.sonar.db.version.v62.DropMeasureFiltersTables;
|
||||
@ -382,6 +383,7 @@ public class MigrationStepModule extends Module {
|
||||
UpdateQualityGateConditionsOnCoverage.class,
|
||||
DropRelatedDashboardTables.class,
|
||||
DropMeasureFiltersTables.class,
|
||||
DropIssueFiltersTables.class);
|
||||
DropIssueFiltersTables.class,
|
||||
CreateTableWebhookDeliveries.class);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* SonarQube
|
||||
* Copyright (C) 2009-2016 SonarSource SA
|
||||
* mailto:contact AT sonarsource DOT com
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
package org.sonar.db.version.v62;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import org.sonar.db.Database;
|
||||
import org.sonar.db.version.CreateTableBuilder;
|
||||
import org.sonar.db.version.DdlChange;
|
||||
|
||||
import static org.sonar.db.version.BigIntegerColumnDef.newBigIntegerColumnDefBuilder;
|
||||
import static org.sonar.db.version.BooleanColumnDef.newBooleanColumnDefBuilder;
|
||||
import static org.sonar.db.version.ClobColumnDef.newClobColumnDefBuilder;
|
||||
import static org.sonar.db.version.IntegerColumnDef.newIntegerColumnDefBuilder;
|
||||
import static org.sonar.db.version.VarcharColumnDef.UUID_SIZE;
|
||||
import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder;
|
||||
|
||||
public class CreateTableWebhookDeliveries extends DdlChange {
|
||||
public CreateTableWebhookDeliveries(Database db) {
|
||||
super(db);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Context context) throws SQLException {
|
||||
context.execute(
|
||||
new CreateTableBuilder(getDialect(), "webhook_deliveries")
|
||||
.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(newVarcharColumnDefBuilder().setColumnName("name").setLimit(100).setIsNullable(false).build())
|
||||
.addColumn(newVarcharColumnDefBuilder().setColumnName("url").setLimit(2000).setIsNullable(false).build())
|
||||
.addColumn(newBooleanColumnDefBuilder().setColumnName("success").setIsNullable(false).build())
|
||||
.addColumn(newIntegerColumnDefBuilder().setColumnName("http_status").setIsNullable(true).build())
|
||||
.addColumn(newIntegerColumnDefBuilder().setColumnName("duration_ms").setIsNullable(true).build())
|
||||
.addColumn(newClobColumnDefBuilder().setColumnName("payload").setIsNullable(false).build())
|
||||
.addColumn(newClobColumnDefBuilder().setColumnName("error_stacktrace").setIsNullable(true).build())
|
||||
.addColumn(newBigIntegerColumnDefBuilder().setColumnName("created_at").setIsNullable(false).build())
|
||||
.build());
|
||||
}
|
||||
}
|
@ -511,6 +511,7 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1419');
|
||||
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1420');
|
||||
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1421');
|
||||
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1422');
|
||||
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1423');
|
||||
|
||||
INSERT INTO USERS(ID, LOGIN, NAME, EMAIL, EXTERNAL_IDENTITY, EXTERNAL_IDENTITY_PROVIDER, USER_LOCAL, CRYPTED_PASSWORD, SALT, IS_ROOT, CREATED_AT, UPDATED_AT) VALUES (1, 'admin', 'Administrator', '', 'admin', 'sonarqube', true, 'a373a0e667abb2604c1fd571eb4ad47fe8cc0878', '48bc4b0d93179b5103fd3885ea9119498e9d161b', true, '1418215735482', '1418215735482');
|
||||
ALTER TABLE USERS ALTER COLUMN ID RESTART WITH 2;
|
||||
|
@ -618,3 +618,21 @@ CREATE TABLE "USER_TOKENS" (
|
||||
);
|
||||
CREATE UNIQUE INDEX "USER_TOKENS_TOKEN_HASH" ON "USER_TOKENS" ("TOKEN_HASH");
|
||||
CREATE UNIQUE INDEX "USER_TOKENS_LOGIN_NAME" ON "USER_TOKENS" ("LOGIN", "NAME");
|
||||
|
||||
|
||||
CREATE TABLE "WEBHOOK_DELIVERIES" (
|
||||
"UUID" VARCHAR(40) NOT NULL PRIMARY KEY,
|
||||
"COMPONENT_UUID" VARCHAR(40) NOT NULL,
|
||||
"CE_TASK_UUID" VARCHAR(40) NOT NULL,
|
||||
"NAME" VARCHAR(100) NOT NULL,
|
||||
"URL" VARCHAR(2000) NOT NULL,
|
||||
"SUCCESS" BOOLEAN NOT NULL,
|
||||
"HTTP_STATUS" INT,
|
||||
"DURATION_MS" INT,
|
||||
"PAYLOAD" CLOB NOT NULL,
|
||||
"ERROR_STACKTRACE" CLOB,
|
||||
"CREATED_AT" BIGINT NOT NULL
|
||||
);
|
||||
CREATE UNIQUE INDEX "PK_WEBHOOK_DELIVERIES" ON "WEBHOOK_DELIVERIES" ("UUID");
|
||||
CREATE INDEX "COMPONENT_UUID" ON "WEBHOOK_DELIVERIES" ("COMPONENT_UUID");
|
||||
CREATE INDEX "CE_TASK_UUID" ON "WEBHOOK_DELIVERIES" ("CE_TASK_UUID");
|
||||
|
@ -29,6 +29,6 @@ public class MigrationStepModuleTest {
|
||||
public void verify_count_of_added_MigrationStep_types() {
|
||||
ComponentContainer container = new ComponentContainer();
|
||||
new MigrationStepModule().configure(container);
|
||||
assertThat(container.size()).isEqualTo(163);
|
||||
assertThat(container.size()).isEqualTo(164);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* 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 java.sql.Types;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.sonar.api.utils.System2;
|
||||
import org.sonar.db.DbTester;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
public class CreateTableWebhookDeliveriesTest {
|
||||
|
||||
private static final String TABLE = "webhook_deliveries";
|
||||
|
||||
@Rule
|
||||
public final DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, CreateTableWebhookDeliveriesTest.class, "empty.sql");
|
||||
@Rule
|
||||
public ExpectedException expectedException = ExpectedException.none();
|
||||
|
||||
private CreateTableWebhookDeliveries underTest = new CreateTableWebhookDeliveries(dbTester.database());
|
||||
|
||||
@Test
|
||||
public void creates_table_on_empty_db() throws SQLException {
|
||||
underTest.execute();
|
||||
|
||||
assertThat(dbTester.countRowsOfTable(TABLE)).isEqualTo(0);
|
||||
|
||||
dbTester.assertColumnDefinition(TABLE, "uuid", Types.VARCHAR, 40, false);
|
||||
dbTester.assertColumnDefinition(TABLE, "component_uuid", Types.VARCHAR, 40, false);
|
||||
dbTester.assertColumnDefinition(TABLE, "ce_task_uuid", Types.VARCHAR, 40, false);
|
||||
dbTester.assertColumnDefinition(TABLE, "name", Types.VARCHAR, 100, false);
|
||||
dbTester.assertColumnDefinition(TABLE, "url", Types.VARCHAR, 2000, false);
|
||||
dbTester.assertColumnDefinition(TABLE, "success", Types.BOOLEAN, null, false);
|
||||
dbTester.assertColumnDefinition(TABLE, "http_status", Types.INTEGER, null, true);
|
||||
dbTester.assertColumnDefinition(TABLE, "duration_ms", Types.INTEGER, null, true);
|
||||
dbTester.assertColumnDefinition(TABLE, "payload", Types.CLOB, null, false);
|
||||
dbTester.assertColumnDefinition(TABLE, "error_stacktrace", Types.CLOB, null, true);
|
||||
dbTester.assertColumnDefinition(TABLE, "created_at", Types.BIGINT, null, false);
|
||||
dbTester.assertPrimaryKey(TABLE, "pk_" + TABLE, "uuid");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void migration_is_not_reentrant() throws SQLException {
|
||||
underTest.execute();
|
||||
|
||||
expectedException.expect(IllegalStateException.class);
|
||||
|
||||
underTest.execute();
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user