mrjgreen / db-sync

PHP library with command line tool for efficiently syncing tables between remote MySQL databases
MIT License
292 stars 91 forks source link

Question: The table ... does not have a primary key #15

Closed lfritsche closed 7 years ago

lfritsche commented 7 years ago

Hi @mrjgreen,

I'm really happy with your tool. It works really great by now. The only problem I experience is related to tables without a primary key.

There I get the following error: The table ... does not have a primary key

Is it necessary to have a primary key in case of comparing the tables? Or is there a possibility to sync without. It would also be ok if I could tell the tool to simply overwrite all the rows in target_db.table by source_db.table without comparing, if there is no primary key.

Thank you!

mrjgreen commented 7 years ago

This seems to be a duplicate of #7 Sorry to copy paste, but here is the response from the last time this was asked:

Firstly... Every table should probably have a key :)

The tool uses insert on duplicate key update to insert or update the row on the remote server. In theory if the table had a unique key that wasn't the primary it would work. But I'm not sure I see the reasoning.

What's the use case?