ALTER TABLE notes ADD COLUMN protected BOOLEAN NOT NULL DEFAULT FALSE;
CREATE TABLE note_files (
 id BIGSERIAL PRIMARY KEY, note_id BIGINT NOT NULL REFERENCES notes(id) ON DELETE CASCADE, filename TEXT NOT NULL, url TEXT NOT NULL UNIQUE,
 mime_type TEXT NOT NULL, size_bytes BIGINT NOT NULL, created_at TEXT NOT NULL DEFAULT (CURRENT_TIMESTAMP::text),
 is_attached BOOLEAN NOT NULL DEFAULT TRUE, detached_at TEXT
);
CREATE INDEX idx_note_files_note ON note_files(note_id, id DESC);
