File indexing completed on 2024-04-21 06:00:36

0001 CREATE TABLE `config_store_tag`
0002 (
0003     `config_store_tag_id` INT(11)         NOT NULL AUTO_INCREMENT,
0004     `store_id`            INT(11)         NOT NULL,
0005     `tag_id`              INT(11)         NOT NULL,
0006     `is_active`           INT(1) UNSIGNED NOT NULL DEFAULT '1',
0007     `created_at`          DATETIME        NULL     DEFAULT NULL,
0008     `changed_at`          DATETIME        NULL     DEFAULT NULL,
0009     `deleted_at`          DATETIME        NULL     DEFAULT NULL,
0010     PRIMARY KEY (`config_store_tag_id`)
0011 )
0012 ;
0013 
0014 
0015 CREATE TRIGGER `config_store_tag_before_insert`
0016     BEFORE INSERT
0017     ON `config_store_tag`
0018     FOR EACH ROW
0019 BEGIN
0020     IF `NEW`.`created_at` IS NULL THEN
0021         SET `NEW`.`created_at` = NOW();
0022     END IF;
0023 END;
0024 
0025 
0026 INSERT INTO `config_store_tag`
0027 
0028 SELECT NULL               AS `config_store_tag_id`,
0029        `s`.`store_id`     AS `store_id`,
0030        `s`.`package_type` AS `tag_id`,
0031        1                  AS `is_active`,
0032        NULL               AS `created_at`,
0033        NULL               AS `changed_at`,
0034        NULL               AS `deleted_at`
0035 FROM `config_store` `s`
0036 WHERE `s`.`package_type` IS NOT NULL;
0037 
0038 
0039