Defect #20176
closedDefect on user table migrate code
0%
Description
There´s a problem with the definitions of the column language of the table users.
The limit of the column size is set to 2, but when you using brazilian portuguese the
language acronym contains 5 letters, 'pt-BR' or 'pt-br'.
Then when i try to run bundle exec rake db:migrate an exception pops on the window.
A don´t know if this bug exists in another version or affects another language, but i almost break my head trying to find the solution.
create_table "users", :force => true do |t| t.column "login", :string, :limit => 30, :default => "", :null => false t.column "hashed_password", :string, :limit => 40, :default => "", :null => false t.column "firstname", :string, :limit => 30, :default => "", :null => false t.column "lastname", :string, :limit => 30, :default => "", :null => false t.column "mail", :string, :limit => 60, :default => "", :null => false t.column "mail_notification", :boolean, :default => true, :null => false t.column "admin", :boolean, :default => false, :null => false t.column "status", :integer, :default => 1, :null => false t.column "last_login_on", :datetime t.column "language", :string, :limit => 2, :default => "" t.column "auth_source_id", :integer t.column "created_on", :timestamp t.column "updated_on", :timestamp end
Solution¶
change to 5 the limit of the column language
t.column "language", :string, :limit => 5, :default => ""
Related issues
Updated by Toshi MARUYAMA over 9 years ago
- Related to Defect #19588: Invalid column size for language pt-BR added
Updated by Toshi MARUYAMA over 9 years ago
- Status changed from New to Needs feedback
- Priority changed from High to Normal
source:tags/3.0.3/db/migrate/044_set_language_length_to_five.rb
class SetLanguageLengthToFive < ActiveRecord::Migration
def self.up
change_column :users, :language, :string, :limit => 5, :default => ""
end
def self.down
raise IrreversibleMigration
end
end
Updated by Jean-Philippe Lang over 9 years ago
- Status changed from Needs feedback to Closed
- Resolution set to Invalid
Yes, the language column was changed to 5 character long few years ago, in migration 44 as shown by Toshi.
The fact that it's 2 character long and the settings table is missing means your database is broken or not up to date.