Rails 3.1, OS X 10.7.3, and PostgreSQL 9.1.3j
Table of contents
- 1. PostgreSQL must be used for Databases
- 2. Install PostgreSQL on OS X 10.7.3
- 3. Check the installed PostgreSQL
- 4. PostgreSQL rails project for Databases
- 5. Deploy web programs to Heroku
1. PostgreSQL must be used for Databases
The official Heroku homepage is opposed to sqlite3 for development and PostgreSQL for production.
2. Install PostgreSQL on OS X 10.7.3
First, check your OS x version. OS X comes with PostgreSQL starting from 10.7.
sw_vers -productVersion
To install the latest version of postgresql, you must delete the old version of the database. For details, refer to this article, which is actually a line of command:
curl http://nextmarvel.net/blog/downloads/fixBrewLionPostgres.sh | sh
It is strongly recommended that you use homebrew to install the database,
brew install postgresql
For installation details, refer to the official PostgreSQL wiki.
3. Check the installed PostgreSQL
Here are some official documents on basic database operations. You can use 'psql-l' to view some existing database lists.
4. PostgreSQL rails project for Databases
rails new myapp --database=postgresql
If you want to switch from a project that has used SQLite to a database, you must change config/database. yml to catch some catch. refer to the discussion on stackoverflow.
Then, 'createdb myapp_development' creates a PostgreSQL database and 'rake DB: migrate' creates a database schema and imports data to a local database. A simple test proves that the database and web programs can work seamlessly.
Do not forget the latest 'git commit 'code.
5. Deploy web programs to Heroku
Please refer to the official Heroku documentation to remind you not to forget to run 'heroku run rake DB: migrate'. Otherwise, the database is empty.
After deployment, run 'heroku open' to access the Web application homepage in a browser.
If a problem occurs when you open the website, you can view the log in 'heroku logs.