change_table

change_table(table_name, options = {}) Instance Public methods A block for changing columns in table. # change_table() yields a Table instance change_table(:suppliers) do |t| t.column :name, :string, limit: 60 # Other column alterations here end The options hash can include the following keys: :bulk Set this to true to make this a bulk alter query, such as ALTER TABLE `users` ADD COLUMN age INT(11), ADD COLUMN birthdate DATETIME ... Defaults to false. Add a column chan

column_exists?

column_exists?(table_name, column_name, type = nil, options = {}) Instance Public methods Checks to see if a column exists in a given table. # Check a column exists column_exists?(:suppliers, :name) # Check a column exists of a particular type column_exists?(:suppliers, :name, :string) # Check a column exists with a specific definition column_exists?(:suppliers, :name, :string, limit: 100) column_exists?(:suppliers, :name, :string, default: 'default') column_exists?(:suppliers, :

columns

columns(table_name) Instance Public methods Returns an array of Column objects for the table specified by table_name. See the concrete implementation for details on the expected parameter values.

create_join_table

create_join_table(table_1, table_2, options = {}) Instance Public methods Creates a new join table with the name created using the lexical order of the first two arguments. These arguments can be a String or a Symbol. # Creates a table called 'assemblies_parts' with no id. create_join_table(:assemblies, :parts) You can pass a options hash can include the following keys: :table_name Sets the table name overriding the default :column_options Any extra options you want appende

create_table

create_table(table_name, options = {}) Instance Public methods Creates a new table with the name table_name. table_name may either be a String or a Symbol. There are two ways to work with create_table. You can use the block form or the regular form, like this: Block form # create_table() passes a TableDefinition object to the block. # This form will not only create the table, but also columns for the # table. create_table(:suppliers) do |t| t.column :name, :string, limit: 60 #

drop_join_table

drop_join_table(table_1, table_2, options = {}) Instance Public methods Drops the join table specified by the given arguments. See create_join_table for details. Although this command ignores the block if one is given, it can be helpful to provide one in a migration's change method so it can be reverted. In that case, the block will be used by create_join_table.

drop_table

drop_table(table_name, options = {}) Instance Public methods Drops a table from the database. Although this command ignores options and the block if one is given, it can be helpful to provide these in a migration's change method so it can be reverted. In that case, options and the block will be used by create_table.

index_exists?

index_exists?(table_name, column_name, options = {}) Instance Public methods Checks to see if an index exists on a table for a given index definition. # Check an index exists index_exists?(:suppliers, :company_id) # Check an index on multiple columns exists index_exists?(:suppliers, [:company_id, :company_type]) # Check a unique index exists index_exists?(:suppliers, :company_id, unique: true) # Check an index with a custom name exists index_exists?(:suppliers, :company_id, name

index_name_exists?

index_name_exists?(table_name, index_name, default) Instance Public methods Verifies the existence of an index with a given name. The default argument is returned if the underlying implementation does not define the indexes method, as there's no way to determine the correct answer in that case.

initialize_schema_migrations_table

initialize_schema_migrations_table() Instance Public methods Should not be called normally, but this operation is non-destructive. The migrations module handles this automatically.