aboutsummaryrefslogtreecommitdiffstats
path: root/filamento/migrations
diff options
context:
space:
mode:
authorLibravatar cel 🌸 <cel@bunny.garden>2025-04-03 03:41:38 +0100
committerLibravatar cel 🌸 <cel@bunny.garden>2025-04-03 03:41:38 +0100
commit91f1994af940085d5d475a97820900ebbf0eb553 (patch)
tree6aab872f71d17a785d3d9286742fef38983d274c /filamento/migrations
parent9ce3827a7d25714d17f266f0f50bb29f41090175 (diff)
downloadluz-91f1994af940085d5d475a97820900ebbf0eb553.tar.gz
luz-91f1994af940085d5d475a97820900ebbf0eb553.tar.bz2
luz-91f1994af940085d5d475a97820900ebbf0eb553.zip
feat: better message handling, pep publish, xep_0172: nick
Diffstat (limited to 'filamento/migrations')
-rw-r--r--filamento/migrations/20240113011930_luz.sql12
1 files changed, 12 insertions, 0 deletions
diff --git a/filamento/migrations/20240113011930_luz.sql b/filamento/migrations/20240113011930_luz.sql
index 148598b..3b56664 100644
--- a/filamento/migrations/20240113011930_luz.sql
+++ b/filamento/migrations/20240113011930_luz.sql
@@ -5,6 +5,7 @@ PRAGMA foreign_keys = on;
create table users(
-- TODO: enforce bare jid
jid text primary key not null,
+ nick text,
-- can receive presence status from non-contacts
cached_status_message text
-- TODO: last_seen
@@ -67,14 +68,24 @@ create table groups_roster(
-- can send chat message to user (creating a new chat if not already exists)
create table chats (
id text primary key not null,
+ have_chatted bool not null,
correspondent text not null unique,
foreign key(correspondent) references users(jid)
);
+-- enum for subscription state
+create table delivery(
+ state text primary key not null
+);
+
+insert into delivery ( state ) values ('sending'), ('written'), ('sent'), ('delivered'), ('read'), ('failed'), ('queued');
+
-- messages include reference to chat they are in, and who sent them.
create table messages (
id text primary key not null,
body text,
+ -- delivery is nullable as only messages sent by the user are markable
+ delivery text,
chat_id text not null,
-- TODO: channel stuff
-- channel_id uuid,
@@ -94,6 +105,7 @@ create table messages (
from_resource text,
-- check (from_jid != original_sender),
+ foreign key(delivery) references delivery(state),
-- TODO: from can be either a jid, a moved jid (for when a contact moves, save original sender jid/user but link to new user), or imported (from another service (save details), linked to new user)
-- TODO: read bool not null,
foreign key(chat_id) references chats(id) on delete cascade,