blog.kirishikistudios.com

About Me   

Just another geek

twitter.com/satully:

    Getting started with PostgeSQL on Rails3

    Add these lines to Gemfile

    #PostgreSQL
    gem 'pg'
    

    Edit config/database.yml

    development:
      adapter: postgresql
      database: mydb
      pool: 5
      timeout: 5000
      username: postgres
      password: ***********
    

    Install gem, DB migration with rake

    Yamada-Naoyuki-MacBook-Pro:hello yamadanaoyuki$ bundle install
    Fetching gem metadata from https://rubygems.org/.........
    Enter your password to install the bundled RubyGems to your system: 
    Using rake (0.9.2.2) 
    Using i18n (0.6.0) 
    Using multi_json (1.3.6) 
    Using activesupport (3.2.8) 
    Using builder (3.0.0) 
    Using activemodel (3.2.8) 
    Using erubis (2.7.0) 
    Using journey (1.0.4) 
    Using rack (1.4.1) 
    Using rack-cache (1.2) 
    Using rack-test (0.6.1) 
    Using hike (1.2.1) 
    Using tilt (1.3.3) 
    Using sprockets (2.1.3) 
    Using actionpack (3.2.8) 
    Using mime-types (1.19) 
    Using polyglot (0.3.3) 
    Using treetop (1.4.10) 
    Using mail (2.4.4) 
    Using actionmailer (3.2.8) 
    Using arel (3.0.2) 
    Using tzinfo (0.3.33) 
    Using activerecord (3.2.8) 
    Using activeresource (3.2.8) 
    Using bundler (1.1.5) 
    Using coffee-script-source (1.3.3) 
    Using execjs (1.4.0) 
    Using coffee-script (2.2.0) 
    Using rack-ssl (1.3.2) 
    Using json (1.7.5) 
    Using rdoc (3.12) 
    Using thor (0.16.0) 
    Using railties (3.2.8) 
    Using coffee-rails (3.2.2) 
    Using jquery-rails (2.1.1) 
    Using libv8 (3.3.10.4) 
    Installing pg (0.14.0) with native extensions  // Here it comes!!
    Using rails (3.2.8) 
    Using sass (3.2.1) 
    Using sass-rails (3.2.5) 
    Using sqlite3 (1.3.6) 
    Using therubyracer (0.10.2) 
    Using uglifier (1.2.7) 
    Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
    

    Rake

    Yamada-Naoyuki-MacBook-Pro:hello yamadanaoyuki$ rake db:migrate
    ==  CreateBooks: migrating ====================================================
    -- create_table(:books)
    NOTICE:  CREATE TABLE will create implicit sequence "books_id_seq" for serial column "books.id"
    NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "books_pkey" for table "books"
       -> 0.0050s
    ==  CreateBooks: migrated (0.0051s) ===========================================
    
    

    Listing tables on psql console

    Yamada-Naoyuki-MacBook-Pro:hello yamadanaoyuki$ psql mydb
    psql (9.1.4)
    Type "help" for help.
    
    mydb=# \d
                    List of relations
     Schema |       Name        |   Type   |  Owner   
    --------+-------------------+----------+----------
     public | books             | table    | postgres
     public | books_id_seq      | sequence | postgres
     public | schema_migrations | table    | postgres
    (3 rows)
    
    
    — 9 months ago