-- Routing operations per product (productionrules module)

CREATE TABLE llx_productionrules_routing (
    rowid                integer AUTO_INCREMENT PRIMARY KEY,
    entity               integer NOT NULL DEFAULT 1,
    fk_product           integer NOT NULL,
    op_no                integer NOT NULL,
    op_code              varchar(64) NULL,
    label                varchar(255) NOT NULL,
    routing_instructions text NULL,
    inspection_notes     text NULL,
    sfdc_op_notes        text NULL,
    subcontract          tinyint NOT NULL DEFAULT 0,
    subcon_code          varchar(64) NULL,
    active               tinyint NOT NULL DEFAULT 1,
    datec                datetime NULL,
    tms                  timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=innodb;

ALTER TABLE llx_productionrules_routing ADD INDEX idx_prouting_fk_product (fk_product);
ALTER TABLE llx_productionrules_routing ADD INDEX idx_prouting_op_no (fk_product, op_no);
