Issue deploying with mina, cant migrate because db does not exist - ruby-on-rails

Im trying to deploy with Mina. I get stuck on database migrations because it say the database does not exist.
Your bundle is complete!
Gems in the groups development and test were not installed.
It was installed into ./vendor/bundle
-----> Migrating database
rake aborted!
ActiveRecord::NoDatabaseError: FATAL: database "production" does not exist
Run `$ bin/rake db:create db:migrate` to create your database
How can I create the database using mina or ssh? im using ubuntu 14.04 on digitalocean

Related

Heroku CI: Postgres error when trying to run tests in pipeline

I am attempting to use Heroku CI to run tests on my app prior to promoting to Production but it keeps failing during the building stage. I use a postgres database and have never configured Heroku's app.json file before.
App.json
{
"environments": {
"test": {
"addons":[
"heroku-postgresql"
],
"scripts": {
"test-setup": "gem install rubocop",
"test": "rubocop"
}
}
}
}
During the build I get to this point and then it fails:
Installing rails 7.0.3.1
Bundle complete! 19 Gemfile dependencies, 88 gems now installed.
Gems in the group 'development' were not installed.
Bundled gems are installed into `./vendor/bundle`
Bundle completed (39.27s)
Cleaning up the bundler cache.
-----> Clearing db:test:purge db:create db:structure:dump rake tasks
-----> Detecting rake tasks
-----> Preparing test database
Running: rake db:schema:load
rake aborted!
ActiveRecord::ConnectionNotEstablished: connection to server at "127.0.0.1", port 5432 failed: Connection refused
Is the server running on that host and accepting TCP/IP connections?
I will say that this app is connected to another app's database but I'm not sure why that would matter.

postgresql database password

I'm trying to build a rails app and deploy it to heroku, I'm very new to all of this, and I'm following this Getting started on Heroku I first installed heroku and postgresql, in the command line (windows 10) I run this command heroku login then rails new weather --database=postgresql then I cd into the weather folder, I run rails db:create and I get this error fe_sendauth: no password supplied Couldn't create 'weather_development' database. Please check your configuration. rails aborted! PG::ConnectionBad: fe_sendauth: no password supplied bin/rails:4:in `<main>' Tasks: TOP => db:create
what to configure, and where are the configurations files?
Installing postgresql locally on Ubuntu:
gemfile:
gem "pg"
console:
sudo apt install postgresql libpq-dev
sudo su postgres
createuser --interactive --pwprompt
username
password
start server:
rails db:create db:migrate
rails s
don't have sqlite and pg installed in one app at the same time.
if you have a postgresql database working in development environment, it will work in heroku for sure.
after pushing to heroku, don't forget to run heroku run rails db:migrate

Local sql database and heroku postgres database files differ, how to sync again? Ruby on Rails

I am currently doing the Ruby on Rails tutorial by Michael Hartl. Somewhere along the way I messed up my database. In my database file there is only 1 user, by the name of Bob.
Locally in cloud9 IDE, when I do 'rails console' and then do Users.first, I get a user with a name of "Bob".
However when I do 'heroku rails run console' and do Users.first, I get a user with a different name. (I probably changed the name somewhere along the way)
How do I get Heroku to see the correct local database file again? Should I clear the heroku database, then use pg:pull to pull the local sql database to heroku?
Not sure if you've gotten to Chapter 9 yet but section 9.3.2 of the current book deals with creating sample users. This is done through the db/seeds.rb file.
Running $ bundle exec rake db:reset then resets your DB followed by $ bundle exec rake db:seed to fill it with your new data.
You can run the same procedure on your production application with:
heroku pg:reset DATABASE
heroku run rake db:migrate
heroku run rake db:seed
It is, of course, also possible to transfer data between local and production databases with tools such as heroku-pg-transfer but that's a little advanced if you're only starting out, and I think somewhat unnecessary if you only have one user to transfer over.
Hope this helps.
You can use yaml_db gem to dump your local data to file and then upload it to heroku.
On your development machine:
rake db:data:dump
Then commit changes, push to heroku and run:
heroku run rake db:data:load

Precompiling assets with capistrano gives error during deployment

I am trying to deploy my rails app to a digital ocean server using the capistrano gem, and I'm getting the error :
The deploy has failed with an error: #<SSHKit::Command::Failed: RAILS_ENV= bundle exec rake assets:precompile exit status: 256
RAILS_ENV= bundle exec rake assets:precompile stdout: Nothing written
RAILS_ENV= bundle exec rake assets:precompile stderr: rake aborted!
ActiveRecord::AdapterNotSpecified: database configuration does not specify adapter
Even though the local config/database.yml and shared/config/database.yml file on the server are both configured, and have production databases set.
In case I run the rake db:create command on the server, it does create the database successfully. So, can't really find the issue.
Using rails 4.0.2, ruby 2.1.0, capsitrano 3.1.0
Sorry - I don't have the rep to comment.
It's a bit short on detail about your deploy configuration, you probably need to share.
RAILS_ENV= bundle exec rake assets:precompile stdout: Nothing written
Would suggest to me that there is no RAILS_ENV set. I don't think there is an issue with the database .yml
Infact - this post might be relevant: Capistrano 3, Rails 4, database configuration does not specify adapter

ROR code is not being deployed on linode with strange error

I have successfully installed and configured apache with passenger for deploying a rails application. I installed the 'mysql' and 'rails' gems successfully, but when I run any rake commands like
rake db:create
to create the database, I get this error
Illegal instruction
Any idea why?

Resources