pub(crate) mod sql {
pub(crate) const INSERT_NEW: &str = r#"INSERT OR IGNORE INTO arcature_notifications
(id, notifiable_key, kind, data, created_at)
VALUES (?, ?, ?, ?, ?)"#;
pub(crate) const LIST: &str = r#"SELECT id, kind, data, read_at, created_at
FROM arcature_notifications
WHERE notifiable_key = ?
ORDER BY created_at DESC, id
LIMIT ?"#;
pub(crate) const LIST_UNREAD: &str = r#"SELECT id, kind, data, read_at, created_at
FROM arcature_notifications
WHERE notifiable_key = ? AND read_at IS NULL
ORDER BY created_at DESC, id
LIMIT ?"#;
pub(crate) const COUNT_UNREAD: &str =
"SELECT COUNT(*) FROM arcature_notifications WHERE notifiable_key = ? AND read_at IS NULL";
pub(crate) const MARK_READ: &str = r#"UPDATE arcature_notifications
SET read_at = ?
WHERE notifiable_key = ? AND id = ? AND read_at IS NULL"#;
pub(crate) const MARK_ALL_READ: &str = r#"UPDATE arcature_notifications
SET read_at = ?
WHERE notifiable_key = ? AND read_at IS NULL"#;
pub(crate) const DELETE: &str =
"DELETE FROM arcature_notifications WHERE notifiable_key = ? AND id = ?";
pub(crate) const DELETE_ALL: &str =
"DELETE FROM arcature_notifications WHERE notifiable_key = ?";
pub(crate) const DELETE_READ_BEFORE: &str =
"DELETE FROM arcature_notifications WHERE read_at IS NOT NULL AND read_at < ?";
pub(crate) const CREATE_HISTORY: &str = r#"CREATE TABLE IF NOT EXISTS arcature_notifications_schema_migrations (
version TEXT PRIMARY KEY,
applied_at INTEGER NOT NULL
DEFAULT (CAST((julianday('now')-2440587.5)*86400000 AS INTEGER))
)"#;
pub(crate) const COUNT_APPLIED: &str =
"SELECT COUNT(*) FROM arcature_notifications_schema_migrations WHERE version = ?";
pub(crate) const RECORD_APPLIED: &str =
"INSERT OR IGNORE INTO arcature_notifications_schema_migrations (version) VALUES (?)";
pub(crate) const LOCK: Option<&str> = None;
pub(crate) const UNLOCK: Option<&str> = None;
pub(crate) const SCHEMA: &str = include_str!("../migrations/sqlite/0001_notifications.sql");
}