-- ============================================================
-- 06_create_adhkar.sql
-- Tabel dzikir (pagi / sore / setelah sholat)
-- Sumber: Muslim API (/v1/dzikir)
-- ============================================================

CREATE TABLE IF NOT EXISTS adhkar (
    id              SERIAL PRIMARY KEY,
    source_id       TEXT,                        -- _id dari API
    arabic          TEXT NOT NULL,                -- Teks Arab
    translation     TEXT NOT NULL,                -- Terjemahan Indonesia
    type            TEXT NOT NULL,                -- pagi, sore, solat
    repeat_count    TEXT,                         -- 1x, 3x, 7x, 33x, dll
    notes           TEXT,                         -- Keterangan tambahan
    sort_order      INTEGER DEFAULT 0,           -- Urutan tampilan
    created_at      TIMESTAMPTZ DEFAULT NOW()
);

-- Index
CREATE INDEX IF NOT EXISTS idx_adhkar_type ON adhkar(type);

-- RLS: semua boleh baca
ALTER TABLE adhkar ENABLE ROW LEVEL SECURITY;

CREATE POLICY "adhkar_read_all" ON adhkar
    FOR SELECT USING (true);
