aboutsummaryrefslogtreecommitdiffstats
path: root/rust/migrations/2018-05-12-001226_init
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2018-09-09 13:51:54 -0700
committerBryan Newbold <bnewbold@robocracy.org>2018-09-09 13:51:56 -0700
commit2732c2e3ba50f28c4c8a3b244783bc70d04806fa (patch)
treef55c357663d9467fd5648850a04b5b54d42fadfe /rust/migrations/2018-05-12-001226_init
parent51f2dcada8588de2f8cde2f874b955fefbd01e97 (diff)
downloadfatcat-2732c2e3ba50f28c4c8a3b244783bc70d04806fa.tar.gz
fatcat-2732c2e3ba50f28c4c8a3b244783bc70d04806fa.zip
changelog ID as a sequence
As noted elsewhere, auto-increment sequences in postgres, mysql, and cockroach can have gaps: when transactions that increment a number are rolled back, a "gap" is left. I didn't realize this, and it's problematic for the external changelog API. I'll need to re-write the changelog inserter to query for the current highest number when inserting, which is unfortunate and might slow down bulk imports.
Diffstat (limited to 'rust/migrations/2018-05-12-001226_init')
-rw-r--r--rust/migrations/2018-05-12-001226_init/down.sql2
-rw-r--r--rust/migrations/2018-05-12-001226_init/up.sql4
2 files changed, 5 insertions, 1 deletions
diff --git a/rust/migrations/2018-05-12-001226_init/down.sql b/rust/migrations/2018-05-12-001226_init/down.sql
index 3f796db6..7667d122 100644
--- a/rust/migrations/2018-05-12-001226_init/down.sql
+++ b/rust/migrations/2018-05-12-001226_init/down.sql
@@ -31,3 +31,5 @@ DROP TABLE IF EXISTS abstracts CASCADE;
DROP TABLE IF EXISTS editor CASCADE;
DROP TABLE IF EXISTS editgroup CASCADE;
DROP TABLE IF EXISTS changelog CASCADE;
+
+DROP SEQUENCE IF EXISTS changelog_seq CASCADE;
diff --git a/rust/migrations/2018-05-12-001226_init/up.sql b/rust/migrations/2018-05-12-001226_init/up.sql
index 6b0e9c6e..3ca954ca 100644
--- a/rust/migrations/2018-05-12-001226_init/up.sql
+++ b/rust/migrations/2018-05-12-001226_init/up.sql
@@ -30,8 +30,10 @@ ALTER TABLE editor
ADD CONSTRAINT editor_editgroupid_fkey FOREIGN KEY (active_editgroup_id)
REFERENCES editgroup(id);
+CREATE SEQUENCE changelog_seq START 1 INCREMENT 1;
+
CREATE TABLE changelog (
- id BIGSERIAL PRIMARY KEY,
+ id BIGINT PRIMARY KEY DEFAULT nextval('changelog_seq'),
editgroup_id UUID REFERENCES editgroup(id) NOT NULL,
timestamp TIMESTAMP WITHOUT TIME ZONE DEFAULT now() NOT NULL
);