CREATE TABLE pad_files (
 id BIGINT AUTO_INCREMENT PRIMARY KEY,
 pad_id BIGINT NOT NULL,
 filename TEXT NOT NULL,
 url VARCHAR(512) NOT NULL UNIQUE,
 mime_type VARCHAR(255) NOT NULL,
 size_bytes BIGINT NOT NULL,
 created_at VARCHAR(64) NOT NULL DEFAULT (CURRENT_TIMESTAMP),
 is_attached BOOLEAN NOT NULL DEFAULT TRUE,
 detached_at VARCHAR(64),
 CONSTRAINT fk_pad_files_pad FOREIGN KEY (pad_id) REFERENCES pads(id) ON DELETE CASCADE,
 INDEX idx_pad_files_pad (pad_id, id DESC)
) ENGINE=InnoDB;
