CREATE TABLE IF NOT EXISTS company_documents (
 id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
 company_id BIGINT UNSIGNED NOT NULL,
 category VARCHAR(40) NOT NULL,
 filename VARCHAR(200) NOT NULL,
 issued_on DATE NULL,
 expires_on DATE NULL,
 notes VARCHAR(1000) NOT NULL DEFAULT '',
 size_bytes INT UNSIGNED NOT NULL,
 content LONGBLOB NOT NULL,
 created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
 INDEX company_category (company_id,category),
 FOREIGN KEY (company_id) REFERENCES companies(id)
) ENGINE=InnoDB;
