INSERT INTO `options` (`foreign_id`, `key`, `tab_id`, `value`, `label`, `type`, `order`, `is_visible`, `style`)
SELECT 1, 'o_default_order_status', 2, 'new|pending|completed|cancelled::new', 'New|Pending|Completed|Cancelled', 'enum', 9, 1, NULL
WHERE NOT EXISTS (
    SELECT 1 FROM `options` WHERE `foreign_id` = 1 AND `key` = 'o_default_order_status'
);

INSERT INTO `fields` (`key`, `type`, `label`, `source`, `modified`)
SELECT 'opt_o_default_order_status', 'backend', 'Options / Default order status', 'script', NULL
WHERE NOT EXISTS (
    SELECT 1 FROM `fields` WHERE `key` = 'opt_o_default_order_status'
);

SET @field_id := (SELECT `id` FROM `fields` WHERE `key` = 'opt_o_default_order_status' LIMIT 1);

INSERT INTO `multi_lang` (`foreign_id`, `model`, `locale`, `field`, `content`, `source`)
SELECT @field_id, 'pjBaseField', '::LOCALE::', 'title', 'Default order status', 'script'
WHERE NOT EXISTS (
    SELECT 1
    FROM `multi_lang`
    WHERE `foreign_id` = @field_id
      AND `model` = 'pjBaseField'
      AND `locale` = '::LOCALE::'
      AND `field` = 'title'
);
