Project

General

Profile

Bug #1350

Mysql2::Error: BLOB/TEXT column 'title' used in key specification without a key length

Added by Telmo X over 10 years ago. Updated over 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Sam Kottler
Category:
DB migrations
Target version:
Difficulty:
Triaged:
No
Bugzilla link:
Pull request:
Fixed in Releases:
Found in Releases:

Description

I get this error when trying to migrate the DB for the first time (clean install)

some info in the system:

sh-3.2# /opt/comcast/platform/rubyee/bin/ruby -v
ruby 1.8.7 (2011-02-18 patchlevel 334) [x86_64-linux], MBARI 0x6770, Ruby Enterprise Edition 2011.03
sh-3.2# lsb_release -a
LSB Version:    :core-4.0-amd64:core-4.0-ia32:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-ia32:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-ia32:printing-4.0-noarch
Distributor ID:    RedHatEnterpriseServer
Description:    Red Hat Enterprise Linux Server release 5.6 (Tikanga)
Release:    5.6
Codename:    Tikanga
sh-3.2# 

I've tried to trace the offending migration, but my rails is a little "rusty" and I haven't been able to find where the index is being created.

My config file is standard, puppet reports have not been added (trying to stand up foreman prior to dealing with puppet)

--- 
#:modulepath: /etc/puppet/modules/
:tftppath: tftp/
#:rrd_report_url: report/
#:ldap: true
#your default puppet server - can be overridden in the host level
#if none specified, plain "puppet" will be used.
:puppet_server: dcavm-nb-18p.sys.comcast.net
#:unattended: false
#use the following setting to override the default 30 minutes puppet run interval - value must be in minutes
#:puppet_interval: 60
#:document_root: /var/www
sh-3.2# RAILS_ENV=production rake db:drop
(in /opt/comcast/platform/foreman/foreman)
sh-3.2# RAILS_ENV=production rake db:create
(in /opt/comcast/platform/foreman/foreman)
sh-3.2# RAILS_ENV=production rake db:migrate --trace
(in /opt/comcast/platform/foreman/foreman)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
==  CreateHosts: migrating ====================================================
rake aborted!
An error has occurred, all later migrations canceled:

