aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/schema.rb
diff options
context:
space:
mode:
authorJamis Buck <jamis@37signals.com>2005-10-16 16:00:16 +0000
committerJamis Buck <jamis@37signals.com>2005-10-16 16:00:16 +0000
commitbcd0968a6f643efc016cb425995a58b7d9261de6 (patch)
treecb13075591d4b394a0dfc233953b8ae54bec4ab2 /activerecord/lib/active_record/schema.rb
parent1c057b7237c98d948b08b80c0ac403cda3028dab (diff)
downloadrails-bcd0968a6f643efc016cb425995a58b7d9261de6.tar.gz
rails-bcd0968a6f643efc016cb425995a58b7d9261de6.tar.bz2
rails-bcd0968a6f643efc016cb425995a58b7d9261de6.zip
Update/clean up ActiveRecord documentation (rdoc)
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2650 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record/schema.rb')
-rw-r--r--activerecord/lib/active_record/schema.rb38
1 files changed, 37 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/schema.rb b/activerecord/lib/active_record/schema.rb
index 8527d54697..c986380853 100644
--- a/activerecord/lib/active_record/schema.rb
+++ b/activerecord/lib/active_record/schema.rb
@@ -1,8 +1,44 @@
module ActiveRecord
- # TODO: Document me!
+ # Allows programmers to programmatically define a schema in a portable
+ # DSL. This means you can define tables, indexes, etc. without using SQL
+ # directly, so your applications can more easily support multiple
+ # databases.
+ #
+ # Usage:
+ #
+ # ActiveRecord::Schema.define do
+ # create_table :authors do |t|
+ # t.column :name, :string, :null => false
+ # end
+ #
+ # add_index :authors, :name, :unique
+ #
+ # create_table :posts do |t|
+ # t.column :author_id, :integer, :null => false
+ # t.column :subject, :string
+ # t.column :body, :text
+ # t.column :private, :boolean, :default => false
+ # end
+ #
+ # add_index :posts, :author_id
+ # end
+ #
+ # ActiveRecord::Schema is only supported by database adapters that also
+ # support migrations, the two features being very similar.
class Schema < Migration
private_class_method :new
+ # Eval the given block. All methods available to the current connection
+ # adapter are available within the block, so you can easily use the
+ # database definition DSL to build up your schema (#create_table,
+ # #add_index, etc.).
+ #
+ # The +info+ hash is optional, and if given is used to define metadata
+ # about the current schema (like the schema's version):
+ #
+ # ActiveRecord::Schema.define(:version => 15) do
+ # ...
+ # end
def self.define(info={}, &block)
instance_eval(&block)