
# This is a fix for InnoDB in MySQL >= 4.1.x
# It "suspends judgement" for fkey relationships until are tables are set.
SET FOREIGN_KEY_CHECKS = 0;

-- ---------------------------------------------------------------------
-- order_status_notification
-- ---------------------------------------------------------------------

DROP TABLE IF EXISTS `order_status_notification`;

CREATE TABLE `order_status_notification`
(
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `order_status_id` INTEGER NOT NULL,
    `to_notify` TINYINT(1) DEFAULT 0 NOT NULL,
    PRIMARY KEY (`id`),
    INDEX `FI_order_status_notify_id` (`order_status_id`),
    CONSTRAINT `fk_order_status_notify_id`
        FOREIGN KEY (`order_status_id`)
        REFERENCES `order_status` (`id`)
        ON UPDATE RESTRICT
        ON DELETE CASCADE
) ENGINE=InnoDB;

# This restores the fkey checks, after having unset them earlier
SET FOREIGN_KEY_CHECKS = 1;

-- ---------------------------------------------------------------------
-- Affectation du modèle d'email
-- ---------------------------------------------------------------------
INSERT INTO `message` (name,secured,text_layout_file_name,text_template_file_name,html_layout_file_name,html_template_file_name,created_at,updated_at,version,version_created_at,version_created_by) VALUES
('order_status_changed',NULL,NULL,NULL,NULL,'order_status_changed.html','2020-02-12 19:18:35.0','2020-03-01 09:56:48.0',3,'2020-03-01 09:56:48.0',NULL);

INSERT INTO `message_i18n` (id,locale,title,subject,text_message,html_message)
(SELECT max(id), 'fr_FR','Informer le client du changement de statut de sa commande','Votre commande {$order_ref} chez {config key="store_name"}',NULL,'Bonjour,


Votre commande référence {$order_ref} vient de passer à l''état {$new_status}.'
from `message`);
