CREATE TABLE pad_files (
 id BIGSERIAL PRIMARY KEY,
 pad_id BIGINT NOT NULL REFERENCES pads(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_pad_files_pad ON pad_files(pad_id, id DESC);
