Skip to content

Commit

Permalink
sqlite re-uses ID for columns not marked as autoincrement, so use that.
Browse files Browse the repository at this point in the history
fixes #202
  • Loading branch information
dannyvankooten committed Feb 4, 2019
1 parent 05598eb commit 5e4ce53
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions pkg/datastore/sqlstore/migrations/sqlite3/26_sites_id_autoinc.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
-- +migrate Up
DROP TABLE IF EXISTS sites_old;
ALTER TABLE sites RENAME TO sites_old;
CREATE TABLE sites (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`tracking_id` VARCHAR(8) UNIQUE,
`name` VARCHAR(100) NOT NULL
);
INSERT INTO sites SELECT `id`, `tracking_id`, `name` FROM sites_old;

-- +migrate Down
DROP TABLE IF EXISTS sites_old;
ALTER TABLE sites RENAME TO sites_old;
CREATE TABLE sites (
`id` INTEGER PRIMARY KEY,
`tracking_id` VARCHAR(8) UNIQUE,
`name` VARCHAR(100) NOT NULL
);
INSERT INTO sites SELECT `id`, `tracking_id`, `name` FROM sites_old;

0 comments on commit 5e4ce53

Please sign in to comment.