diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2017-07-28 10:27:21 +0200 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2017-08-07 11:44:06 +0200 |
commit | d43366ba83a9112bfe1b320640b9afc7d171d6c4 (patch) | |
tree | 0cf109a48d6d367314ba44389f7f773b6fb821a0 /server/sonar-db-migration/src/main/java/org/sonar | |
parent | f48a201c2a691281e689b2a4aee9df976a5f3986 (diff) | |
download | sonarqube-d43366ba83a9112bfe1b320640b9afc7d171d6c4.tar.gz sonarqube-d43366ba83a9112bfe1b320640b9afc7d171d6c4.zip |
SONAR-9639 Support CE task characteristics
Diffstat (limited to 'server/sonar-db-migration/src/main/java/org/sonar')
2 files changed, 87 insertions, 1 deletions
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/CreateTableCeTaskCharacteristics.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/CreateTableCeTaskCharacteristics.java new file mode 100644 index 00000000000..79770d26fc0 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/CreateTableCeTaskCharacteristics.java @@ -0,0 +1,84 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info 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.server.platform.db.migration.version.v66; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_SIZE; +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +import java.sql.SQLException; + +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder; +import org.sonar.server.platform.db.migration.sql.CreateTableBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class CreateTableCeTaskCharacteristics extends DdlChange { + private static final String TABLE_NAME = "ce_task_characteristics"; + + public CreateTableCeTaskCharacteristics(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + VarcharColumnDef uuidColumn = newVarcharColumnDefBuilder() + .setColumnName("uuid") + .setLimit(UUID_SIZE) + .setIsNullable(false) + .setIgnoreOracleUnit(true) + .build(); + VarcharColumnDef ceTaskUuidColumn = newVarcharColumnDefBuilder() + .setColumnName("task_uuid") + .setLimit(UUID_SIZE) + .setIsNullable(false) + .setIgnoreOracleUnit(true) + .build(); + VarcharColumnDef keyColumn = newVarcharColumnDefBuilder() + .setColumnName("kee") + .setLimit(512) + .setIsNullable(false) + .setIgnoreOracleUnit(true) + .build(); + VarcharColumnDef valueColumn = newVarcharColumnDefBuilder() + .setColumnName("text_value") + .setLimit(512) + .setIsNullable(true) + .setIgnoreOracleUnit(true) + .build(); + + context.execute( + new CreateTableBuilder(getDialect(), TABLE_NAME) + .addPkColumn(uuidColumn) + .addColumn(ceTaskUuidColumn) + .addColumn(keyColumn) + .addColumn(valueColumn) + .build()); + + context.execute( + new CreateIndexBuilder(getDialect()) + .setTable(TABLE_NAME) + .setName("ce_characteristics_" + ceTaskUuidColumn.getName()) + .addColumn(ceTaskUuidColumn) + .setUnique(false) + .build()); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/DbVersion66.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/DbVersion66.java index a9bb2dc26be..9ea2becfe20 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/DbVersion66.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/DbVersion66.java @@ -26,6 +26,8 @@ import org.sonar.server.platform.db.migration.version.DbVersion; public class DbVersion66 implements DbVersion { @Override public void addSteps(MigrationStepRegistry registry) { - registry.add(1800, "Add incremental column to snapthots table", AddIncrementalColumnToSnapshotsTable.class); + registry + .add(1800, "Add incremental column to snapthots table", AddIncrementalColumnToSnapshotsTable.class) + .add(1801, "Create table CE task characteristics", CreateTableCeTaskCharacteristics.class); } } |