aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2014-12-10 17:08:14 +0100
committerJulien Lancelot <julien.lancelot@sonarsource.com>2014-12-10 17:08:22 +0100
commit6372fc6ff7e0f0251b510bc6fad3e14ccc13ed5b (patch)
tree92b510ba38f579cb1de0d460a50d6687763fbc74
parentd6dab555f5cdce8f7a213b78639cf46f7c9f470f (diff)
downloadsonarqube-6372fc6ff7e0f0251b510bc6fad3e14ccc13ed5b.tar.gz
sonarqube-6372fc6ff7e0f0251b510bc6fad3e14ccc13ed5b.zip
SONAR-5918 Fix migrations on users : Do not use callbacks because they're saving dates in long
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/db/migrate/011_create_administrator.rb6
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/db/migrate/088_create_default_users_and_groups.rb6
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/db/migrate/257_add_active_field_on_users.rb3
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/db/migrate/431_migrate_users_names.rb3
4 files changed, 12 insertions, 6 deletions
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/011_create_administrator.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/011_create_administrator.rb
index bf7c6211798..69b579ec831 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/011_create_administrator.rb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/011_create_administrator.rb
@@ -21,8 +21,10 @@ class CreateAdministrator < ActiveRecord::Migration
def self.up
# Do not use faux model here : the password must be encrypted
- User.create(:login => 'admin', :name => 'Administrator', :email => '', :password => 'admin',
- :password_confirmation => 'admin')
+ u = User.new(:login => 'admin', :name => 'Administrator', :email => '', :password => 'admin', :password_confirmation => 'admin',
+ :created_at => Time.now, :updated_at => Time.now)
+ # Skip before_create as it populate dates columns with a long value (see migrations 752 to 754)
+ u.send(:create_without_callbacks)
end
end
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/088_create_default_users_and_groups.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/088_create_default_users_and_groups.rb
index c84ee36c257..22060e26efb 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/088_create_default_users_and_groups.rb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/088_create_default_users_and_groups.rb
@@ -32,7 +32,8 @@ class CreateDefaultUsersAndGroups < ActiveRecord::Migration
admin=User.find_by_login('admin')
admin.groups<<administrators
- admin.save!
+ admin.updated_at = Time.now
+ admin.send(:update_without_callbacks)
end
def self.create_users
@@ -41,6 +42,7 @@ class CreateDefaultUsersAndGroups < ActiveRecord::Migration
# The user 'admin' is considered as a user
admin=User.find_by_login('admin')
admin.groups<<users
- admin.save!
+ admin.updated_at = Time.now
+ admin.send(:update_without_callbacks)
end
end
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/257_add_active_field_on_users.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/257_add_active_field_on_users.rb
index 600cc547847..e5a2758f739 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/257_add_active_field_on_users.rb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/257_add_active_field_on_users.rb
@@ -29,7 +29,8 @@ class AddActiveFieldOnUsers < ActiveRecord::Migration
User.reset_column_information
User.find(:all).each do |user|
user.active = true
- user.save
+ user.updated_at = Time.now
+ user.send(:update_without_callbacks)
end
end
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/431_migrate_users_names.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/431_migrate_users_names.rb
index 96d5b71fbdf..fc737725814 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/431_migrate_users_names.rb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/431_migrate_users_names.rb
@@ -33,7 +33,8 @@ class MigrateUsersNames < ActiveRecord::Migration
User.find(:all).each do |user|
if user.name.blank?
user.name = user.login
- user.save!
+ user.updated_at = Time.now
+ user.send(:update_without_callbacks)
end
end