migrateを使ってTableを作る

articleテーブルを作成しよう!中身は後で考えればいいや!

kenmituo@hoge ~/My Documents/Aptana Studio 3 Workspace/hoge
$ rails generate model article
      invoke  active_record
      create    db/migrate/20121116071134_create_articles.rb
      create    app/models/article.rb
      invoke    test_unit
      create      test/unit/article_test.rb
      create      test/fixtures/articles.yml

完成したマイグレートファイルを開く
db/migrate/20121116071134_create_articles.rb

class CreateArticles < ActiveRecord::Migration
  def change
    create_table :articles do |t|

      t.timestamps
    end
  end
end

ちょこっと編集

class CreateArticles < ActiveRecord::Migration
  def change
    create_table :articles do |t|
      t.string :name, :null=>false
      t.text :memo
      t.text :notice
      t.datetime :moved

      t.timestamps # created_at, updated_atを自動生成
    end
  end
end

カラムが多い、少ないは後でなんとでもなるからマイグレートを実行する

$ rake db:migrate