Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Merging Activerecord databases
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
giorgio  
View profile  
 More options Dec 12 2010, 5:31 pm
From: giorgio <george.pever...@gmail.com>
Date: Sun, 12 Dec 2010 14:31:33 -0800 (PST)
Local: Sun, Dec 12 2010 5:31 pm
Subject: Merging Activerecord databases
I want to merge several identical databases together.

There is obviously a problem in that the primary keys (id) will change
when imported and thus any foreign keys that refer to that id will
have to be changed as well.

This is all doable but I wonder if there are any plugins that would
make this sort of task easier?

Cheers
George


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Marnen Laibow-Koser  
View profile  
 More options Dec 13 2010, 11:00 am
From: Marnen Laibow-Koser <li...@ruby-forum.com>
Date: Mon, 13 Dec 2010 17:00:02 +0100
Local: Mon, Dec 13 2010 11:00 am
Subject: Re: Merging Activerecord databases
giorgio wrote in post #967970:

> I want to merge several identical databases together.

> There is obviously a problem in that the primary keys (id) will change
> when imported and thus any foreign keys that refer to that id will
> have to be changed as well.

> This is all doable but I wonder if there are any plugins that would
> make this sort of task easier?

Have you got foreign key constraints set up in your DBs?  If not, do so
now (and use Foreigner for your migrations), and make sure cascading
updates are on.  That will change the foreign keys when the primary keys
change.  Then renumber your primary keys somehow and merge the DBs.

Or at least that's one idea.  If it were just one table, I'd advise
doing an SQL dump and insert, but I'm not sure how that would work with
associated records.

> Cheers
> George

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org

--
Posted via http://www.ruby-forum.com/.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
giorgio  
View profile  
 More options Dec 13 2010, 7:18 pm
From: giorgio <george.pever...@gmail.com>
Date: Mon, 13 Dec 2010 16:18:49 -0800 (PST)
Local: Mon, Dec 13 2010 7:18 pm
Subject: Re: Merging Activerecord databases
Thanks for that idea Marnen,

I will take a look at Foreigner..

I think I would still have problems importing one database into the
other ...
Say I import "Clients" and all the ids get updated I would need to
update all the client_id values on say the adresses table.... but the
addresses table may not be imported yet so would not cascade update.

I think you are saying - Change all the primary keys on one of the
databases first and then do the merge and the keys will be in mutually
exclusive ranges..
I guess I would then possibly need to reset the sequences on the DB..

Whichever way I look has drawbacks!

Cheers
George


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Marnen Laibow-Koser  
View profile  
 More options Dec 13 2010, 8:01 pm
From: Marnen Laibow-Koser <li...@ruby-forum.com>
Date: Tue, 14 Dec 2010 02:01:13 +0100
Local: Mon, Dec 13 2010 8:01 pm
Subject: Re: Merging Activerecord databases
giorgio wrote in post #968193:

> Thanks for that idea Marnen,

> I will take a look at Foreigner..

> I think I would still have problems importing one database into the
> other ...
> Say I import "Clients" and all the ids get updated I would need to
> update all the client_id values on say the adresses table.... but the
> addresses table may not be imported yet so would not cascade update.

> I think you are saying - Change all the primary keys on one of the
> databases first and then do the merge and the keys will be in mutually
> exclusive ranges..

Right.

> I guess I would then possibly need to reset the sequences on the DB..

Yes.

> Whichever way I look has drawbacks!

How is resetting the sequences a big drawback?  It's easy and you'll
only need to do it once per DB.

> Cheers
> George

Best,
-- 
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org

Sent from my iPhone

--
Posted via http://www.ruby-forum.com/.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »