I want to migrate a database to Heroku. The old database is exported to some JSON files, but now I don't know how to select the database in Heroku.
My issue is:
The data is always increasing, so in the future, there will be a lot of data. Which database is available for this?
I can only get JSON files from my old database. Can it be imported into the Heroku database?
My users are mostly in America. The database in Heroku whether lead the user's access speed slowly or not?
My project is using Ruby on Rails.
What should I do?
First of all, Heroku provides PostgreSQL as the default database. It might be the following reasons for use it.
PostgreSQL is a powerful, open source object-relational database system.
Heroku Postgres is the SQL database service run by Heroku that is provisioned and managed as an add-on.
Heroku Postgres is accessible from any language with a PostgreSQL driver including all languages and frameworks supported by Heroku: Java, Ruby, Python, Scala, Play, Node.js and Clojure.
For more you can refer this http://www.postgresql.org/about/advantages/.
It's better that you specify the database you currently use for your application. If you give more information, I will update my answer.
But firstly, reading the article Moving a Rails App to Heroku will help you a lot with moving the application to Heroku.
Heroku has addons from another provider. The only database they provide is PostgreSQL which is very nice and suitable for many kind of applications. It's just brilliant.
Read the mentioned article above.
If you create your application in Heroku, it will be located in the USA by default. I don't know if Heroku optimizes to the location of your application and addons or not, but normally if you have something slow in your application, it's your fault, not Heroku's.
Yes! Heroku loves Ruby on Rails
Related
I have a Rails app which is using Postgresql. I want to make a new Node + React Native app and I want to use the same database (usernames, passwords and other details will be shared).
I saw lots of sources which are explaining how to set up Postgresql on Node, but how do I set up an existing database? For the dev environment it is stored locally if I'm not mistaken.
You just need to use this package.
https://github.com/sequelize/sequelize
This is a connector for nodejs and postgresql.
But I suggest you do not use both of them handle database migration at the same time.
You can use rails to handle the migration. And just implement the database query in nodejs.
I would like to understand how I can start a rails app that is using NoSQL when I first make it and then when I deploy or have the project in production use Postgresql?
I'm really new to rails and have a project due in 4 days that requires me to have Postgresql once the app is deployed to Heroku.
Any information would be great, Thank you.
I truly Recommend you to use the same DB in development, testing and production environments. Otherwise you'll encounter many issues in terms of the schema file (generated by the migrations). It starts from simple strings length supported by PG or MySql (MySql limitations are bigger), and also for types like 'inet' in PG that should be converted to 'string' in MySql.
BTW- the inet type is created by Devise for 'user' (Which is the most popular gem for authentication) model! Even for that case you'll receive errors.
For a direct answer- you can simply change the database adapter in config/database.yml file.
But for my experience for some customers that explicitly asked for PG to MySql conversion (the opposite side, does not really matter), I would suggest using the same DB everywhere. Or else- dragons.
I'm very new to Rails.
I am confused about the development and production databases. I am using postgreSQL for all of my environments and heroku to host the site. I am able to push migrations and seeds to my production database on heroku. However I entered quite a bit of new data through the browser on localhost:3000. I spent a long time trying to figure out how to get that data to heroku but finally was successful by destroying then creating a new empty database and pushing my development database to it. Now my site on heroku is the same as localhost:3000 using rails server. I modified the database.yaml file so that the development and production databases are now the same name (the name of the development database). But I don't think that means that if I make changes to the development database through localhost:3000 they will automatically be changed on the heroku site. I am very confused about the colors (CRIMSON, MAROON) on heroku - are those different databases than what I specify in the yaml? And I don't know whether I should now be entering new data on the localhost:3000 site or the heroku site. Sorry if this is very amateur. Thank you.
You're getting confused with how Rails uses Databases
Let me explain:
Rails uses the MVC (Model View Controller) programming pattern to populate your applications with database data. Rails uses this pattern because it's the most efficient & extensible, and it works by taking a command from a user (clicks a link, inputs data), sends to the controller & performs the request on the model
The way all rails applications work is to take commands (which you define), and perform database operations with them & then repopulates the app with the new data
Rails is designed to work with a single database, and the database.yml file is there to specify which database that is (it's good practice to have different databases for development, staging & production -- for performance, efficiency & other issues)
This means that the database name is not important - what is important is to keep both databases up to date using the rake db:migrate system to give all databases the required columns to make your app work properly
In answer to your question, the data you have is going to be different for development & production. Your production environment is meant to be that "holy-of-holies" where everything is compiled & running efficiently
The production environment is meant to handle its own data, and should be populated through your application. The reason for development & production databases is to ensure you can "get things wrong" in the development environment before you try and apply it to the production db
If you tell us some more about your specific issues, we'll be able to give a much more refined answer
I've been looking for hosting services and I still don't know what kind of database is the most commom. It seems to be MySql and PostgreSql.
So, I'm not sure about how much traffic and data my website will have (it's just a project), but I would like to be prepared. I've worked in some projects with Oracle (PL/SQL) and I know something from MySql.
Thank you !
ps. 4 years later, I've been coding RoR mostly with PostgreSQL. SQLite by default when I need simple apps, but PostgreSQL otherwise.
One of the tenets of Rails is you shouldn't really care what database you're using: that's all abstracted for you.
So I would say go with the hosting provider that seems the overall best, and trust them to pick a good database.
In this case, as house9, I would recommend Heroku as an excellent overall service. Start with a small, free plan, scale up as needed. They use PostgreSQL by default, which has been entirely adequate in my experience.
I recommend Heroku for hosting
they require Postgres or if you want to go 'NoSql' - you can use MongoDB via the MongoHQ Heroku plug-in
http://heroku.com/
they offer a 'free' plan for small sites
Engine Yard is a trusted Rails host. They support MySQL, Postgres and MongoDB. Here is their list of supported technologies:
http://www.engineyard.com/technology/stack
On May 10th, they are hosting a demo on their cloud services.
MySQL is by far the most common free web database now a days, and is very common in Ruby on Rails Projects. Almost all linux hosting providers will give you mysql databases. Unless you have a specific reason to go elsewhere, it is a great place to start.
I have personally implemented a couple of RoR projects that used MySQL as the backend with no complaints.
I don't think there is any argument that MySQL is the most used. If you re looking for an enterprise class database, I say give DB2 a try. Just like MySQL, DB2 Express-C is free and optional support is available. DB2 is the only database that has support from the vendor. See http://antoniocangiano.com/2010/04/22/rails-db2-and-the-enterprise/.
I've been playing around with a rails app and showing the customer the updates by deploying it on heroku. Now the customer wants it set up on their on server...as a live site.
Heroku made deploying rails app so simple that I can not wrap my head around starting from scratch on a server.
To the experienced rails developers, what all is required to do this? My app uses postgresql and the server is a linux server. The customer claims that they have installed rails on the server.
Do I just have to install postgresql...create the DB...run migrations and voila? or is there other stuff involved as well. Up till now I was working with development section of database.yml...now it will pick up production?
Please give some pointers and/or links that explain the process.
I think capistrano web page has a decent how-to tutorial on where to start from.
Well, think about this: what does a rails app need?
Ruby
Rails (the version you used for your app!)
Ruby gems you use
Rails plugins you use
A database with proper login/password access
If you use the RAILS_ENV environment variable, and set it to production, you won't have to worry about it for the next steps, otherwise REMEMBER TO DO THIS FOR THE PRODUCTION ENVIRONMENT!
You can use rake db:schema:load to set up the database, and then.. Well, make sure it loads at startup automatically, make sure you have whatever preloaded data you need, make sure it's accessible from the outside, or from wherever it needs to be accessed.
I don't know if there is anything else you need for the rails app -- but of course, Capistrano is a good idea, to help you maintain the app :)
You probably need to decide which server software you're going to use first, because that's not something that Heroku give you a decision about. Anyway, it's easy because Phusion Passenger is the default choice in the Rails world now. Passenger is easy to set up—it has probably the best command-line setup program I've ever seen—and the documentation is excellent.
Slicehost have a whole series of articles that cover setting up the various bits you need for various flavours of Linux. They really are excellent:
http://articles.slicehost.com/search?q=rails
You'll also need to learn how to use Capistrano, which is what most people use for deploying Rails apps.
Is there a reason why you can't use Heroku as your production environment?
Edit:
If they're running a php webserver the chances are they already have a functioning apache server. If this is the case you should look in to installing passenger and setting up a new database.
At this point you can either copy up your application yourself, run your rake tasks to get everything setup and then sit back and relax, or you can spend the time to learn how to use capistrano so you can repeatably deploy your application.
I suggest the latter... capistrano really isn't that tricky and assuming your application set up is relatively sane the defaults should get you 90% of the way there.