dkforest

A forum and chat platform (onion)
git clone https://git.dasho.dev/n0tr1v/dkforest.git
Log | Files | Refs | LICENSE

125.sql (955B)


      1 -- +migrate Up
      2 drop trigger links_before_update;
      3 drop trigger links_before_update1;
      4 
      5 -- +migrate StatementBegin
      6 CREATE TRIGGER links_before_update_soft_delete
      7     BEFORE UPDATE ON links WHEN old.deleted_at IS NULL AND new.deleted_at IS NOT NULL BEGIN
      8     DELETE FROM fts5_links WHERE id=old.id;
      9 END;
     10 
     11 CREATE TRIGGER links_before_update
     12     BEFORE UPDATE ON links WHEN old.deleted_at IS NOT NULL AND new.deleted_at IS NULL BEGIN
     13     INSERT INTO fts5_links(rowid, uuid, url, title, description, created_at, visited_at) VALUES
     14         (new.id, new.uuid, new.url, new.title, new.description, new.created_at, new.visited_at);
     15 END;
     16 
     17 CREATE TRIGGER links_after_insert
     18     AFTER INSERT ON links BEGIN
     19     INSERT INTO fts5_links(rowid, uuid, url, title, description, created_at, visited_at)
     20         SELECT id, uuid, url, title, description, created_at, visited_at
     21         FROM links
     22         WHERE links.id = new.id;
     23 END;
     24 -- +migrate StatementEnd
     25 
     26 -- +migrate Down