Files
MuditaOS/image/user/db/sms_001.sql
Radoslaw Wicik d14e40d378 [EGD-4831] Add license headers to c, h and sql files
Add license headers to `h`, `c` and `sql` files as this files haven't
been checked previously, script now to automatically updates current
year in existing licenses.
2021-01-28 14:41:33 +01:00

44 lines
1.2 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 sms
(
_id INTEGER PRIMARY KEY,
thread_id INTEGER,
contact_id INTEGER,
date INTEGER,
date_send INTEGER,
error_code INTEGER,
body TEXT NOT_NULL,
type INTEGER,
FOREIGN KEY (thread_id) REFERENCES threads (_id) ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS templates
(
_id INTEGER PRIMARY KEY,
text TEXT,
lastUsageTimestamp INTEGER
);
CREATE TABLE IF NOT EXISTS threads
(
_id INTEGER PRIMARY KEY,
date INTEGER,
msg_count INTEGER,
read INTEGER,
contact_id INTEGER,
number_id INTEGER,
snippet TEXT NOT NULL,
last_dir INTEGER
);
CREATE TABLE IF NOT EXISTS threads_count
(
_id INTEGER PRIMARY KEY,
count INTEGER
);
CREATE TRIGGER IF NOT EXISTS on_thread_insert AFTER INSERT ON threads BEGIN UPDATE threads_count SET count=count+1 WHERE _id=1; END;
CREATE TRIGGER IF NOT EXISTS on_thread_remove AFTER DELETE ON threads BEGIN UPDATE threads_count SET count=count-1 WHERE _id=1; END;