Skip to content
This repository has been archived by the owner on Jun 21, 2021. It is now read-only.

GeoName should not have an autoincrementing primary key #14

Open
jace opened this issue Nov 5, 2015 · 4 comments
Open

GeoName should not have an autoincrementing primary key #14

jace opened this issue Nov 5, 2015 · 4 comments

Comments

@jace
Copy link
Member

jace commented Nov 5, 2015

SQLAlchemy provides an autoincrementing primary key by default (also referred to as "serial"). The GeoName table uses geonameid as the primary key and these numbers are externally defined, so the table should not have autoincrement enabled. We need to:

  1. Disable autoincrement in the model
  2. Add a migration to remove it from the database
@ghost
Copy link

ghost commented Nov 20, 2015

I followed a Stackoverflow post regarding this issue, this could help I guess.
(http://stackoverflow.com/questions/27498991/sqlalchemy-primary-key-without-auto-increment):
$ geonameid = db.Column(db.Integer, primary_key=True, autoincrement=False)

@jace
Copy link
Member Author

jace commented Nov 20, 2015

This takes care of point 1. We also need a migration for point 2.

@ghost
Copy link

ghost commented Nov 20, 2015

@jace we modify the generated migration (for point 1) by hand for point 2, right?

@jace
Copy link
Member Author

jace commented Nov 20, 2015

Try and see what you get. You need both forward and backward revisions.

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

No branches or pull requests

1 participant