I have 2 databases that I would like to combine. They both have the same schema.
The second database started with the same data as the first, but they diverged on a specific date.
The problem is that the ids for some of the tables continued to auto-increment from the same point so that both tables use the same ids for different data. I should also mention that the ids are used as foreign keys in other tables.
I was thinking that I could just add a value to every id in the second database to remove the conflicts. Is this an acceptable way to do this. If so, what is the best way to do that. If not, what would be a better way.
You can add an offset to all the tables’ primary and foreign key values, taking care that
Example updates statements:
This is an instance where creating your foreign keys with the
ON UPDATE CASCADEoption would have been very helpful. You would only have had to modify the primary key columns, and changes would propagate to tables referencing them as foreign keys.