Preparing database schema fails with Peatio setup


#1

I added the root user and password to ~/.bashrc like so:

## mysql settings
export DATABASE_HOST=localhost         
export DATABASE_USER=root                       
export DATABASE_PASS=mypassword

and then executed source with the file:

$ source ~/.bashrc

but I’m getting this error when trying to setup Peatio, any idea what could be causing the script to fail when creating the MySQL schema?

deploy@host:~/peatio$ bin/setup
...
=== Preparing database schema ===
rake aborted!
ActiveRecord::NoDatabaseError: Unknown database 'peatio_production'
/home/deploy/.rvm/gems/ruby-2.5.1/gems/activerecord-4.2.10/lib/active_record/connection_adapters/mysql2_adapter.rb:23:in `rescue in mysql2_connection'
/home/deploy/.rvm/gems/ruby-2.5.1/gems/activerecord-4.2.10/lib/active_record/connection_adapters/mysql2_adapter.rb:9:in `mysql2_connection'
/home/deploy/.rvm/gems/ruby-2.5.1/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/connection_pool.rb:438:in `new_connection'
/home/deploy/.rvm/gems/ruby-2.5.1/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/connection_pool.rb:448:in `checkout_new_connection'
/home/deploy/.rvm/gems/ruby-2.5.1/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `acquire_connection'
/home/deploy/.rvm/gems/ruby-2.5.1/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `block in checkout'
/home/deploy/.rvm/gems/ruby-2.5.1/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `checkout'
/home/deploy/.rvm/gems/ruby-2.5.1/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `block in connection'
/home/deploy/.rvm/gems/ruby-2.5.1/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in `connection'
/home/deploy/.rvm/gems/ruby-2.5.1/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/connection_pool.rb:571:in `retrieve_connection'
/home/deploy/.rvm/gems/ruby-2.5.1/gems/activerecord-4.2.10/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
/home/deploy/.rvm/gems/ruby-2.5.1/gems/activerecord-4.2.10/lib/active_record/connection_handling.rb:87:in `connection'
/home/deploy/.rvm/gems/ruby-2.5.1/gems/activerecord-4.2.10/lib/active_record/railties/databases.rake:230:in `block (4 levels) in <top (required)>'
/home/deploy/.rvm/gems/ruby-2.5.1/gems/activerecord-4.2.10/lib/active_record/railties/databases.rake:229:in `open'
/home/deploy/.rvm/gems/ruby-2.5.1/gems/activerecord-4.2.10/lib/active_record/railties/databases.rake:229:in `block (3 levels) in <top (required)>'

Caused by:
Mysql2::Error: Unknown database 'peatio_production'
/home/deploy/.rvm/gems/ruby-2.5.1/gems/mysql2-0.4.10/lib/mysql2/client.rb:89:in `connect'
/home/deploy/.rvm/gems/ruby-2.5.1/gems/mysql2-0.4.10/lib/mysql2/client.rb:89:in `initialize'
/home/deploy/.rvm/gems/ruby-2.5.1/gems/activerecord-4.2.10/lib/active_record/connection_adapters/mysql2_adapter.rb:18:in `new'
/home/deploy/.rvm/gems/ruby-2.5.1/gems/activerecord-4.2.10/lib/active_record/connection_adapters/mysql2_adapter.rb:18:in `mysql2_connection'
/home/deploy/.rvm/gems/ruby-2.5.1/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/connection_pool.rb:438:in `new_connection'
/home/deploy/.rvm/gems/ruby-2.5.1/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/connection_pool.rb:448:in `checkout_new_connection'
/home/deploy/.rvm/gems/ruby-2.5.1/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `acquire_connection'
/home/deploy/.rvm/gems/ruby-2.5.1/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `block in checkout'
/home/deploy/.rvm/gems/ruby-2.5.1/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `checkout'
/home/deploy/.rvm/gems/ruby-2.5.1/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `block in connection'
/home/deploy/.rvm/gems/ruby-2.5.1/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in `connection'
/home/deploy/.rvm/gems/ruby-2.5.1/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/connection_pool.rb:571:in `retrieve_connection'
/home/deploy/.rvm/gems/ruby-2.5.1/gems/activerecord-4.2.10/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
/home/deploy/.rvm/gems/ruby-2.5.1/gems/activerecord-4.2.10/lib/active_record/connection_handling.rb:87:in `connection'
/home/deploy/.rvm/gems/ruby-2.5.1/gems/activerecord-4.2.10/lib/active_record/railties/databases.rake:230:in `block (4 levels) in <top (required)>'
/home/deploy/.rvm/gems/ruby-2.5.1/gems/activerecord-4.2.10/lib/active_record/railties/databases.rake:229:in `open'
/home/deploy/.rvm/gems/ruby-2.5.1/gems/activerecord-4.2.10/lib/active_record/railties/databases.rake:229:in `block (3 levels) in <top (required)>'
Tasks: TOP => db:schema:dump
(See full trace by running task with --trace)

#2

Hi @rraallvv,

try to run:

$> rake db:create db:migrate

and then

$> ./bin/setup

#3

Thanks, it did the trick. The installation finished without any errors.

I’m getting now a different error though:

=> Booting Puma
=> Rails 4.2.10 application starting in production on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Puma starting in single mode...
* Version 3.11.4 (ruby 2.5.0-p0), codename: Love Song
* Min threads: 5, max threads: 5
* Environment: production
* Listening on tcp://0.0.0.0:3000
Use Ctrl-C to stop

NoMethodError (undefined method `attributes' for nil:NilClass):
  app/controllers/application_controller.rb:50:in `set_gon'

38%20AM

But maybe it’s because I’m running Peatio without peatio-trading-ui @shai do you know if that could be the case?

Thanks again, it’s very much appreciated.


#4

I dropped the databases and created new ones as suggested by yivo in this issue

$ bin/init_config
$ bundle exec rake db:drop
$ bundle exec rake db:create
$ bundle exec rake db:migrate
$ bundle exec rake db:seed

Now the website opens showing the login page. Moving onto to the next issue :yum: