]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5918 Fix creation of admin user
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Mon, 15 Dec 2014 08:56:28 +0000 (09:56 +0100)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Mon, 15 Dec 2014 08:56:28 +0000 (09:56 +0100)
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/011_create_administrator.rb

index 69b579ec831f19aa4520eb9888051c51ddcc011e..afadd45191a6922d0838e322ff4033da080f6b89 100644 (file)
 class CreateAdministrator < ActiveRecord::Migration
 
   def self.up
-    # Do not use faux model here : the password must be encrypted
-    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)
+    # Create the admin user with 'admin' password
+    ActiveRecord::Base.connection.execute("INSERT INTO USERS(LOGIN, NAME, EMAIL, CRYPTED_PASSWORD, SALT, CREATED_AT, UPDATED_AT, REMEMBER_TOKEN, REMEMBER_TOKEN_EXPIRES_AT) "+
+      "VALUES ('admin', 'Administrator', '', 'a373a0e667abb2604c1fd571eb4ad47fe8cc0878', '48bc4b0d93179b5103fd3885ea9119498e9d161b', '#{Time.now}', '#{Time.now}', null, null);")
   end
 
 end