Rake migrate HANGS


#1

I have been attempting to use migrations as a build a poll app.

I have created the initial file:

class CreateTablePollsAndPollOptions < ActiveRecord::Migration
def self.up
create_table polls do |table|
table.column ‘question’, :string
table.column ‘user_id’, :integer
table.column ‘start_time’, :datetime
table.column ‘end_time’, :datetime
end

create_table poll_options do |table|
  table.column 'poll_id', :integer
  table.column 'option_text', :string
  table.column 'option_order', :integer
end

execute 'ALTER TABLE poll_options ADD CONSTRAINT fk_polls FOREIGN 

KEY ( poll_id ) REFERENCES polls( id ) ’

end

def self.down
drop_table :polls
drop_table :poll_options
end
end


However, when I attempt to migrate:

rake migrate
The system just hangs.

So I attempted:

rake migrate --trace
(in /Users/intention/work/atlrugpoll_working)
** Invoke migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute migrate
^Crake aborted! ## I hit ctrl-d because it wasn’t working

/usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/vendor/mysql.rb:1079:in
read' /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/vendor/mysql.rb:1079:inread’
/usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/vendor/mysql.rb:499:in
read' /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/vendor/mysql.rb:492:incommand’
/usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/vendor/mysql.rb:339:in
stat' /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/mysql_adapter.rb:147:inactive?’
/usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:103:in
retrieve_connection' /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:20:inconnection’
/usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:107:in
retrieve_connection' /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:20:inconnection’
/usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/migration.rb:178:in
migrate' /usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/tasks/databases.rake:3 /usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/tasks/databases.rake:2:incall’
/usr/lib/ruby/gems/1.8/gems/rake-0.6.2/lib/rake.rb:202:in execute' /usr/lib/ruby/gems/1.8/gems/rake-0.6.2/lib/rake.rb:202:ineach’
/usr/lib/ruby/gems/1.8/gems/rake-0.6.2/lib/rake.rb:202:in execute' /usr/lib/ruby/gems/1.8/gems/rake-0.6.2/lib/rake.rb:180:ininvoke’
/usr/lib/ruby/gems/1.8/gems/rake-0.6.2/lib/rake.rb:1454:in run' /usr/lib/ruby/gems/1.8/gems/rake-0.6.2/lib/rake.rb:1454:ineach’
/usr/lib/ruby/gems/1.8/gems/rake-0.6.2/lib/rake.rb:1454:in run' /usr/lib/ruby/gems/1.8/gems/rake-0.6.2/bin/rake:7 /usr/bin/rake:18:inload’
/usr/bin/rake:18

I’m running Rails 1.0.0

I’d really appreciate suggestions on how to get Migrations working.

Bryan


#2

I"m still having the same issue with:

rake migrate

It just doesn’t work on my system.
I don’t know if it’s a problem with rake, or a problem with my Rails
setup.

I’m really not sure how to troubleshoot this problem and would
appreciate any help.

thanks,
Bryan


#3

Bryan W. wrote:

appreciate any help.
Two things:

  • You can go to script/console, and run the migrations manually. From
    memory, it goes like:

    $ script/console

    require ‘db/migrate/00n_name_of_migration’
    NameOfMigration.up

That’ll show you the precise failures. Rake has a tendency to swallow
the error messages.

  • Use the verbose_migrations plugin.

#4

Apparently, I’m missing some key understanding with how this should
work.

Attempted to run the migrations manually and failed.

===============

ruby script/console
Loading development environment.

require ‘db/migrate/001_add_a_table.rb’
=> true

001_add_a_table.up
SyntaxError: compile error
(irb):2: trailing `_’ in number
001_add_a_table.up
^
(irb):2: syntax error
001_add_a_table.up
^
from (irb):2

add_a_table.up
NameError: undefined local variable or method `add_a_table’ for
#Object:0xe79b8
from (irb):3

