-
Notifications
You must be signed in to change notification settings - Fork 555
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(sqlite): id column should be unique (#894)
Co-authored-by: Felipe Martin <[email protected]>
- Loading branch information
1 parent
c107e97
commit eaa6f0e
Showing
2 changed files
with
23 additions
and
0 deletions.
There are no files selected for viewing
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,22 @@ | ||
-- Create a temporary table | ||
CREATE TABLE IF NOT EXISTS bookmark_temp( | ||
id INTEGER PRIMARY KEY AUTOINCREMENT, | ||
url TEXT NOT NULL, | ||
title TEXT NOT NULL, | ||
excerpt TEXT NOT NULL DEFAULT "", | ||
author TEXT NOT NULL DEFAULT "", | ||
public INTEGER NOT NULL DEFAULT 0, | ||
modified TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
has_content BOOLEAN DEFAULT FALSE NOT NULL, | ||
CONSTRAINT bookmark_url_UNIQUE UNIQUE(url) | ||
); | ||
|
||
-- Copy data from the original table to the temporary table | ||
INSERT INTO bookmark_temp (id, url, title, excerpt, author, public, modified, has_content) | ||
SELECT id, url, title, excerpt, author, public, modified, has_content FROM bookmark; | ||
|
||
-- Drop the original table | ||
DROP TABLE bookmark; | ||
|
||
-- Rename the temporary table to the original table name | ||
ALTER TABLE bookmark_temp RENAME TO bookmark; |
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