Forum: Ruby on Rails rake migrate HANGS

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Bryan W. (Guest)
on 2006-02-16 20:53
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:in
`read'
/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:in
`command'
/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:in
`active?'
/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:in
`connection'
/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:in
`connection'
/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:in
`call'
/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:in `each'
/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:in `invoke'
/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:in `each'
/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:in `load'
/usr/bin/rake:18


I'm running Rails 1.0.0

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

Bryan
Bryan W. (Guest)
on 2006-02-17 18:14
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
Alex Y. (Guest)
on 2006-02-17 20:01
(Received via mailing list)
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.
Bryan W. (Guest)
on 2006-02-23 21:02
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
>>
Alex Y. (Guest)
on 2006-02-24 11:35
(Received via mailing list)
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
Alan F. (Guest)
on 2006-02-24 13:08
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.
Bryan W. (Guest)
on 2006-02-24 19:45
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
Bryan W. (Guest)
on 2006-02-24 20:26
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:in
`read'
/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:in
`command'
/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:in
`active?'
/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:in
`connection'
/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:in
`connection'
/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:in
`call'
/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:in `each'
/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:in `invoke'
/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:in `invoke'
/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:in `each'
/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:in `load'
/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
Bryan W. (Guest)
on 2006-02-27 18:40
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
Bryan W. (Guest)
on 2006-03-01 19:58
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.
This topic is locked and can not be replied to.