Move initial setup from seeds.rb to bootstrap rake task

#515
This commit is contained in:
Artur Beljajev 2017-05-14 19:29:58 +03:00
parent 924e6c037a
commit ca6105a919
3 changed files with 12 additions and 34 deletions

View file

@ -45,6 +45,7 @@ Manual demo install and database setup:
cp config/application-example.yml config/application.yml # and edit it cp config/application-example.yml config/application.yml # and edit it
cp config/database-example.yml config/database.yml # and edit it cp config/database-example.yml config/database.yml # and edit it
bundle exec rake db:setup:all # for production, please follow deployment howto bundle exec rake db:setup:all # for production, please follow deployment howto
bundle exec rake:bootstrap
bundle exec rake assets:precompile bundle exec rake assets:precompile
### Apache with patched mod_epp (Debian 7/Ubuntu 14.04 LTS) ### Apache with patched mod_epp (Debian 7/Ubuntu 14.04 LTS)

View file

@ -1,36 +1,2 @@
# This file should contain all the record creation needed to seed the database with its default values. # This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
ActiveRecord::Base.transaction do
registrar = Registrar.create!(
name: 'Test',
reg_no: '1234',
street: 'test',
city: 'test',
state: 'test',
zip: '1234',
email: 'test@domain.tld',
country_code: 'US',
code: 'US1'
)
registrar.accounts.create!(account_type: Account::CASH, currency: 'EUR')
ApiUser.create!(
username: 'test',
password: 'testtest',
identity_code: '51001091072',
active: true,
registrar: registrar,
roles: ['super']
)
AdminUser.create!(
username: 'test',
email: 'test@domain.tld',
password: 'testtest',
password_confirmation: 'testtest',
country_code: 'US',
roles: ['admin']
)
end

11
lib/tasks/bootstrap.rake Normal file
View file

@ -0,0 +1,11 @@
desc 'Bootstraps production-like environment'
task :bootstrap do
AdminUser.create!(
username: 'demo',
email: 'demo@domain.tld',
password: 'demodemo',
password_confirmation: 'demodemo',
country_code: 'US',
roles: ['admin']
)
end