Skip to content

Fix schema that has missing null:false due to incorrect migrations had `nil:false` instead of `null:false`

Issue

Some migrations say nil:false where they should say null:false, e.g.

20210818145118_add_name_type_to_names.rb:      t.string :oclc_number, nil:false, default: ''

The schema shows that null is not set, e.g., image

The following migrations may need to be fixed:

20210805164425_add_oclc_number_to_crdl.rb:    add_column :names, :oclc_number, :string, nil:false, default: ''
20210805164425_add_oclc_number_to_crdl.rb:    add_column :corporate_entities, :oclc_number, :string, nil:false, default: ''
20210805170526_add_legacy_data_to_crdl_tables.rb:    add_column :names, :legacy_data, :json, nil: false, default: {}
20210805170526_add_legacy_data_to_crdl_tables.rb:    add_column :corporate_entities, :legacy_data, :json, nil: false, default: {}
20210805170526_add_legacy_data_to_crdl_tables.rb:    add_column :events, :legacy_data, :json, nil: false, default: {}
20210818145118_add_name_type_to_names.rb:      t.string :oclc_number, nil:false, default: ''
20210818145118_add_name_type_to_names.rb:      t.json   :legacy_data, nil: false, default: {}

Note: see https://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html#method-i-change_column_null as a possible way to do this.

Edited by Seamus Narron