Newbee rake migrate question


#1

with a simple table def.

class Objects < ActiveRecord::Migration
def self.up
create_table :objects do |table|
table.column :name, string
end

def self.down
drop_table :objects
end
end

when I run rake migrate, I get:

** Invoke migrate (first_time)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
rake aborted!
./db/migrate//001_objects.rb:10: parse error, unexpected $, expecting
kEND
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:140:in
load' /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:140:inload’
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/migration.rb:340:in
migration_classes' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/connection_adapters/mysql_adapter.rb:190:ininject’
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/migration.rb:339:in
migration_classes' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/migration.rb:327:inmigrate’
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/migration.rb:294:in
up' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/migration.rb:285:inmigrate’
/usr/local/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/tasks/databases.rake:4
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:387:in
execute' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:387:inexecute’
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:357:in invoke' /usr/local/lib/ruby/1.8/thread.rb:135:insynchronize’
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:350:in invoke' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:364:ininvoke_prerequisites’
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:999:in each' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:363:ininvoke_prerequisites’
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:356:in invoke' /usr/local/lib/ruby/1.8/thread.rb:135:insynchronize’
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:350:in invoke' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:1906:inrun’
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:1906:in `run’
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/bin/rake:7
/usr/local/bin/rake:18

from terminal

and

e[4;36;1mSQL (0.031305)e[0m e[0;1mCREATE TABLE schema_info
(version int(11))e[0m
e[4;35;1mSQL (0.004014)e[0m e[0mINSERT INTO schema_info (version)
VALUES(0)e[0m
e[4;36;1mSQL (0.000000)e[0m e[0;1mMysql::Error: Table
‘schema_info’ already exists: CREATE TABLE schema_info (version
int(11))e[0m
e[4;36;1mSQL (0.000000)e[0m e[0;1mMysql::Error: Table
‘schema_info’ already exists: CREATE TABLE schema_info (version
int(11))e[0m
e[4;35;1mSQL (0.000000)e[0m e[0mMysql::Error: Table ‘schema_info’
already exists: CREATE TABLE schema_info (version int(11))e[0m

in the log.

(of course schema_info didn’t exist until I ran rake.)

I’ve googled this quite a bit and see people talking about ruby 1.8.4
breaking things, but I don’t find a specific comment about the model
making.

Any directions?

Thanks, in advance.


#2

Lee H. wrote:

with a simple table def.

class Objects < ActiveRecord::Migration
def self.up
create_table :objects do |table|
table.column :name, string
end

I think your problem is here, you haven’t ended the “do” block.

Add another end, after you add the column.

David


#3

On 4/20/06, David removed_email_address@domain.invalid wrote:

Add another end, after you add the column.

David

Thank you. That got me further and I’ll look around before I ask about
the next error message.


Tech support: Click on the ‘my computer’ icon on to the left of the
screen.
Customer: Your left or my left?


#4

Lee :

class Objects < ActiveRecord::Migration
def self.up
create_table :objects do |table|
table.column :name, string
end

Thank you. That got me further and I’ll look around before
I ask about the next error message.

Be careful, Object is a reserved word.

http://ruby-doc.org/core/classes/Object.html

РJean-Fran̤ois.


#5

On 4/20/06, Lee H. removed_email_address@domain.invalid wrote:

I think your problem is here, you haven’t ended the “do” block.

Add another end, after you add the column.

David

Thank you. That got me further and I’ll look around before I ask about
the next error message.

A missing colon, and I’m good to go.

Thanks again.


Tech support: Click on the ‘my computer’ icon on to the left of the
screen.
Customer: Your left or my left?