From 6502c3ebd725635c3dea60be68ff99b70a24fad1 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Wed, 14 Sep 2016 13:05:11 +0200 Subject: [PATCH] SONAR-8079 create table rule_repositories Goal is to remove the in-memory cache RuleRepositories. It is not populated on web "followers" (cluster mode) and makes WS api/rules/app and api/rules/repositories fail. --- .../1319_create_table_rule_repositories.rb | 35 +++++++++++++++++++ .../org/sonar/db/version/DatabaseVersion.java | 3 +- .../org/sonar/db/version/rows-h2.sql | 1 + .../org/sonar/db/version/schema-h2.ddl | 8 ++++- 4 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1319_create_table_rule_repositories.rb diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1319_create_table_rule_repositories.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1319_create_table_rule_repositories.rb new file mode 100644 index 00000000000..66b86b6182f --- /dev/null +++ b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1319_create_table_rule_repositories.rb @@ -0,0 +1,35 @@ +# +# 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.1 +# +class CreateTableRuleRepositories < ActiveRecord::Migration + + def self.up + create_table 'rule_repositories', :id => false do |t| + t.column 'kee', :string, :limit => 200, :null => false + t.column 'language', :string, :limit => 20, :null => false + t.column 'name', :string, :limit => 4000, :null => false + t.column 'created_at', :big_integer, :null => false + end + add_primary_key 'rule_repositories', 'kee' + end +end diff --git a/sonar-db/src/main/java/org/sonar/db/version/DatabaseVersion.java b/sonar-db/src/main/java/org/sonar/db/version/DatabaseVersion.java index 7e5a27c3e0b..fa67f02ad38 100644 --- a/sonar-db/src/main/java/org/sonar/db/version/DatabaseVersion.java +++ b/sonar-db/src/main/java/org/sonar/db/version/DatabaseVersion.java @@ -30,7 +30,7 @@ import org.sonar.db.MyBatis; public class DatabaseVersion { - public static final int LAST_VERSION = 1_318; + public static final int LAST_VERSION = 1_319; /** * The minimum supported version which can be upgraded. Lower @@ -87,6 +87,7 @@ public class DatabaseVersion { "rules", "rules_parameters", "rules_profiles", + "rule_repositories", "schema_migrations", "snapshots", "users", diff --git a/sonar-db/src/main/resources/org/sonar/db/version/rows-h2.sql b/sonar-db/src/main/resources/org/sonar/db/version/rows-h2.sql index 7310b9b985e..e7b7850eec0 100644 --- a/sonar-db/src/main/resources/org/sonar/db/version/rows-h2.sql +++ b/sonar-db/src/main/resources/org/sonar/db/version/rows-h2.sql @@ -503,6 +503,7 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1315'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1316'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1317'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1318'); +INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1319'); INSERT INTO USERS(ID, LOGIN, NAME, EMAIL, EXTERNAL_IDENTITY, EXTERNAL_IDENTITY_PROVIDER, USER_LOCAL, CRYPTED_PASSWORD, SALT, CREATED_AT, UPDATED_AT) VALUES (1, 'admin', 'Administrator', '', 'admin', 'sonarqube', true, 'a373a0e667abb2604c1fd571eb4ad47fe8cc0878', '48bc4b0d93179b5103fd3885ea9119498e9d161b', '1418215735482', '1418215735482'); ALTER TABLE USERS ALTER COLUMN ID RESTART WITH 2; diff --git a/sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl b/sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl index e3c74e61ba1..6b5b37e0aeb 100644 --- a/sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl +++ b/sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl @@ -92,6 +92,13 @@ CREATE TABLE "GROUP_ROLES" ( "ROLE" VARCHAR(64) NOT NULL ); +CREATE TABLE "RULE_REPOSITORIES" ( + "KEE" VARCHAR(200) NOT NULL PRIMARY KEY, + "LANGUAGE" VARCHAR(20) NOT NULL, + "NAME" VARCHAR(4000) NOT NULL, + "CREATED_AT" BIGINT +); + CREATE TABLE "RULES" ( "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, @@ -123,7 +130,6 @@ CREATE TABLE "RULES" ( "UPDATED_AT" BIGINT ); - CREATE TABLE "WIDGET_PROPERTIES" ( "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), "WIDGET_ID" INTEGER NOT NULL, -- 2.39.5