Resolve “Could not dump table because of following FrozenError can’t modify frozen String: “false”

--

Photo by Markus Spiske on Unsplash

If you encountered this problem in your schema.rb file:

# Could not dump table "users" because of following FrozenError
# can't modify frozen String: "false"

Then, do the following:

  1. Create file config/initializers/prepare_column_options.rb with the following content:
module ActiveRecord
module ConnectionAdapters
module ColumnDumper
def prepare_column_options(column, types)
spec = {}
spec[:name] = column.name.inspect
spec[:type] = column.type.to_s
spec[:null] = 'false' unless column.null

limit = column.limit || types[column.type][:limit]
spec[:limit] = limit.inspect if limit
spec[:precision] = column.precision.inspect if column.precision
spec[:scale] = column.scale.inspect if column.scale

default = schema_default(column).dup if column.has_default?
spec[:default] = default unless default.nil?

spec
end
end
end
end

2. Run bundle exec rake db:schema:dump to recreate the schema.rb file.

And you will not see the following error in your schema.rb file anymore when you run rails db:migrate.

Source: Abdul Rehman at Stack Overflow.

--

--