class ActiveRecord::Schema
support migrations, the two features being very similar.
ActiveRecord::Schema is only supported by database adapters that also
end
add_index :posts, :author_id
end
t.boolean :private, default: false
t.text :body
t.string :subject
t.integer :author_id, null: false
create_table :posts do |t|
add_index :authors, :name, :unique
end
t.string :name, null: false
create_table :authors do |t|
ActiveRecord::Schema.define do
Usage:
databases.
directly, so your applications can more easily support multiple
DSL. This means you can define tables, indexes, etc. without using SQL
Allows programmers to programmatically define a schema in a portable
= Active Record Schema
def self.define(info={}, &block)
...
ActiveRecord::Schema.define(version: 20380119000001) do
about the current schema (currently, only the schema's version):
The +info+ hash is optional, and if given is used to define metadata
+add_index+, etc.).
database definition DSL to build up your schema (+create_table+,
adapter are available within the block, so you can easily use the
Eval the given block. All methods available to the current connection
def self.define(info={}, &block) new.define(info, &block) end
def define(info, &block) # :nodoc:
def define(info, &block) # :nodoc: instance_eval(&block) unless info[:version].blank? initialize_schema_migrations_table connection.assume_migrated_upto_version(info[:version], migrations_paths) end end
def migrations_paths
ActiveRecord::Schema.new.migrations_paths
Returns the migrations paths.
def migrations_paths ActiveRecord::Migrator.migrations_paths end