Skip to content

Migrations Should Raise an Exception for Unsupported Options #39230

@chadrschroeder

Description

@chadrschroeder

Steps to reproduce

It's easy to make a mistake in a migration and accidentally use an option that ends up being ignored.

Some options are supported by one command but not another:

create_table :things do |t|
  # Good - Creates column_a and an index
  t.integer :column_a, index: true
end

# Bad - Creates column_b but silently ignores the index option
add_column :things, :column_b, :integer, index: true

And typos are allowed. In this example from Stack Overflow, using precison instead of precision still created a numeric column without the precision defined.

Expected behavior

Migrations should raise an exception for unsupported options.

Actual behavior

Migration completes successfully without any error.

System configuration

Rails version: 6.0

Ruby version: 2.6

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions