edgi-govdata-archiving / web-monitoring-db

An HTTP API for tracking and annotating changes to a set of web pages.
https://api.monitoring.envirodatagov.org/
GNU General Public License v3.0
17 stars 26 forks source link

Change int primary keys to bigint #1088

Closed Mr0grog closed 1 year ago

Mr0grog commented 1 year ago

Integer primary keys can cause problems over time on big tables, and in general it's just better practice to use bigints instead. Some of our larger tables use UUIDs instead of ints, so this only upgrades the tables that used ints. (Practically speaking, none of these tables are really likely to overflow their primary key sequence, but better safe than sorry here, especially with technical maintainers offboarding.)

Fixes #1067.

Mr0grog commented 1 year ago

I noticed schema.rb doesn’t record anything about the sequences, and since this doesn't make things :bigserial, was worried a fresh DB would potentially be missing the sequences.

Tried this and and it appears to create the sequences and hook them up to the PK columns correctly, though:

# NOTE: delete the old DB or change the DB name in database.yaml first!
rails db:create
rails db:schema:load