Skip to content
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

Allow to use natural primary/foreing keys for geoname objects. #217

Closed
cezio opened this issue May 6, 2020 · 4 comments
Closed

Allow to use natural primary/foreing keys for geoname objects. #217

cezio opened this issue May 6, 2020 · 4 comments

Comments

@cezio
Copy link

cezio commented May 6, 2020

Current default model implementation relies on a sequence as a primary key value for each model. This leads to a situation where two sibling deployments may have different IDs for the same objects, when cities_lights import was run in a different time frame or with different order of objects imported. An interchange of other data that relies on cities_light models between those two may be difficult in such situation.

A solution would be to support natural primary/foreign keys in models and use them in dump/load commands: https://docs.djangoproject.com/en/3.0/topics/serialization/#natural-keys

@dwasyl
Copy link

dwasyl commented Aug 14, 2020

+1 This would be really handy

@cezio
Copy link
Author

cezio commented Sep 15, 2020

Actually, wouldn't it be more feasible to use geoname_id as the primary key in each model? It is unique already (locally and from the data source), and it's portable between datasets.

@marianoeramirez
Copy link
Collaborator

marianoeramirez commented Sep 15, 2020

@cezio @dwasyl

I think that change the primary key will be something out of scope, for the complexity to do the migration for all the users of this library.

But I like the idea of using natural keys to dump and load the data into the system. On the development branch, you can test initial support of this feature. The feedback is appreciated!!

marianoeramirez added a commit that referenced this issue Nov 28, 2020
…217 (#245)

* fix: return to dbdiff and removed django2.0 from tests

* fix: fixture geoname_id instead of pk

* feat: type annotation

* fix: geoname id

* Builtins not required

* fix: changes to support natural key on tests (#244)

* pep8

* pep8

* CHANGELOG

Co-authored-by: marianoeramirez <Sosinformatico1990>
@marianoeramirez
Copy link
Collaborator

The solution to this problem is already live on version 3.9.

Still left write the documentation about this but closing this ticket for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants