Currently, when creating a migration and the user specifies an invalid option, the migration silently succeeds and does not notifiy the user that the option is meaningless.
Given this migration for postgres:
class CreatePost < ActiveRecord::Migration[5.0] def change create_table :posts do |t| t.text :description, limit: 5000 end end end
When we run this migration, the schema will be created, and everything appears to have succeeded. It will result in something like this:
ActiveRecord::Schema.define(version: 20160601201548) do create_table "posts", force: :cascade do |t| t.text "description", null: false end end
The schema is correct and does not impose a
limit: 5000 on the
description column. However, I find the developer experience to be confusing as it does not warn that there is no possible limit constraint on a
text column. This can lead to issues like a developer expecting a limit when there is none.
Raise an error where there are invalid options given in migrations. Instead of silently succeeding on
rake db:migrate, throw a
ActiveRecord::InvalidDatabaseConstaint or something similar. This way, the user is made aware of mistakes they may have made.
I am happy to work on this issue if there is consensus that this is a positive change. Please post your thoughts here! Thanks