I'm working on a simple Rails (activeRecord based) application, and i'm testing in locally.
Now it's time to move online, but... do i need to insert all the records again in the app's db? I hope not!
Do you know a if is it possible to make a copy of my entire local db and import it in heroku?
Thanks!
erm, using the Heroku CLI
heroku db:push
job done, built into Heroku - will magically transpose your local DB whether it be sqlite, mysql, postgres to Heroku's shared postgresql db.
Try yaml_db gem
https://github.com/ludicast/yaml_db
Related
I have a rails app on heroku and the database I am using on it is Postgres.
I want to restore data from a pg dump file that I get from heroku on an app locally deployed on centOS 7 which has database of MSSQL. Is there any proper way to do it? The solutions I found are mostly windows based softwares. The app is on ruby on rails, any help would be great.
Since I learned Rails from Micheal Hartl's tutorial, all of my apps are set up to use SQLite3 in development, but Postgresql in production. This is causing problems with searches that work in development but not in production. From other Stack overflow questions, I've learned that using different databases in different environments is a bad idea.
I think that my best solution is to change the development database to Postgresql. But I'm sure that it's not as simple as adjusting the db name in my gemfile. What other changes will I need to make? What are some potential side effects that I should be aware of?
Thank you in advance for any insight.
You can do it two ways.
First Way :
Below are steps you can follow to convert sqlite to postgres.
Install postgres.
Change your Gemfile in your rails app and add PG gem.
Run bundle install.
Change the database.yml file to use postgres.
Run rake db:setup followed by rake db:migrate.
Everything should work as expected, Because with rake db:setup and rake db:migrate you will get identical database as before.
Second Way :
Now rails also provide way to directly change DB from one DB to another, You can check here.
Just use below command and you are done.
bin/rails db:system:change --to=postgresql
Copy Data as well :
If you want to copy data as well you can use yaml_db gem.
I have previously used apartment on Heroku, but now for a client, I am evaluating if it can be used on AWS. Is there a tutorial that shows how to use the apartment gem on Amazon AWS?
After reading https://aws.amazon.com/running_databases/ , I am not sure how to setup my database.
Should I install postgres on my instance or should I use RDS? Does the RDS allow creating multiple schemas if I use Postgres.
Thanks.
Apartment isn't tied to any hosting provider. It just uses Postgres (by default) for its db. Heroku vs AWS/RDS won't matter.
Sure, you can use RDS. Best to just try it out-- setup a new RDS instance with the aws console then plug the connection string into your rails database.yml config and then run your migrations (rake db:migrate) or load your schema (rake db:schema:load).
I want to implement capistrano in my ruby on rails project. I am using MongoDB as database .
I install capistrano gem.
capify .
[add] writing './Capfile'
[add] writing './config/deploy.rb'
[done] capified!
It gives me file deploy.rb inside the Config. What should i do inside. so where do i have to put mongoid.yml ? Working code is helpful for me to do or some hints is appreciable.
You should first be clear about why you want to implement capistrano :-)
Capistrano is a tool for making deployments easier - it allows for executing commands in multiple remote machines, via ssh.
For a default installation of a Rails App with mongodb, you don't need to have anything related to mongodb in the capistrano deploy.rb file.
You would add some mongodb stuff in this file if there is some mongodb related task that you want to accomplish every time the code is deployed to the remote servers.
Example: Here is a capistrano recipe example to synchronize local mongodb with production
I would recommend that you familiarize yourself with the basics of capistrano by watching the railscast episode on capistrano tasks.
Put mongoid.yml in /config, and type cap deploy in /.
Is it possible to backup Heroku database using cron jobs?
I tried putting the following line into cron.rake:
heroku pgbackups:capture --expire
However it didn't work. The line works when I run it from Terminal.
Can you help?
Check out the heroku_s3_backup gem, which packages up the code necessary to do this in a neat way.
The gem heroku_backup_task integrates directly with the free PG Backups add-on for Heroku.