Forum: Ruby on Rails rake migrate question!

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.
9eb3f9018980d0ad0feae770b2971d8b?d=identicon&s=25 DBC User (Guest)
on 2007-06-12 20:59
(Received via mailing list)
I have followed the tutorial at
http://godbit.com/article/beginners-guide-to-rails-part-1
to learn rake migrate. I created a database and have the database
information in my database.yml correct.

I ran ruby to generate migrate for table and in the ruby code I added
the following

class ContactDB < ActiveRecord::Migration --- was already there
  def self.up                                               --- was
already
     create_table "people" do |t|
        t.column "id", :integer
        t.column "name", :string
     end
  end

  def self.down
     drop_table :people
  end
end

when I ran 'rake migrate' I get an error like the following

== ContactDb: migrating ==========================
--- create_table("people")
rake aborted
MySql::Error: #420000You have an error in your SQL syntax: check the
manual that corresponds to your MySql server version for the right
syntax to use near '(11), 'name' varchar(255) DEFAULT NULL)
ENGINE=InnoDB' at line 1 CREATE TABLE people ('id' int(11) DEFAULT
NULL auto_increment PRIMARY KEY(11), 'name' varchar(255) DEFAULT NULL)
ENGINE=InnoDB

(See full trace by running task with --trace)

Could some one tell me what am I doing wrong?

Thanks.
34a7615f38496a5dafbb3e6b721c435e?d=identicon&s=25 Mohit Sindhwani (Guest)
on 2007-06-12 21:06
(Received via mailing list)
DBC User wrote:
>      create_table "people" do |t|
> when I ran 'rake migrate' I get an error like the following
>
> (See full trace by running task with --trace)
>
> Could some one tell me what am I doing wrong?
>
> Thanks.
>
Rails automatically adds the "id" field.  You do not need to (must not)
include that in your schema.

I don't think there are any other errors, but I'm sleepy :-D

Cheers
Mohit.
9eb3f9018980d0ad0feae770b2971d8b?d=identicon&s=25 DBC User (Guest)
on 2007-06-12 21:12
(Received via mailing list)
On Jun 12, 2:04 pm, Mohit Sindhwani <mo_m...@onghu.com> wrote:
> > already
>
> > ENGINE=InnoDB
> I don't think there are any other errors, but I'm sleepy :-D
>
> Cheers
> Mohit.- Hide quoted text -
>
> - Show quoted text -

Thank you so much, it worked. Now I remember, in the begining when I
using MySql I ran into the same problem.
Thanks again.
This topic is locked and can not be replied to.