On Fri, Mar 6, 2009 at 8:55 PM, Francis Fish <[email protected]> wrote:

> Probably too late now but I've noticed that restoring a database from a
> mysqldump doesn't have any problems with auto increment. I *think* that if
> you provide an ID it will use it. Failing that see what params mysqldump
> sets.
>
sorry I wasn't clear, I"m inserting records with ActiveRecord, usually
having it auto-gen the ids is great, but during this migration I want them
to be pre-ordained ;)
- Cj.


>
> F
>
> On Fri, Mar 6, 2009 at 9:51 AM, Ciaran <[email protected]> wrote:
>
>> Should be ok, the migration is one-time job, shouldn't be anything in
>> there :)  I'll try and try the alter table route then *crosses_fingers
>> - cj.
>>
>>
>>
>> On Fri, Mar 6, 2009 at 9:45 AM, Dave Spurr <[email protected]> wrote:
>>
>>>  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]>
>>> 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]>
>>>
>>>
>>> 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.
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>
>>
>>
>
>
> --
> Thanks and regards,
>
> Francis Fish
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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