Dropping the column and doing you inserts then putting an ID column back 
on with auto_increment will work, however if you currently have FK 
references to those ID's then you'll obviously break everything else if 
you had deleted some records previously.

-D

On 6/3/09 09:38, Ciaran wrote:
> *sigh* why do I always insist on posting mails to the wrong 
> addresses!?! :)  Since I posted this question, I 'solved' it by 
> performing an:
>
> Issue.connection.execute("ALTER TABLE issues AUTO_INCREMENT = 
> #{issue_id_i_want_next}")
> before each save, which is slow, but works, are there any better ideas 
> out there ? (Is dropping the column, re-creating without 
> auto_increment, doing all the saves, then putting the auto_increment 
> back on feasible? )
> - CJ.
>
>
> ---------- Forwarded message ----------
> From: *Ciaran* <[email protected] <mailto:[email protected]>>
> Date: Thu, Mar 5, 2009 at 8:42 AM
> Subject: Quick question regarding auto_increment and migrations
> To: North West Ruby User Group <[email protected] <mailto:[email protected]>>
>
>
> HI folks, Really quick one I hope, but my google-fu is letting me down :(
>
> Say I have an object 'Issue' that has an id column in it, currently 
> the rails app I'm using (Redmine) sets up the database tables so the 
> 'id' of Issue is an auto_increment field, so any time I do an 
> Issue.create(...) I get an issue with the latest and greatest id, ace, 
> all well and good ! :)
>
> But now I need to migrate an existing bug tracking system into redmine 
> (Bugzilla in this case).  One of my goals is to avoid changing our 
> issue ids from an external perspective, so I would like in my 
> migration rake task (as distinct from an ActiveRecord migration )  
> which I've found on t'interweb to be able to 'create' Issues with 
> specific ids.  If I was doing this in raw sql then I would probably 
> end up altering columns, can I do this rails-style ?
> - cj.
>
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"NWRUG" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nwrug-members?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to