Performing a fresh install of 1.1RC1 fails on db:migrate due to an
issue in Puppet. The host this is on is CentOS 6.3, Puppet-2.6.17.
Using the mysql2 database adapter results in failed migration [1].
This issue is mentioned here, http://www.theforeman.org/issues/1350,
but does not seem to have been fixed in 1.1. Puppet does not seem to
have supported mysql2 as a database adapter till 2.7.10 2. The
offending lines in the code for 2.6.x 3 will result in MySQL
specific schema operations being skipped. This patch resolved the
issue for me:
— a/migrate/20090714132448_create_hosts.rb
+++ b/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
I am submitting a pull request right now as well as updating Redmine issue 1350.
[1]:
$ bundle exec rake db:migrate RAILS_ENV=production --trace
/usr/lib/ruby/gems/1.8/gems/ruby_parser-2.3.1/lib/ruby_parser_extras.rb:10:
warning: already initialized constant ENC_NONE
/usr/lib/ruby/gems/1.8/gems/ruby_parser-2.3.1/lib/ruby_parser_extras.rb:11:
warning: already initialized constant ENC_EUC
/usr/lib/ruby/gems/1.8/gems/ruby_parser-2.3.1/lib/ruby_parser_extras.rb:12:
warning: already initialized constant ENC_SJIS
/usr/lib/ruby/gems/1.8/gems/ruby_parser-2.3.1/lib/ruby_parser_extras.rb:13:
warning: already initialized constant ENC_UTF8
** 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
)
/usr/lib/ruby/gems/1.8/gems/mysql2-0.2.18/lib/active_record/connection_adapters/mysql2_adapter.rb:265:in
query' /usr/lib/ruby/gems/1.8/gems/mysql2-0.2.18/lib/active_record/connection_adapters/mysql2_adapter.rb:265:in
execute'
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.17/lib/active_record/connection_adapters/abstract_adapter.rb:202:in
log' /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.17/lib/active_support/notifications/instrumenter.rb:21:in
instrument'
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.17/lib/active_record/connection_adapters/abstract_adapter.rb:200:in
log' /usr/lib/ruby/gems/1.8/gems/mysql2-0.2.18/lib/active_record/connection_adapters/mysql2_adapter.rb:265:in
execute'
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.17/lib/active_record/connection_adapters/abstract/schema_statements.rb:348:in
add_index' /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:385:in
send'
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:385:in
method_missing' /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:361:in
say_with_time'
/usr/lib/ruby/1.8/benchmark.rb:293:in measure' /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:361:in
say_with_time'
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:381:in
method_missing' /usr/lib/ruby/site_ruby/1.8/puppet/rails/database/schema.rb:28:in
init'
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.17/lib/active_record/schema.rb:51:in
instance_eval' /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.17/lib/active_record/schema.rb:51:in
define'
/usr/lib/ruby/site_ruby/1.8/puppet/rails/database/schema.rb:8:in init' /usr/lib/ruby/site_ruby/1.8/puppet/util.rb:178:in
benchmark'
/usr/lib/ruby/1.8/benchmark.rb:308:in realtime' /usr/lib/ruby/site_ruby/1.8/puppet/util.rb:177:in
benchmark'
/usr/lib/ruby/site_ruby/1.8/puppet/rails/database/schema.rb:4:in init' /usr/share/foreman/db/migrate/20090714132448_create_hosts.rb:8:in
up_without_benchmarks'
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:314:in
send' /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:314:in
migrate'
/usr/lib/ruby/1.8/benchmark.rb:293:in measure' /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:314:in
migrate'
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:397:in
__send__' /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:397:in
migrate'
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:539:in
migrate' /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:615:in
call'
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:615:in
ddl_transaction' /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:538:in
migrate'
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:525:in
each' /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:525:in
migrate'
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:435:in
up' /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:417:in
migrate'
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.17/lib/active_record/railties/databases.rake:151
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:205:in call' /usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:205:in
execute'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:200:in each' /usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:200:in
execute'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:158:in
invoke_with_call_chain' /usr/lib/ruby/1.8/monitor.rb:242:in
synchronize'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:151:in
invoke_with_call_chain' /usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:144:in
invoke'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:116:in
invoke_task' /usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:94:in
top_level'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:94:in each' /usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:94:in
top_level'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:133:in
standard_exception_handling' /usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:88:in
top_level'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:66:in run' /usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:133:in
standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:63:in run' /usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/bin/rake:33 /usr/bin/rake:19:in
load'
/usr/bin/rake:19
Tasks: TOP => db:migrate
- Trey