-- Ensure note.userid column exists (for older databases created before this field was added)
ALTER TABLE note ADD COLUMN userid INTEGER DEFAULT 0;

-- Index for faster per-user queries
CREATE INDEX IF NOT EXISTS idx_note_userid ON note(userid);
CREATE INDEX IF NOT EXISTS idx_note_flag_userid ON note(flag, userid);
