-
Notifications
You must be signed in to change notification settings - Fork 372
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sqlite re-uses ID for columns not marked as autoincrement, so use that.
fixes #202
- Loading branch information
1 parent
05598eb
commit 5e4ce53
Showing
1 changed file
with
19 additions
and
0 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
pkg/datastore/sqlstore/migrations/sqlite3/26_sites_id_autoinc.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |