-- Copyright (C) 2026 ZUGFeRD Import Module
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.

CREATE TABLE llx_importzugferd_datanorm_log (
    rowid           integer AUTO_INCREMENT PRIMARY KEY,
    fk_product      integer NOT NULL,
    fk_soc          integer NOT NULL,
    fk_user         integer NOT NULL,
    datanorm_ref    varchar(100),
    field_changed   varchar(50) NOT NULL,
    old_value       text,
    new_value       text,
    date_change     datetime NOT NULL,
    batch_id        varchar(50),
    entity          integer DEFAULT 1 NOT NULL
) ENGINE=innodb;

ALTER TABLE llx_importzugferd_datanorm_log ADD INDEX idx_datanorm_log_product (fk_product);
ALTER TABLE llx_importzugferd_datanorm_log ADD INDEX idx_datanorm_log_soc (fk_soc);
ALTER TABLE llx_importzugferd_datanorm_log ADD INDEX idx_datanorm_log_date (date_change);
ALTER TABLE llx_importzugferd_datanorm_log ADD INDEX idx_datanorm_log_batch (batch_id);
