I'm getting really close to putting up my first app. However, I'm worried that because I'm so new, I won't know how to manage my database properly.
What's the best practice for managing a database on heroku? As in, backups for example. What if I really screw up something? Can I edit information like usernames, email addresses for users, etc directly in heroku or do I still do that from my terminal?
As Gene mentioned above, you will use pg backup to back up your db. You can do this manually, but you can also schedule backups.
You can easily access the rails console on heroku. Docs here: https://devcenter.heroku.com/articles/getting-started-with-rails4#console
Gook luck rolling your your first app!
Related
I use Aiven.io to manage a PSQL server, inside has multiple databases! Im using it from my rails app, so my rails app uses xxx_production, xxx_development etc.. But i dont remember creating xxx_optimization or metrics databases. The metrics one in particular is 50GB (My xxx_production is only 11GB so this is costing me a lot of extra money)
Is there any way to figure out who created these or why? My suspicion is there is some GEM im using in my rails app that could have created it to keep track of things? No idea what these databases are, and i would delete them but I do want to know what they are so i make sure im not breaking anything.
Thanks!
I've been searching and doing my research but I can't seem to find any articles directly talking about this. I have an art gallery rails app with around 6 models of different attributes, pieces of art, etc. When I make changes to their site and redeploy, will the databases also be reset? Or is Postgres and the rails app separate on Heroku?
I also read that someone takes all of their data and puts it into seed.rb then repopulates the databases with the seed data once it's redeployed? Does that sound right? Any insight would be very helpful. Thank you
If you're using a database, your data won't get lost on redeploys. Only the data which is stored in /tmp gets lost after a deploy is performed.
I'm going to assume you're using heroku postgres. In this case check out this, it's good to regularly create backups: https://devcenter.heroku.com/articles/heroku-postgres-backups
In seed.rb you should only add data which is necessary to set up the project, and nothing more. e.g. create an admin.
No data will be lost on redeploy to heroku until you intentionally do so.
Seed data only for populating some default database values in a rails application.
I am assuming you are uploading pictures in your application and they don't persist after deploy. So that true. Heroku does allow you to upload images to heroku. But they not persist after deployment.
Uploaded images persist for particular interval of time.
If this is the case with you try upload images to amazon s3 bucket, all uploading gem support that.
Thankfully this is a hypothetical, planning-ahead sort of a question. Can you restore part of a database using Heroku's backup addon, or otherwise? So, for instance, only restore records in all tables which have a client_id of 5?
No, that does not appear to be a feature included in the PG Backups addon provided by Heroku: http://devcenter.heroku.com/articles/pgbackups#restoring_from_a_backup
I need to edit data in my tables at Heroku, how can i do that with an IDE for PostgreSQL or some other solution to this? I'm really new to Heroku, so please can you guide me what's the best way around it.
thanks
To the best of my knowledge, Heroku does not offer direct access to the database. Does heroku console cut it for you? You can access the db through your models directly.
Otherwise you may want to look at how to import/export your database.
If you have access to a dedicated database, you will be able to take advantage of the "ingress" feature to get a raw connection to your database, compatible with all programs that need to speak over the Postgres wire protocol (examples include: psql, pgadmin, navicat, or Microsoft Excel with ODBC -- yes, really, and it's not half bad sometimes!)
But on shared databases you are somewhat out of luck at this time unless you somehow bounce your interactions off ruby and the pg gem.
Alternatively (if you're able to) use db:pull to bring the database locally, do the work locally and then db:push it back up.
Or more likely the easiest option is to do it from console (heroku console at prompt)
John.
for my rails app I use the typus gem which provides a very simple to implement fairly nice db admin interface to the application.
As a developer new to Rails, I'd like to know what checklists seasoned Rails developers might have of things to check before putting a Ruby on Rails web site live. I am thinking that you should probably remove generated views that you aren't using, remove controller actions you don't need, remove default routes and so forth.
I'm thinking there could be a list for performance and another for security..?
Security
Disable Apache script processing for the public directory.
filter_parameter_logging :password in application_controller.rb (and password_confirmation, credit card numbers etc.)
Make sure you require SSL for login, credit card processing
Performance
Cache everything you can, especially the front page
Look at this question: what-should-a-developer-know-before-building-a-public-web-site
Make sure you have a cron job backing up your database (and user's uploaded files!).
Replication is not backup.
RAID is not backup.
Databases can get corrupted. (Including by your own buggy code.)
Data can be hacked.
When that happens, you need a backup.
Not just a single copy: keep checkpoints in case your db gets corrupted and you don't notice before the backup runs.
Not just on the same server/drive as the database itself on case the drive is unrecoverably hosed.
Remember what happened to ma.gnolia.com
Don't let it happen to you.