pub(crate) mod sql {
pub(crate) const INSERT_NEW: &str = r#"INSERT INTO arcature_password_resets
(id, secret_digest, subject, expires_at, created_at)
VALUES ($1, $2, $3, $4, $5)
ON CONFLICT (id) DO NOTHING"#;
pub(crate) const FIND_LIVE: &str = r#"SELECT secret_digest, subject
FROM arcature_password_resets
WHERE id = $1 AND expires_at > now()"#;
pub(crate) const DELETE_FOR: &str = "DELETE FROM arcature_password_resets WHERE subject = $1";
pub(crate) const DELETE_EXPIRED: &str =
"DELETE FROM arcature_password_resets WHERE expires_at <= now()";
pub(crate) const CREATE_HISTORY: &str = r#"CREATE TABLE IF NOT EXISTS arcature_password_resets_schema_migrations (
version TEXT PRIMARY KEY,
applied_at TIMESTAMPTZ NOT NULL DEFAULT now()
)"#;
pub(crate) const COUNT_APPLIED: &str =
"SELECT COUNT(*) FROM arcature_password_resets_schema_migrations WHERE version = $1";
pub(crate) const RECORD_APPLIED: &str = "INSERT INTO arcature_password_resets_schema_migrations (version) VALUES ($1) ON CONFLICT DO NOTHING";
pub(crate) const LOCK: Option<&str> = Some("SELECT pg_advisory_lock(71420004)");
pub(crate) const UNLOCK: Option<&str> = Some("SELECT pg_advisory_unlock(71420004)");
pub(crate) const SCHEMA: &str = include_str!("../migrations/postgres/0001_password_resets.sql");
}