Files
MuditaOS/image/user/db/quotes_001.sql
Mateusz Grzegorzek 31b24ed4d3 [EGD-5932] Add more queries to Quotes agent
Added queries:
- list quotes from selected category,
- enable/disable category,
- enable/disable single quote,
- list enabled quotes,

Other fixes:
- move `msgHandled` and `msgNotHandled` to `Message.hpp`,
- use `typeid` in `QuotesAgent::registerMessages`,
- change `Quotes::Queries` style,
- make `quotesList` private

Queries to add in next PR:
- add/read/write quote
2021-03-17 13:55:20 +01:00

34 lines
1.0 KiB
SQL

-- Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
-- For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
CREATE TABLE IF NOT EXISTS quote_languages (
lang_id INTEGER NOT NULL,
lang_name TEXT NOT NULL,
PRIMARY KEY (lang_id)
);
CREATE TABLE IF NOT EXISTS category_table (
category_id INTEGER NOT NULL,
category_name TEXT NOT NULL UNIQUE,
enabled BOOLEAN NOT NULL DEFAULT TRUE,
PRIMARY KEY (category_id)
);
CREATE TABLE IF NOT EXISTS quote_table (
quote_id INTEGER NOT NULL,
lang_id INTEGER NOT NULL,
quote TEXT NOT NULL,
author TEXT,
enabled BOOLEAN NOT NULL DEFAULT TRUE,
PRIMARY KEY (quote_id),
FOREIGN KEY (lang_id) REFERENCES quote_languages(lang_id)
);
CREATE TABLE IF NOT EXISTS quote_category_map (
category_id INTEGER NOT NULL,
quote_id INTEGER NOT NULL,
FOREIGN KEY (category_id) REFERENCES category_table(category_id),
FOREIGN KEY (quote_id) REFERENCES quote_table(quote_id),
CONSTRAINT quotes_unique UNIQUE(category_id, quote_id)
);