| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
ALTER TABLE notifications ADD COLUMN repo_id INTEGER REFERENCES repositories(id) ON DELETE CASCADE; |
| 5 |
|
| 6 |
ALTER TABLE notifications ADD COLUMN thread TEXT NOT NULL DEFAULT ''; |
| 7 |
ALTER TABLE notifications ADD COLUMN reason TEXT NOT NULL DEFAULT 'participating' CHECK (reason IN ('participating', 'watching')); |
| 8 |
ALTER TABLE notifications ADD COLUMN done INTEGER NOT NULL DEFAULT 0; |
| 9 |
|
| 10 |
UPDATE notifications SET thread = CASE WHEN instr(url, '#') > 0 THEN substr(url, 1, instr(url, '#') - 1) ELSE url END; |
| 11 |
UPDATE notifications SET repo_id = ( |
| 12 |
SELECT r.id FROM repositories r |
| 13 |
WHERE substr(notifications.url, 1, length('/' || r.owner || '/' || r.name || '/')) = '/' || r.owner || '/' || r.name || '/' |
| 14 |
); |
| 15 |
CREATE INDEX notifications_by_thread ON notifications (account_id, done, thread, at_ms DESC); |