Project

General

Profile

Refactor #13897

Explicitly set :limit on all DB migrations adding string columns

Added by Dominic Cleal almost 5 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
DB migrations
Target version:
Difficulty:
Triaged:
Bugzilla link:
Fixed in Releases:
Found in Releases:

Description

Rails 4.2 changes the default options for string columns in DB migrations, removing the default limit of 255 characters for PostgreSQL and SQLite adapters (it remains for MySQL, since that's the limit of a VARCHAR).

http://edgeguides.rubyonrails.org/4_2_release_notes.html#active-record-notable-changes

All of our existing DB migrations should be changed to set :limit => 255 on add_column .. :string calls if no limit is already set. This will ensure that a database created on earlier versions will be exactly the same as one created on Rails 4.2.

I don't think we should change the limits of any columns while doing this, just be explicit about what limit they currently have. If we want to change limits, that should be done as an additional DB migration so the behaviour across versions is consistent.


Related issues

Related to Katello - Refactor #14025: Specify string column limitsClosed2016-03-02
Blocks Foreman - Feature #13244: Upgrade Ruby on Rails to 4.2Closed2016-01-15

Associated revisions

Revision 3339b4d8 (diff)
Added by Dominic Cleal almost 5 years ago

fixes #13897 - explicitly set limit on string columns

Rails 4.2 removes the default limit of 255 characters on PostgreSQL and
SQLite DB adapters, causing migrations on empty DBs to create columns
with no limit. The MySQL adapter does not do this, as VARCHAR is
limited to 255 characters.

To keep the database schema identical no matter which version or adapter
is in use, specify the existing column limits explicitly on all
add_column calls. This doesn't intend to resize any columns, which
should be done with additional DB migrations.

History

#1 Updated by Dominic Cleal almost 5 years ago

#2 Updated by Dominic Cleal almost 5 years ago

  • Status changed from New to Assigned
  • Assignee set to Dominic Cleal

#3 Updated by The Foreman Bot almost 5 years ago

  • Status changed from Assigned to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/3261 added

#4 Updated by Dominic Cleal almost 5 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

#5 Updated by David Davis almost 5 years ago

#6 Updated by Dominic Cleal almost 5 years ago

  • Legacy Backlogs Release (now unused) set to 136

Also available in: Atom PDF