2 # Allows programmers to programmatically define a schema in a portable
3 # DSL. This means you can define tables, indexes, etc. without using SQL
4 # directly, so your applications can more easily support multiple
9 # ActiveRecord::Schema.define do
10 # create_table :authors do |t|
11 # t.string :name, :null => false
14 # add_index :authors, :name, :unique
16 # create_table :posts do |t|
17 # t.integer :author_id, :null => false
20 # t.boolean :private, :default => false
23 # add_index :posts, :author_id
26 # ActiveRecord::Schema is only supported by database adapters that also
27 # support migrations, the two features being very similar.
28 class Schema
< Migration
29 private_class_method
:new
31 # Eval the given block. All methods available to the current connection
32 # adapter are available within the block, so you can easily use the
33 # database definition DSL to build up your schema (+create_table+,
36 # The +info+ hash is optional, and if given is used to define metadata
37 # about the current schema (currently, only the schema's version):
39 # ActiveRecord::Schema.define(:version => 20380119000001) do
42 def self.define(info
={}, &block
)
45 unless info
[:version].blank
?
46 initialize_schema_migrations_table
47 assume_migrated_upto_version info
[:version]