Cristiano
Cristiano

Reputation: 3189

Insert records to Heroku database

How can I insert new records to Heroku database. I have successfully uploaded my application and database structure. Now I need to insert some records so it could work. I tried to use seeds.rb but without any success. db:push and db:seed don't give any success. The database is always empty. Is there any heroku tool available which I could use to see database structure and insert data?

Thank you.

Upvotes: 4

Views: 10302

Answers (2)

Urmish pachal
Urmish pachal

Reputation: 11

You can use below command for insert record to Heroku server

heroku run rails c

Example:-

suppose you have one table is employee and field are first_name.

Now open a command line and call this command

heroku run rails c

After call insert command

Employee.create(first_name: "admin")

Upvotes: 1

Vidya
Vidya

Reputation: 30310

You have a few options. You can run heroku run rake db:seed.

Or assuming Postgres, try

heroku pg:psql

And run your SQL commands from there. See here for more.

I was also able to connect my IDE to my databases on Heroku. I am using RubyMine, so it was a matter of using the right JDBC URL to make that happen.

Upvotes: 11

Related Questions