create table if not exists merchant_product_audit_record ( id bigint unsigned not null auto_increment, product_id bigint unsigned not null, merchant_id bigint unsigned not null, product_no varchar(64) not null, product_type varchar(64) not null, product_name varchar(128) not null, subtitle varchar(255) default null, cover_url varchar(500) default null, original_price decimal(10,2) not null default 0.00, sale_price decimal(10,2) not null default 0.00, subsidy_amount decimal(10,2) not null default 0.00, is_government_subsidy tinyint not null default 0, stock int not null default -1, sales_count int not null default 0, detail_text text, benefit_desc text, purchase_notice json default null, valid_start_time datetime default null, valid_end_time datetime default null, product_images json default null, rights_config json default null, audit_status tinyint not null default 0, audit_remark varchar(500) default null, audit_by bigint unsigned default null, submit_time datetime default null, audit_time datetime default null, source_created_at datetime default null, created_at datetime not null default current_timestamp, deleted tinyint not null default 0, primary key (id), key idx_product_audit_record_product (product_id, id), key idx_product_audit_record_status (audit_status), key idx_product_audit_record_submit_time (submit_time), key idx_product_audit_record_merchant (merchant_id) ) engine=InnoDB default charset=utf8mb4 comment='merchant product audit history'; insert into merchant_product_audit_record( product_id, merchant_id, product_no, product_type, product_name, subtitle, cover_url, original_price, sale_price, subsidy_amount, is_government_subsidy, stock, sales_count, detail_text, benefit_desc, purchase_notice, valid_start_time, valid_end_time, product_images, rights_config, audit_status, audit_remark, audit_by, submit_time, audit_time, source_created_at ) select p.id, p.merchant_id, p.product_no, p.product_type, p.product_name, p.subtitle, p.cover_url, p.original_price, p.sale_price, p.subsidy_amount, p.is_government_subsidy, p.stock, p.sales_count, p.detail_text, p.benefit_desc, p.purchase_notice, p.valid_start_time, p.valid_end_time, p.product_images, p.rights_config, p.audit_status, p.audit_remark, p.audit_by, p.submit_time, p.audit_time, p.created_at from merchant_product p where not exists ( select 1 from merchant_product_audit_record r where r.product_id = p.id );