Mysql2::Error: BLOB/TEXT column 'title' used in key specification without a key length: CREATE  INDEX `index_resources_on_title_and_restype` ON `resources` (`title`, `restype`)
/opt/comcast/platform/foreman/foreman/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:227:in `log'
/opt/comcast/platform/rubyee/lib/ruby/gems/1.8/gems/mysql2-0.2.6/lib/active_record/connection_adapters/mysql2_adapter.rb:314:in `execute'
/opt/comcast/platform/foreman/foreman/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:292:in `add_index'
/opt/comcast/platform/foreman/foreman/vendor/rails/activerecord/lib/active_record/migration.rb:352:in `send'
/opt/comcast/platform/foreman/foreman/vendor/rails/activerecord/lib/active_record/migration.rb:352:in `method_missing'
/opt/comcast/platform/foreman/foreman/vendor/rails/activerecord/lib/active_record/migration.rb:328:in `say_with_time'
/opt/comcast/platform/rubyee/lib/ruby/1.8/benchmark.rb:293:in `measure'
/opt/comcast/platform/foreman/foreman/vendor/rails/activerecord/lib/active_record/migration.rb:328:in `say_with_time'
/opt/comcast/platform/foreman/foreman/vendor/rails/activerecord/lib/active_record/migration.rb:348:in `method_missing'
/opt/comcast/platform/rubyee/lib/ruby/gems/1.8/gems/puppet-2.7.6/lib/puppet/rails/database/schema.rb:28:in `init'
/opt/comcast/platform/foreman/foreman/vendor/rails/activerecord/lib/active_record/schema.rb:47:in `instance_eval'
/opt/comcast/platform/foreman/foreman/vendor/rails/activerecord/lib/active_record/schema.rb:47:in `define'
/opt/comcast/platform/rubyee/lib/ruby/gems/1.8/gems/puppet-2.7.6/lib/puppet/rails/database/schema.rb:8:in `init'
/opt/comcast/platform/rubyee/lib/ruby/gems/1.8/gems/puppet-2.7.6/lib/puppet/util.rb:180:in `benchmark'
/opt/comcast/platform/rubyee/lib/ruby/1.8/benchmark.rb:308:in `realtime'
/opt/comcast/platform/rubyee/lib/ruby/gems/1.8/gems/puppet-2.7.6/lib/puppet/util.rb:179:in `benchmark'
/opt/comcast/platform/rubyee/lib/ruby/gems/1.8/gems/puppet-2.7.6/lib/puppet/rails/database/schema.rb:4:in `init'
./db/migrate//20090714132448_create_hosts.rb:8:in `up_without_benchmarks'
/opt/comcast/platform/foreman/foreman/vendor/rails/activerecord/lib/active_record/migration.rb:282:in `send'
/opt/comcast/platform/foreman/foreman/vendor/rails/activerecord/lib/active_record/migration.rb:282:in `migrate'
/opt/comcast/platform/rubyee/lib/ruby/1.8/benchmark.rb:293:in `measure'
/opt/comcast/platform/foreman/foreman/vendor/rails/activerecord/lib/active_record/migration.rb:282:in `migrate'
/opt/comcast/platform/foreman/foreman/vendor/rails/activerecord/lib/active_record/migration.rb:365:in `__send__'
/opt/comcast/platform/foreman/foreman/vendor/rails/activerecord/lib/active_record/migration.rb:365:in `migrate'
/opt/comcast/platform/foreman/foreman/vendor/rails/activerecord/lib/active_record/migration.rb:491:in `migrate'
/opt/comcast/platform/foreman/foreman/vendor/rails/activerecord/lib/active_record/migration.rb:567:in `call'
/opt/comcast/platform/foreman/foreman/vendor/rails/activerecord/lib/active_record/migration.rb:567:in `ddl_transaction'
/opt/comcast/platform/foreman/foreman/vendor/rails/activerecord/lib/active_record/migration.rb:490:in `migrate'
/opt/comcast/platform/foreman/foreman/vendor/rails/activerecord/lib/active_record/migration.rb:477:in `each'
/opt/comcast/platform/foreman/foreman/vendor/rails/activerecord/lib/active_record/migration.rb:477:in `migrate'
/opt/comcast/platform/foreman/foreman/vendor/rails/activerecord/lib/active_record/migration.rb:401:in `up'
/opt/comcast/platform/foreman/foreman/vendor/rails/activerecord/lib/active_record/migration.rb:383:in `migrate'
/opt/comcast/platform/foreman/foreman/vendor/rails/railties/lib/tasks/databases.rake:112
/opt/comcast/platform/rubyee/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/opt/comcast/platform/rubyee/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/opt/comcast/platform/rubyee/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/opt/comcast/platform/rubyee/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/opt/comcast/platform/rubyee/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/opt/comcast/platform/rubyee/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/opt/comcast/platform/rubyee/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/opt/comcast/platform/rubyee/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/opt/comcast/platform/rubyee/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
/opt/comcast/platform/rubyee/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/opt/comcast/platform/rubyee/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
/opt/comcast/platform/rubyee/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/opt/comcast/platform/rubyee/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/opt/comcast/platform/rubyee/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
/opt/comcast/platform/rubyee/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
/opt/comcast/platform/rubyee/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/opt/comcast/platform/rubyee/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/opt/comcast/platform/rubyee/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
/opt/comcast/platform/rubyee/bin/rake:19:in `load'
/opt/comcast/platform/rubyee/bin/rake:19
sh-3.2# 

Associated revisions

Revision dbdc8726 (diff)
Added by Trey Dockendorf over 9 years ago

- Allows mysql2 usage with Puppet < 2.7.10 - Fixes #1350

History

#1 Updated by Telmo X over 10 years ago

I forgot to add that this is foreman 0.4 from http://theforeman.org/attachments/download/298/foreman-0.4.tar.bz2 because I don't have a standard bury installation I can't instal the rpm

#2 Updated by Ohad Levy over 10 years ago

  • Status changed from New to Feedback

tracing it back to db/migrate/20090714132448_create_hosts.rb line 8 seems to be related to puppet internals.

I would suggest try with mysql gem not mysql2 ( i never tried it with mysql2).

check the version of active record that you have installed, maybe its too new for puppet.

#3 Updated by Telmo X over 10 years ago

changing from mysql2 to mysql did the trick. maybe something worth documenting.

#4 Updated by Ohad Levy over 10 years ago

  • Target version deleted (0.4.1)

according to http://stackoverflow.com/questions/5255234/is-it-possible-to-use-gem-mysql2-with-rails-2-3 (and many others) rails 2.3.x might have a few issues with the mysql2 gem.

since we already moved to rails3 (in the develop branch), if you are interested, you could give it another try.

Thanks

#5 Updated by Ohad Levy about 10 years ago

can we close this one?

thanks

#6 Updated by Sam Kottler over 9 years ago

  • Status changed from Feedback to Closed
  • Assignee set to Sam Kottler
  • Target version set to 1.1

This is fixed in the develop branch now and slated for release in 1.1. Thanks!

#7 Updated by Trey Dockendorf over 9 years ago

  • Status changed from Closed to Assigned

I just ran into this with 1.1RC1. This fixed it for me. See https://groups.google.com/d/topic/foreman-users/NlJzvScgZZ8/discussion

diff --git a/db/migrate/20090714132448_create_hosts.rb b/db/migrate/20090714132448_create_hosts.rb
index e7e7923..f029466 100644
--- a/db/migrate/20090714132448_create_hosts.rb
+++ b/db/migrate/20090714132448_create_hosts.rb
@@ -4,7 +4,7 @@ class CreateHosts < ActiveRecord::Migration
     # we are only creating the full database if the hosts table doesn't exists, if it does, we assume that store config is already configured
     unless Host.table_exists?
       require 'puppet/rails/database/schema'
-      Puppet[:dbadapter]= ActiveRecord::Base.configurations[RAILS_ENV]["adapter"]
+      Puppet[:dbadapter]= ActiveRecord::Base.configurations[RAILS_ENV]["adapter"].sub("mysql2", "mysql")
       Puppet::Rails::Schema.init
       Puppet::Rails.migrate()
     end

#8 Updated by Anonymous over 9 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

Also available in: Atom PDF