mirror of
https://github.com/dnote/dnote
synced 2026-03-14 22:45:50 +01:00
* Remove public from CLI * Write migration and test * Use in-memory db for a test server * Simplify CLI test db teardown * Restructure packages to reduce duplication
40 lines
1.5 KiB
SQL
40 lines
1.5 KiB
SQL
-- This is the final state of the CLI database after all migrations.
|
|
-- Auto-generated by generate-schema.go. Do not edit manually.
|
|
CREATE TABLE books
|
|
(
|
|
uuid text PRIMARY KEY,
|
|
label text NOT NULL
|
|
, dirty bool DEFAULT false, usn int DEFAULT 0 NOT NULL, deleted bool DEFAULT false);
|
|
CREATE TABLE system
|
|
(
|
|
key string NOT NULL,
|
|
value text NOT NULL
|
|
);
|
|
CREATE UNIQUE INDEX idx_books_label ON books(label);
|
|
CREATE UNIQUE INDEX idx_books_uuid ON books(uuid);
|
|
CREATE TABLE "notes"
|
|
(
|
|
uuid text NOT NULL,
|
|
book_uuid text NOT NULL,
|
|
body text NOT NULL,
|
|
added_on integer NOT NULL,
|
|
edited_on integer DEFAULT 0,
|
|
dirty bool DEFAULT false,
|
|
usn int DEFAULT 0 NOT NULL,
|
|
deleted bool DEFAULT false
|
|
);
|
|
CREATE VIRTUAL TABLE note_fts USING fts5(content=notes, body, tokenize="porter unicode61 categories 'L* N* Co Ps Pe'");
|
|
CREATE TRIGGER notes_after_insert AFTER INSERT ON notes BEGIN
|
|
INSERT INTO note_fts(rowid, body) VALUES (new.rowid, new.body);
|
|
END;
|
|
CREATE TRIGGER notes_after_delete AFTER DELETE ON notes BEGIN
|
|
INSERT INTO note_fts(note_fts, rowid, body) VALUES ('delete', old.rowid, old.body);
|
|
END;
|
|
CREATE TRIGGER notes_after_update AFTER UPDATE ON notes BEGIN
|
|
INSERT INTO note_fts(note_fts, rowid, body) VALUES ('delete', old.rowid, old.body);
|
|
INSERT INTO note_fts(rowid, body) VALUES (new.rowid, new.body);
|
|
END;
|
|
|
|
-- Migration version data.
|
|
INSERT INTO system (key, value) VALUES ('schema', 14);
|
|
INSERT INTO system (key, value) VALUES ('remote_schema', 1);
|