aboutsummaryrefslogtreecommitdiff
path: root/internal/dbstore/testdata/sql/init.sql
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2022-02-04 18:38:48 -0500
committerPaul Duncan <pabs@pablotron.org>2022-02-04 18:38:48 -0500
commitd1f55e2626513dd8a77a6c6ad204f4ec843f2ad0 (patch)
tree9244cb2723fe15e210be4d0288ff83e7e88b6455 /internal/dbstore/testdata/sql/init.sql
parent27e997ddfbda5eb28be9b92615894617659c2e5c (diff)
downloadcvez-d1f55e2626513dd8a77a6c6ad204f4ec843f2ad0.tar.bz2
cvez-d1f55e2626513dd8a77a6c6ad204f4ec843f2ad0.zip
mv internal/dbstore/testdata/sql internal/dbstore/sql
Diffstat (limited to 'internal/dbstore/testdata/sql/init.sql')
-rw-r--r--internal/dbstore/testdata/sql/init.sql73
1 files changed, 0 insertions, 73 deletions
diff --git a/internal/dbstore/testdata/sql/init.sql b/internal/dbstore/testdata/sql/init.sql
deleted file mode 100644
index a08b2f8..0000000
--- a/internal/dbstore/testdata/sql/init.sql
+++ /dev/null
@@ -1,73 +0,0 @@
--- enable foreign keys
-PRAGMA foreign_keys = true;
-
--- create cpes table
-CREATE TABLE cpes (
- cpe_id INTEGER PRIMARY KEY,
-
- -- cpe uri
- cpe_uri TEXT UNIQUE NOT NULL,
-
- -- cpe 2.3 formatting string
- cpe23 TEXT UNIQUE NOT NULL
-);
-
--- create titles table
-CREATE TABLE cpe_titles (
- -- external CPE id
- cpe_id INT NOT NULL
- REFERENCES cpes(cpe_id),
-
- -- language code
- lang TEXT NOT NULL,
-
- -- text value
- val TEXT NOT NULL,
-
- UNIQUE (cpe_id, lang)
-);
-
--- create titles fts table
-CREATE VIRTUAL TABLE cpe_titles_fts USING fts5(title, tokenize = 'porter');
-
--- create titles insert trigger
-CREATE TRIGGER tr_cpe_titles_insert AFTER INSERT ON cpe_titles
- FOR EACH ROW WHEN (NEW.lang = 'en-US') BEGIN
- INSERT INTO cpe_titles_fts(rowid, title) VALUES (NEW.cpe_id, NEW.val);
- END;
-
--- create titles delete trigger
-CREATE TRIGGER tr_cpe_titles_delete BEFORE DELETE ON cpe_titles
- FOR EACH ROW WHEN (OLD.lang = 'en-US') BEGIN
- DELETE FROM cpe_titles_fts WHERE rowid = OLD.cpe_id;
- END;
-
--- create refs table
-CREATE TABLE cpe_refs (
- -- external CPE id
- cpe_id INT NOT NULL
- REFERENCES cpes(cpe_id),
-
- -- url
- href TEXT NOT NULL,
-
- -- text description
- val TEXT NOT NULL
-);
-
--- create refs fts
-CREATE VIRTUAL TABLE cpe_refs_fts USING fts5(cpe_id UNINDEXED, href, val);
-
--- create refs insert trigger
-CREATE TRIGGER tr_cpe_refs_insert AFTER INSERT ON cpe_refs
- FOR EACH ROW BEGIN
- INSERT INTO cpe_refs_fts(cpe_id, href, val) VALUES (NEW.cpe_id, NEW.href, NEW.val);
- END;
-
--- create refs delete trigger
-CREATE TRIGGER tr_cpe_refs_delete BEFORE DELETE ON cpe_refs
- FOR EACH ROW BEGIN
- DELETE FROM cpe_refs_fts WHERE rowid = OLD.cpe_id;
- END;
-
-PRAGMA user_version = 314159;