Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
alexalouit committed Nov 2, 2017
1 parent 4726c4c commit 2cf87ca
Showing 1 changed file with 1 addition and 37 deletions.
38 changes: 1 addition & 37 deletions daos/sqlite/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,43 +236,7 @@ public function __construct() {
}
if (strnatcmp($version, '12') < 0) {
\F3::get('db')->exec([
// Table needs to be re-created because ALTER TABLE is rather limited.
// https://sqlite.org/lang_altertable.html#otheralter
'CREATE TABLE new_items (
id INTEGER PRIMARY KEY AUTOINCREMENT,
datetime DATETIME NOT NULL,
title TEXT NOT NULL,
content TEXT NOT NULL,
thumbnail TEXT,
icon TEXT,
unread BOOL NOT NULL,
starred BOOL NOT NULL,
source INT NOT NULL,
uid VARCHAR(255) NOT NULL,
link TEXT NOT NULL,
updatetime DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
author VARCHAR(255),
shared BOOL,
lastseen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT uid UNIQUE (uid, source)
)',
'UPDATE items SET updatetime = datetime WHERE updatetime IS NULL',
'INSERT INTO new_items SELECT *, CURRENT_TIMESTAMP FROM items',
'DROP TABLE items',
'ALTER TABLE new_items RENAME TO items',
'CREATE INDEX source ON items (source)',
'CREATE TRIGGER update_updatetime_trigger
AFTER UPDATE ON items FOR EACH ROW
WHEN (
OLD.unread <> NEW.unread OR
OLD.starred <> NEW.starred
)
BEGIN
UPDATE items
SET updatetime = CURRENT_TIMESTAMP
WHERE id = NEW.id;
END',
'INSERT INTO version (version) VALUES (12)'
'CREATE UNIQUE INDEX uid ON new_items(uid, source);'
]);
}
}
Expand Down

0 comments on commit 2cf87ca

Please sign in to comment.