stripe-archive / mosql

MongoDB → PostgreSQL streaming replication
MIT License
1.62k stars 224 forks source link

Allow column renaming #15

Closed flavio closed 11 years ago

flavio commented 11 years ago

Allow to rename MongoDB's attributes during the import.

In order to implement this feature I took some commits from @andrewjshults' dot-syntax branch.

This pull request introduces the new configuration format described inside of issue #4 but stays backward compatible with the current one.

It will be possible to mix the two configuration formats in this way:

   - (destination):
     :source: (source)
     :type: (type)
   - (source & destination): (type)
nelhage commented 11 years ago

Hey -- thanks for this PR. This looks pretty good, and I'd be happy to take something like this.

Unfortunately, the code currently has some implicit assumptions that the SQL primary key is named _id, so your example of renaming _id doesn't work. I've pushed a commit to the pr-15 branch that contains a test case demonstrating the problem.

If you wanted to, I'd love to remove the implicit _id assumption and make this work, but as a stop-gap, I'd also just merge a version that adds an assertion that _id is not renamed, with the plan of improving the situation later.

flavio commented 11 years ago

Good points, I'm going to work on the issue you reported.

flavio commented 11 years ago

Everything should be working fine right now. Mosql handles properly also the tables with a primary key named in a different way.

nelhage commented 11 years ago

Thanks! Merged, with some slight cleanup and an extra test.