Project

General

Profile

Actions

Defect #20176

closed

Defect on user table migrate code

Added by Jonatas Wesley Gonçalves over 9 years ago. Updated over 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Database
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Invalid
Affected version:

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

Related to Redmine - Defect #19588: Invalid column size for language pt-BRClosed

Actions
Actions #1

Updated by Jonatas Wesley Gonçalves over 9 years ago

I´m using Postgre SQL 9.4

Actions #2

Updated by Toshi MARUYAMA over 9 years ago

  • Related to Defect #19588: Invalid column size for language pt-BR added
Actions #3

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
Actions #4

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.

Actions

Also available in: Atom PDF