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. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
DBC User wrote:> 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. >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. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Jun 12, 2:04 pm, Mohit Sindhwani <mo_m...-RxrYI66vbj0AvxtiuMwx3w@public.gmane.org> wrote:> DBC User wrote: > > I have followed the tutorial athttp://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. > > 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.- 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. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---