From 1eb5dbdab56e6948ea96ed11e62a399ae9c7d2c3 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Lievremont Date: Mon, 21 Jul 2014 16:08:39 +0200 Subject: [PATCH] SONAR-5001 Split migration on rules description format (1 to add column, 1 to fill column) --- .../581_add_rules_description_format.rb | 7 ---- ...pdate_existing_rules_description_format.rb | 35 +++++++++++++++++++ .../core/persistence/DatabaseVersion.java | 2 +- .../org/sonar/core/persistence/rows-h2.sql | 1 + 4 files changed, 37 insertions(+), 8 deletions(-) create mode 100644 server/sonar-web/src/main/webapp/WEB-INF/db/migrate/582_update_existing_rules_description_format.rb diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/581_add_rules_description_format.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/581_add_rules_description_format.rb index 24d620385c0..87d1867acfc 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/581_add_rules_description_format.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/581_add_rules_description_format.rb @@ -24,15 +24,8 @@ # class AddRulesDescriptionFormat < ActiveRecord::Migration - class Rule < ActiveRecord::Base - end - def self.up add_column :rules, :description_format, :string, :null => true, :limit => 20 - - Rule.reset_column_information - Rule.update_all({:description_format => 'HTML', :updated_at => Time.now}, "plugin_name != 'manual' AND template_id IS NULL") - Rule.update_all({:description_format => 'MARKDOWN', :updated_at => Time.now}, "plugin_name = 'manual' OR template_id IS NOT NULL") end end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/582_update_existing_rules_description_format.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/582_update_existing_rules_description_format.rb new file mode 100644 index 00000000000..4f5fc6be52a --- /dev/null +++ b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/582_update_existing_rules_description_format.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 4.5 +# SONAR-5001 +# +class UpdateExistingRulesDescriptionFormat < ActiveRecord::Migration + + class Rule < ActiveRecord::Base + end + + def self.up + Rule.reset_column_information + Rule.update_all({:description_format => 'HTML', :updated_at => Time.now}, "plugin_name != 'manual' AND template_id IS NULL") + Rule.update_all({:description_format => 'MARKDOWN', :updated_at => Time.now}, "plugin_name = 'manual' OR template_id IS NOT NULL") + 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 2ad5a2f4874..57e0644406a 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 = 581; + public static final int LAST_VERSION = 582; public static enum Status { UP_TO_DATE, REQUIRES_UPGRADE, REQUIRES_DOWNGRADE, FRESH_INSTALL 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 555a2914acb..2e80275f139 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 @@ -251,6 +251,7 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('555'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('556'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('580'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('581'); +INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('582'); 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; -- 2.39.5