1_add_a_table.up
SyntaxError: compile error
(irb):4: trailing `_’ in number
1_add_a_table.up
^
(irb):4: syntax error
1_add_a_table.up
^
from (irb):4
from :0


#5

Possibly a dumb question, but does the database exist ? migrate will
not (as far as I know) perform the CREATE DATABASE or the GRANTs…

Alan.

Bryan W. wrote:

I have been attempting to use migrations as a build a poll app.

However, when I attempt to migrate:

rake migrate
The system just hangs.


#6

Bryan W. wrote:

Apparently, I’m missing some key understanding with how this should
work.

Attempted to run the migrations manually and failed.
Try AddATable.up (after requiring the file, of course…)


Alex


#7

Is there any way someone could post the trace of a successful migration?

My migration attempts always seem to stop at the same point.

rake migrate --trace
(in /Users/intention/work/atlrugpoll_working)
** Invoke migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute migrate
^Crake aborted!

/usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/vendor/mysql.rb:1079:in
read' /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/vendor/mysql.rb:1079:inread’
/usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/vendor/mysql.rb:499:in
read' /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/vendor/mysql.rb:492:incommand’
/usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/vendor/mysql.rb:339:in
stat' /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/mysql_adapter.rb:147:inactive?’
/usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:103:in
retrieve_connection' /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:20:inconnection’
/usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:107:in
retrieve_connection' /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:20:inconnection’
/usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/migration.rb:178:in
migrate' /usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/tasks/databases.rake:3 /usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/tasks/databases.rake:2:incall’
/usr/lib/ruby/gems/1.8/gems/rake-0.7.0/lib/rake.rb:232:in execute' /usr/lib/ruby/gems/1.8/gems/rake-0.7.0/lib/rake.rb:232:ineach’
/usr/lib/ruby/gems/1.8/gems/rake-0.7.0/lib/rake.rb:232:in execute' /usr/lib/ruby/gems/1.8/gems/rake-0.7.0/lib/rake.rb:202:ininvoke’
/usr/lib/ruby/gems/1.8/gems/rake-0.7.0/lib/rake.rb:195:in synchronize' /usr/lib/ruby/gems/1.8/gems/rake-0.7.0/lib/rake.rb:195:ininvoke’
/usr/lib/ruby/gems/1.8/gems/rake-0.7.0/lib/rake.rb:1719:in run' /usr/lib/ruby/gems/1.8/gems/rake-0.7.0/lib/rake.rb:1719:ineach’
/usr/lib/ruby/gems/1.8/gems/rake-0.7.0/lib/rake.rb:1719:in run' /usr/lib/ruby/gems/1.8/gems/rake-0.7.0/bin/rake:7 /usr/bin/rake:18:inload’
/usr/bin/rake:18

I’d like to see how much I’m missing in the process.

I don’t see any errors, it just doesn’t work.

frustrated,
Bryan


#8

I have no idea why this won’t work.

As I understand migrations, I’m attempting to call the method up on the
class CreateTablePollsAndPollOptions

Why am I not allowed to do this?

ruby script/console
Loading development environment.

require ‘db/migrate/001_add_a_table.rb’
=> true

AddATable.up
NameError: uninitialized constant AddATable
from
/usr/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:200:in
`const_missing’
from (irb):2

CreateTablePollsAndOptions.up
NameError: uninitialized constant CreateTablePollsAndOptions
from
/usr/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:200:in
`const_missing’
from (irb):3

The databases exist and I’m pretty sure that I set up the grants as
well.

As I understand it, if I did not have GRANTS, that would be showing an
error. At least, that’s what I seem to recall whenever I’ve attempted to
work with a db where I did not have GRANTS.

Thanks,
Bryan


#9

Finally fixed this issue.

Somewhere in the course of setting this schema up and failed to keep the
table name consistent in the schema.

I made sure all the table names were symbols and now the migrations
worked fine.


#10

I’m still unable to perform migrations.

I have also attempted to build the rforum app with rake migrate and it
failed as well.

Is there anyone that might understand what it going wrong here?

thanks,
Bryan