class

ActiveRecord::ConnectionAdapters::TableDefinition

v3.0.0 - Show latest stable - Superclass: Object

Represents the schema of an SQL table in an abstract way. This class provides methods for manipulating the schema representation.

Inside migration files, the t object in create_table and change_table is actually of this type:

  class SomeMigration < ActiveRecord::Migration
    def self.up
      create_table :foo do |t|
        puts t.class  # => "ActiveRecord::ConnectionAdapters::TableDefinition"
      end
    end

    def self.down
      ...
    end
  end

The table definitions The Columns are stored as a ColumnDefinition in the columns attribute.

Attributes

[RW]columns

Files

  • activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
  • activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb