-- V9: Guardian notifications - pesan dari Guardian ke User (text atau voice note)
CREATE TABLE IF NOT EXISTS guardian_notifications (
    id                  BIGSERIAL    PRIMARY KEY,
    guardian_id         BIGINT       NOT NULL REFERENCES users(id) ON DELETE CASCADE,
    user_id             BIGINT       NOT NULL REFERENCES users(id) ON DELETE CASCADE,
    notif_type          VARCHAR(20)  NOT NULL DEFAULT 'TEXT',
    content             TEXT,
    voice_note_url      VARCHAR(500),
    voice_note_duration INT,
    is_read             BOOLEAN      NOT NULL DEFAULT FALSE,
    read_at             TIMESTAMP,
    created_at          TIMESTAMP    NOT NULL DEFAULT NOW()
);
CREATE INDEX IF NOT EXISTS idx_notif_user_id    ON guardian_notifications(user_id);
CREATE INDEX IF NOT EXISTS idx_notif_is_read    ON guardian_notifications(is_read);
CREATE INDEX IF NOT EXISTS idx_notif_created_at ON guardian_notifications(created_at DESC);
