add subscribing and unsubscribing to threads

This commit is contained in:
2025-06-02 20:54:36 +03:00
parent 1e23959e52
commit bd1ba6c087
6 changed files with 94 additions and 22 deletions

View File

@ -102,4 +102,15 @@ return {
db.query("CREATE INDEX idx_rate_limit_user_method ON api_rate_limits (user_id, method)")
end,
[13] = function ()
schema.create_table("subscriptions", {
{"id", types.integer{primary_key = true}},
{"user_id", "INTEGER REFERENCES users(id) ON DELETE CASCADE"},
{"thread_id", "INTEGER REFERENCES threads(id) ON DELETE CASCADE"},
{"last_seen", "INTEGER DEFAULT (unixepoch(CURRENT_TIMESTAMP)) NOT NULL"},
})
db.query("CREATE INDEX idx_subscription_user_thread ON subscriptions (user_id, thread_id)")
end,
}