How do I sync a local rails database with a remote database? - ruby-on-rails

I've used Taps before on Heroku, but what is a good solution on non-heroku rails apps?

You could create a capistrano task/s to mysqldump on the source database, gzip the file, then scp it to the destination and execute the mysql script there to import.

I wrote a Capistrano recipe some time ago to sync a MySQL database and files between different environments: https://gist.github.com/111597

OK, there are some things you need to keep in mind. If you are using SQlite for development and MySQL / Postgre for production on the server, then sinking is almost impossible. On the contrary if you are using the same DB engines you can use administrator interface like MySQL administrator on your desktop and generate a backup file and upload it to server and vice versa.
May hosting providers provide PHPMyAdmin to take backups and restore it on the server.

Related

Connecting Rails to AWS MySQL database

I've recently created a rails app. I pushed the initial files onto github.
My problem is that I want to connect my rails app to AWS in order to use a MySQL database. I keep seeing tutorials on EC2 and Beanstalk, but I am not sure which one I should use. I have all the drivers needed for ruby through the gem installations.
I'm looking to figure out the main differences between Beanstalk and created a MySQL instance as well as what to put in my database.yml file in my rails app to connect to a database. Thank you in advance!
Just to give an idea, after you provision/create your instance on AWS (EC2 or wherever), you will then push your app's code to that remote server somewhere. You can do it manually via scripts, or you can use Capistrano for this. Once your app is deployed to the server, you need to connect to the server via SSH and manually edit the config/database.yml file to point to the staging/production MySQL database. (I'm generalizing, but I think you just need a step in the right direction.)

Are all my Ruby files in my Rails project stored on the server I specify? (eg. Puma, Webrick)

When I enter a URL into my browser, and it sends a request to the server (in this case, the host is salty-headland-18854.herokuapp.com), are all my Rails files stored at this host?
How does Puma come into play? I understand Puma to be a web server and I've included its gem. What is the distinction here between the host and Puma?
Does Heroku have a bunch of physical computers somewhere, that house my literal .rb files?
Visual of my question
It depends on the files, but pretty much the answer is yes. Heroku pulls down your app from the git repository specified (or you push it to Heroku's git repository) and Heroku has all the files from that. Without a security exploit, no one is able to access their source.
You can think of a Heroku Dyno as a Linux server with the complete Rails application. When it is launched for the first time, a linux server is built and the Rails application copied to it and the app server launched.
You code actually lives in the Github repository you have linked to Heroku. Persistant data is stored either in the database or an external file service such as S3.
It is possible to run commands on the Dynos using heroku run
Reference

ejabberd - Disable MySQL without recompiling

I have an ejabberd application in production. I've been using MySQL for a couple of month, but now I've decided to migrate to a different db (I've created a custom module which I have in production). The problem is that even when no module is setup with "dbtype: mysql", ejabberd needs the odbc configuration to start, and creates the connection to mysql. I want to disable mysql.
I know I can recompile the code without the --enable-mysql flag, but I'm wondering if there is a way to stop ejabberd for trying to connect to mysql without recompiling.
Thanks!
You have something wrong in your configuration. MySQL can be disabled by not configuring MySQL in the configuration. Maybe you have configured default database backend to be MySQL.

How do I deploy my rails app to Heroku using an existing SQL database?

I have an existing MySQL database and would like to build a Rails app on top of it. How do I deploy my app to Heroku but still use my existing database instead of the default PostgreSQL database?
EDIT
Rephrasing the question slightly (formerly, it was "Is it possible to deploy...").
Yes. You can configure your application any way you like including specifying a non-Heroku database in your config file, and including using the default Heroku paradigm of using environment variables for config but with manually set database URLs in the environment variables.
You can either continue hosting your MySQL database separately, or migrate your data to a MySQL database hosted within the Heroku platform, like ClearDB (provided as a Heroku add-on).
Yes, although Heroku recommends that you use PostgreSQL, it is possible to migrate MySQL to Postgres with their service. They have an article in their docs for just such a scenario: https://devcenter.heroku.com/articles/heroku-mysql
They recommend you first install the http://rubygems.org/gems/mysql2psql gem
If your needs are MySQL specific and you have to use heroku clearDB has and addon https://addons.heroku.com/cleardb that you can use with your heroku app.

Use Heroku DB into Engine Yard

I am using postgresql database for my Heroku Application.
I have very large database on AmazonAws as heroku not providing the Postgresql Database.
Now my client want to switch to EngineYard from Heroku.
Can i use same database (w/o taking backup and then reload) for my application on the EngineYard?
If YES
How can i use or steps for using the Existing AmazonAws Database with the new EngineYard Application.
You can, but only if you are using a dedicated database. From the Heroku database FAQ
Shared Database
No, connecting to your database from machines outside of Heroku is not
supported. We recommend that you encapsulate data access in an API to
manipulate it.
Dedicated Database
It's possible to connect to our dedicated databases using our
pg:ingress feature. Please see using the PG console for more
information.
The database connection string is available in the DATABASE_URL config. You can run
$ heroku config --long
to view it. However, it won't probably work if you use a shared database because it seems connection is restricted to the Heroku net.
Surely this is just a case of getting the correct connection credentials for the DB regardless of where it's hosted?
For instance, if the DB is on Heroku, then ENV['DATABASE_URL'] give you everything you need. All these details then go in your database.yml as normal (assuming you're using ActiveRecord)
For the record, Heroku do provide Postgres and it's part of their core business.

Resources