From 0628865b6b93b2fea535937cbda7ece9917a362c Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Tue, 12 Mar 2013 16:25:58 +0100 Subject: [PATCH] Separate last db migration in 3 migrations --- pom.xml | 2 +- .../core/persistence/DatabaseVersion.java | 2 +- .../org/sonar/core/persistence/rows-h2.sql | 2 + ..._add_status_language_and_dates_to_rules.rb | 12 ------ .../db/migrate/381_update_rules_status.rb | 42 +++++++++++++++++++ .../migrate/382_remove_enabled_from_rules.rb | 34 +++++++++++++++ 6 files changed, 80 insertions(+), 14 deletions(-) create mode 100644 sonar-server/src/main/webapp/WEB-INF/db/migrate/381_update_rules_status.rb create mode 100644 sonar-server/src/main/webapp/WEB-INF/db/migrate/382_remove_enabled_from_rules.rb diff --git a/pom.xml b/pom.xml index d01688dbd1a..1d6e57acce6 100644 --- a/pom.xml +++ b/pom.xml @@ -71,7 +71,7 @@ 1.5-RC1 - 1.2-RC2 + 1.2-SNAPSHOT 3.3.1 1.3.167 6.1.25 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 491e6dc2d7e..383c94f4fed 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 @@ -32,7 +32,7 @@ import java.util.List; */ public class DatabaseVersion implements BatchComponent, ServerComponent { - public static final int LAST_VERSION = 380; + public static final int LAST_VERSION = 382; 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 fbc8eb61309..e3aedb77854 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 @@ -150,6 +150,8 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('362'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('363'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('370'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('380'); +INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('381'); +INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('382'); 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-server/src/main/webapp/WEB-INF/db/migrate/380_add_status_language_and_dates_to_rules.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/380_add_status_language_and_dates_to_rules.rb index 4f4cd18a059..bb77ec02a88 100644 --- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/380_add_status_language_and_dates_to_rules.rb +++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/380_add_status_language_and_dates_to_rules.rb @@ -31,18 +31,6 @@ class AddStatusLanguageAndDatesToRules < ActiveRecord::Migration add_column 'rules', 'language', :string, :null => true, :limit => 20 add_column 'rules', 'created_at', :datetime, :null => true add_column 'rules', 'updated_at', :datetime, :null => true - - set_rule_status - - remove_column('rules', 'enabled') - end - - private - - def self.set_rule_status - Rule.reset_column_information - Rule.update_all({:status => 'READY', :created_at => Time.now}, ['enabled=?', true]) - Rule.update_all({:status => 'REMOVED', :updated_at => Time.now}, ['enabled=?', false]) end end diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/381_update_rules_status.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/381_update_rules_status.rb new file mode 100644 index 00000000000..33f23bdcfb0 --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/381_update_rules_status.rb @@ -0,0 +1,42 @@ +# +# Sonar, entreprise quality control tool. +# Copyright (C) 2008-2012 SonarSource +# mailto:contact AT sonarsource DOT com +# +# Sonar 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. +# +# Sonar 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 Sonar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 +# + +# +# Sonar 3.6 +# +class UpdateRulesStatus < ActiveRecord::Migration + + class Rule < ActiveRecord::Base + end + + def self.up + set_rule_status + end + + private + + def self.set_rule_status + Rule.reset_column_information + Rule.update_all({:status => 'READY', :created_at => Time.now}, ['enabled=?', true]) + Rule.update_all({:status => 'REMOVED', :updated_at => Time.now}, ['enabled=?', false]) + end + +end + diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/382_remove_enabled_from_rules.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/382_remove_enabled_from_rules.rb new file mode 100644 index 00000000000..dc160a1df62 --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/382_remove_enabled_from_rules.rb @@ -0,0 +1,34 @@ +# +# Sonar, entreprise quality control tool. +# Copyright (C) 2008-2012 SonarSource +# mailto:contact AT sonarsource DOT com +# +# Sonar 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. +# +# Sonar 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 Sonar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 +# + +# +# Sonar 3.6 +# +class RemoveEnabledFromRules < ActiveRecord::Migration + + class Rule < ActiveRecord::Base + end + + def self.up + remove_column('rules', 'enabled') + end + +end + -- 2.39.5