Hello, I''m trying to create a data migration for a new project I''m working on. I have numerous tables and would like to be able to populate the MySql db with test data. I get the data to appear in the tables but the linking (has_many, has_one, etc.) don''t seem to connect to each record properly. The area I''m talking about is the id field of each record. I can get the linking of the tables but the id of the records are starting from 15 of so each time. +----+-----------+---------+ | id | client_id | address | +----+-----------+---------+ | 33 | 1 | 1 | | 34 | 2 | 2 | | 35 | 3 | 3 | | 36 | 1 | 4 | +----+-----------+---------+ Now this db has been through a number of migrations, both forward and backwards (Version=0). Is this something I''m overlooking in Rails or is this a MySql problem? thanks Jeffrey --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Knowing what is wrong without seeing the migrations is difficult, but you can reset the auto_increment value on a table: ActiveRecord::Base.connection.execute "ALTER TABLE people AUTO_INCREMENT = 1;" It sounds like the auto_incrementing is continuing, but that shouldn''t happen if you''re completely dropping your tables by going down to database version 0. Hope that helps, Dan Manges http://www.dcmanges.com On Jul 21, 12:43 am, zbadone <jeff...-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote:> Hello, > > I''m trying to create a data migration for a new project I''m working > on. I have numerous tables and would like to be able to populate the > MySql db with test data. > > I get the data to appear in the tables but the linking (has_many, > has_one, etc.) don''t seem to connect to each record properly. The area > I''m talking about is the id field of each record. I can get the > linking of the tables but the id of the records are starting from 15 > of so each time. > > +----+-----------+---------+ > | id | client_id | address | > +----+-----------+---------+ > | 33 | 1 | 1 | > | 34 | 2 | 2 | > | 35 | 3 | 3 | > | 36 | 1 | 4 | > +----+-----------+---------+ > > Now this db has been through a number of migrations, both forward and > backwards (Version=0). > Is this something I''m overlooking in Rails or is this a MySql problem? > > thanks > Jeffrey--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
This happened to me once, I didn''t know what to do also :) But as "Dan Manges" said, if you drop your table the auto increment will reset to ZERO again. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---