aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2013-11-29 11:27:22 +0100
committerJulien HENRY <julien.henry@sonarsource.com>2013-11-29 11:27:47 +0100
commite820ac79c6365cf3b86d9a028cddeba64657db94 (patch)
tree158b53f0dffb82b40f3221093ab79ff489a160b9
parent9ead868b4282004368bc68b3eebde1899d84faef (diff)
downloadsonarqube-e820ac79c6365cf3b86d9a028cddeba64657db94.tar.gz
sonarqube-e820ac79c6365cf3b86d9a028cddeba64657db94.zip
SONAR-2447 Add migration script
-rw-r--r--sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java4
-rw-r--r--sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql1
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/db/migrate/463_add_administer_issues_perm.rb45
3 files changed, 48 insertions, 2 deletions
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 7af4c474942..55787c8b7fb 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 = 462;
+ public static final int LAST_VERSION = 463;
public static enum Status {
UP_TO_DATE, REQUIRES_UPGRADE, REQUIRES_DOWNGRADE, FRESH_INSTALL
@@ -96,7 +96,7 @@ public class DatabaseVersion implements BatchComponent, ServerComponent {
"user_roles",
"widgets",
"widget_properties"
- );
+ );
private MyBatis mybatis;
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 90092a55eb2..5c68dd607c0 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
@@ -186,6 +186,7 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('444');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('460');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('461');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('462');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('463');
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/463_add_administer_issues_perm.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/463_add_administer_issues_perm.rb
new file mode 100644
index 00000000000..b40de5c0750
--- /dev/null
+++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/463_add_administer_issues_perm.rb
@@ -0,0 +1,45 @@
+#
+# Sonar, entreprise quality control tool.
+# Copyright (C) 2008-2013 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.
+#
+
+#
+# Sonar 3.6
+#
+
+class AddAdministerIssuesPerm < ActiveRecord::Migration
+
+ class GroupRole < ActiveRecord::Base
+ end
+
+ class UserRole < ActiveRecord::Base
+ end
+
+ def self.up
+ group_roles=GroupRole.find(:all, :conditions => {:role => 'user'})
+ group_roles.each do |group_role|
+ GroupRole.create(:group_id => group_role.group_id, :role => 'issueadmin', :resource_id => group_role.resource_id)
+ end
+
+ user_roles=UserRole.find(:all, :conditions => {:role => 'user'})
+ user_roles.each do |user_role|
+ UserRole.create(:user_id => user_role.user_id, :role=> 'issueadmin', :resource_id => user_role.resource_id)
+ end
+ end
+
+end