-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changing pk column is not supported #238
Comments
This actually seems to work about as well as can be expected. Kart treats a feature as the same if it has the same primary key - all primary keys changing at once means everything old was deleted, and everything new is newly inserted. But, that's consistent with how kart works. |
This is not done, so closing this bug was an oversight. It is not possible to create such a commit by modifying the working copy, since there is a check preventing it. Attempting to modify the working copy to change the primary key column will fail at the commit-step with "Schema changes that involve primary key changes are not yet supported". Fixing this so that it works just as it does at import-time is of course possible, but will just need to take an extra step of explicitly deleting every pre-existing row from the model and explicitly adding every current row from the working copy during any commit which changes the primary key, since the DB operation which changed the primary key won't necessarily have caused every single row to be marked as dirty, but every row is dirty since it potentially (probably) has a new PK value and so needs to be deleted from one path and rewritten at another path. Note that changing primary key type from int to text or vice versa would also require that the path metadata is rewritten, which is also not yet implemented. |
Note that changing the PK column disconnects every past feature from every future feature, since the way we know that a feature is the same feature going forward is that it continues to have the same primary key value.
Fix for #238 - changing PK column (was not supported)
In the V2 structure, changing which column is the primary key means that every feature has to be deleted and rewritten in a new location.
Preliminary tests indicate this works to some extent, but definitely the diff shown for this change will be useless. We need to do more work if we want to support this properly.
The text was updated successfully, but these errors were encountered: