CREATE TABLE aws_document_row_overrides (
    id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    document_id INT UNSIGNED NOT NULL,
    row_index INT UNSIGNED NOT NULL,
    is_loan TINYINT(1) NOT NULL DEFAULT 1,
    created_by INT UNSIGNED NULL,
    created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    updated_at DATETIME NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
    CONSTRAINT fk_aws_doc_row_overrides_document FOREIGN KEY (document_id) REFERENCES aws_documents (id) ON DELETE CASCADE,
    CONSTRAINT fk_aws_doc_row_overrides_user FOREIGN KEY (created_by) REFERENCES users (id) ON DELETE SET NULL,
    UNIQUE KEY uq_aws_doc_row_overrides_doc_row (document_id, row_index),
    INDEX idx_aws_doc_row_overrides_doc (document_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
