Tuesday, September 27, 2005

Database-agnostic schemas with migrations

Posted by admin

ActiveRecord::Schema.define(:version => 8) do
  create_table "authors" do |t|
    t.column "name", :string
    t.column "ip", :string
    t.column "book_id", :integer
  end
 
  create_table "books" do |t|
    t.column "name", :string
    t.column "url_name", :string
    t.column "existing_page_titles", :text
    t.column "premiere", :integer, :limit => 1, :default => "0"
  end
 
  create_table "pages" do |t|
    t.column "title", :string
    t.column "book_id", :integer
    t.column "created_at", :datetime
    t.column "updated_at", :datetime
  end
 
  create_table "versions" do |t|
    t.column "page_id", :integer
    t.column "author_id", :integer
    t.column "created_at", :datetime
    t.column "body", :text
    t.column "book_id", :integer
  end
end
</pre>

</code>