smugcloud
smugcloud

Reputation: 627

Create Postgres RDS with rake db:create:all

I have an app that I am migrating to Deis and want to use RDS for my Postgres instance. I have Postgres set up but if i run rake db:create:all from my local machine, configured to point to RDS, I get:

This task only modifies local databases. <db_name> is on a remote host.

Is there a way to create the DB from an existing migration or the schema.rb file?

Update 1 Here is the database.yml file. All environments inherit the default

default: &default
adapter: postgresql
encoding: utf8
pool: 5
username: <db user I created>
password: <PW>
host: <my_unique_host>.us-east-1.rds.amazonaws.com
port: 5432

Update 2 For the comment about just creating the DB then running db:migrate like normal, this is exactly the behavior I am not seeing. If I have the DB active and run rake db:migrate, the process completes and I am presented a new terminal line. No tables/columns are created.

Am I better off trying to do a local DB dump and restoring it into RDS?

Update 3: Solution I have resolved this and wanted to share my learnings:

  1. It appears that running the rake db:migrate command from a remote host was not working. This may be possible but I was not able to figure it out.
  2. What solved it was actually SSH'ing into the app container in the Deis cluster and running rake db:create and rake db:migrate. This ack'd back saying the table was created and I was able to verify in the psql prompt.

Hopefully this helps.

Upvotes: 0

Views: 2652

Answers (3)

Artur INTECH
Artur INTECH

Reputation: 7396

ActiveRecord::Tasks::DatabaseTasks::LOCAL_HOSTS << "192.168.1.1" # Replace with the IP you want to connect from

P.S. Keep in mind, it is a dirty hack which may stop working anytime, since it alters a constant.

Upvotes: 0

smugcloud
smugcloud

Reputation: 627

Update 3: Solution I have resolved this and wanted to share my learnings:

  1. It appears that running the rake db:migrate command from a remote host was not working. This may be possible but I was not able to figure it out.
  2. What solved it was actually SSH'ing into the app container in the Deis cluster and running rake db:create and rake db:migrate. This ack'd back saying the table was created and I was able to verify in the psql prompt.

Hopefully this helps.

Upvotes: 2

Zahid
Zahid

Reputation: 1830

You will have to do manually the part done by rake db:create:all[1], so connect to the DBMS and create the db by running command

CREATE DATABASE db_name CHARACTER SET utf8;

migration can be done in normal way via rake db:migrate

Upvotes: 2

Related Questions