diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2012-02-16 11:22:20 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2012-02-16 11:23:12 +0100 |
commit | 78e0a10a5b86370f47fb1d37e1c7b0560a2b8e48 (patch) | |
tree | 25917a337fb9dd91fe08c3ca528099ac2b4c84f3 | |
parent | bf92873a3ea24b077264512f18d50c027a4536d0 (diff) | |
download | sonarqube-78e0a10a5b86370f47fb1d37e1c7b0560a2b8e48.tar.gz sonarqube-78e0a10a5b86370f47fb1d37e1c7b0560a2b8e48.zip |
Fix db migration : do not use faux models for User
5 files changed, 20 insertions, 8 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/087_create_user_roles.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/087_create_user_roles.rb index a04aecba554..a30fe7b7bd1 100644 --- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/087_create_user_roles.rb +++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/087_create_user_roles.rb @@ -28,8 +28,4 @@ class CreateUserRoles < ActiveRecord::Migration add_index "user_roles", "user_id", :name => 'user_roles_user' add_index "user_roles", "resource_id", :name => 'user_roles_resource' end - - def self.down - drop_table :user_roles - end end diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/088_create_default_users_and_groups.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/088_create_default_users_and_groups.rb index 04cfe08ec21..881eca6a98c 100644 --- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/088_create_default_users_and_groups.rb +++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/088_create_default_users_and_groups.rb @@ -20,7 +20,16 @@ # sonar 2.0 class CreateDefaultUsersAndGroups < ActiveRecord::Migration + class GroupRole < ActiveRecord::Base + end + + class Group < ActiveRecord::Base + end + def self.up + Group.reset_column_information + GroupRole.reset_column_information + create_administrators create_users end diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/089_set_default_project_roles.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/089_set_default_project_roles.rb index 70cf1c1992f..2a7eeaec0fb 100644 --- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/089_set_default_project_roles.rb +++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/089_set_default_project_roles.rb @@ -19,8 +19,17 @@ # # sonar 2.0 class SetDefaultProjectRoles < ActiveRecord::Migration - + + class Group < ActiveRecord::Base + end + + class GroupRole < ActiveRecord::Base + end + def self.up + Group.reset_column_information + GroupRole.reset_column_information + administrators=Group.find_by_name('sonar-administrators') users=Group.find_by_name('sonar-users') diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/257_add_active_field_on_users.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/257_add_active_field_on_users.rb index 2a7da8f1afd..027bcab8f6e 100644 --- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/257_add_active_field_on_users.rb +++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/257_add_active_field_on_users.rb @@ -23,9 +23,6 @@ # class AddActiveFieldOnUsers < ActiveRecord::Migration - class User < ActiveRecord::Base - end - def self.up add_column 'users', 'active', :boolean, :null => true, :default => true diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/README.txt b/sonar-server/src/main/webapp/WEB-INF/db/migrate/README.txt index 1c3a2d850bb..8d58907d324 100644 --- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/README.txt +++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/README.txt @@ -28,6 +28,7 @@ RECOMMENDATIONS * Use faux models when touching rows (SELECT/INSERT/UPDATE/DELETE). See http://guides.rubyonrails.org/migrations.html#using-models-in-your-migrations for more details. + IMPORTANT : do not use faux models for User. The algorithm to encrypt passwords is required during migrations. class MyMigration < ActiveRecord::Migration # This is the faux model. It only maps columns. No functional methods. |