diff options
author | Jean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com> | 2014-11-06 16:47:46 +0100 |
---|---|---|
committer | Jean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com> | 2014-11-06 16:47:53 +0100 |
commit | 15c34a1fbcb4f42b45ba82ccb9090235c2bf7164 (patch) | |
tree | dd1acd78f8b77dd0795a686a66e1e7be0acce26a | |
parent | 1e92c1ccba98dd2b4cdda59b8fd5332022b69a79 (diff) | |
download | sonarqube-15c34a1fbcb4f42b45ba82ccb9090235c2bf7164.tar.gz sonarqube-15c34a1fbcb4f42b45ba82ccb9090235c2bf7164.zip |
SONAR-5825 Create DB structure to store file oriented data
4 files changed, 69 insertions, 1 deletions
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/713_create_file_sources.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/713_create_file_sources.rb new file mode 100644 index 00000000000..d8cdc1b2776 --- /dev/null +++ b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/713_create_file_sources.rb @@ -0,0 +1,50 @@ +# +# 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 5.0 +# SONAR-5624 +# +class CreateFileSources < ActiveRecord::Migration + + def self.up + create_table :file_sources do |t| + t.column :project_uuid, :string, :limit => 50, :null => false + t.column :file_uuid, :string, :limit => 50, :null => false + t.column :data, :text, :null => true + t.column :data_hash, :string, :limit => 50, :null => true + t.column :created_at, :datetime, :null => false + t.column :updated_at, :datetime, :null => false + end + + if dialect()=='mysql' + ActiveRecord::Base.connection.execute("alter table file_sources modify data longtext") + end + + ["project_uuid", "file_uuid", "updated_at"].each do |column| + begin + add_index "file_sources", column, :name => "file_sources_" + column + rescue + # ignore + end + end + + end + +end diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java b/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java index 93d65401b9e..970a1d1b2c1 100644 --- a/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java +++ b/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java @@ -33,7 +33,7 @@ import java.util.List; */ public class DatabaseVersion implements BatchComponent, ServerComponent { - public static final int LAST_VERSION = 712; + public static final int LAST_VERSION = 713; /** * List of all the tables. * This list is hardcoded because we didn't succeed in using java.sql.DatabaseMetaData#getTables() in the same way @@ -52,6 +52,7 @@ public class DatabaseVersion implements BatchComponent, ServerComponent { "dependencies", "duplications_index", "events", + "file_sources", "graphs", "groups", "groups_users", diff --git a/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql b/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql index b7118612b8a..2d0708f8199 100644 --- a/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql +++ b/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql @@ -272,6 +272,7 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('709'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('710'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('711'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('712'); +INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('713'); INSERT INTO USERS(ID, LOGIN, NAME, EMAIL, CRYPTED_PASSWORD, SALT, CREATED_AT, UPDATED_AT, REMEMBER_TOKEN, REMEMBER_TOKEN_EXPIRES_AT) VALUES (1, 'admin', 'Administrator', '', 'a373a0e667abb2604c1fd571eb4ad47fe8cc0878', '48bc4b0d93179b5103fd3885ea9119498e9d161b', '2011-09-26 22:27:48.0', '2011-09-26 22:27:48.0', null, null); ALTER TABLE USERS ALTER COLUMN ID RESTART WITH 2; diff --git a/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl b/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl index 4db09659428..f579edcf5c2 100644 --- a/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl +++ b/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl @@ -566,6 +566,16 @@ CREATE TABLE "ANALYSIS_REPORTS" ( "FINISHED_AT" TIMESTAMP ); +CREATE TABLE "FILE_SOURCES" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "PROJECT_UUID" VARCHAR(50) NOT NULL, + "FILE_UUID" VARCHAR(50) NOT NULL, + "DATA" CLOB(2147483647), + "DATA_HASH" VARCHAR(50) NOT NULL, + "CREATED_AT" TIMESTAMP NOT NULL, + "UPDATED_AT" TIMESTAMP NOT NULL +); + -- ---------------------------------------------- -- DDL Statements for indexes -- ---------------------------------------------- @@ -707,3 +717,9 @@ CREATE UNIQUE INDEX "ACTIVE_RULES_UNIQUE" ON "ACTIVE_RULES" ("PROFILE_ID","RULE_ CREATE INDEX "SNAPSHOT_DATA_RESOURCE_IDS" ON "SNAPSHOT_DATA" ("RESOURCE_ID"); CREATE UNIQUE INDEX "PROFILE_UNIQUE_KEY" ON "RULES_PROFILES" ("KEE"); + +CREATE INDEX "FILE_SOURCES_PROJECT_UUID" ON "FILE_SOURCES" ("PROJECT_UUID"); + +CREATE INDEX "FILE_SOURCES_FILE_UUID" ON "FILE_SOURCES" ("FILE_UUID"); + +CREATE INDEX "FILE_SOURCES_UPDATED_AT" ON "FILE_SOURCES" ("UPDATED_AT"); |