Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ALTER TABLE `images`
- ADD INDEX `md5_hash` (`md5_hash`);
- DELETE FROM products_images WHERE products_attributes_id = 0 OR image_name = '';
- INSERT INTO images (name, md5_hash)
- SELECT t.image_name, t.hash
- FROM (
- SELECT MIN(pi.image_name) AS image_name, pi.hash
- FROM products_images pi
- LEFT JOIN images i ON i.md5_hash = pi.hash
- WHERE i.images_id IS NULL AND pi.hash IS NOT NULL
- GROUP BY pi.hash
- ) t;
- UPDATE products_images pi
- JOIN images i ON i.md5_hash = pi.hash
- SET pi.images_id = i.images_id
- WHERE pi.images_id IS NULL
- ;
- UPDATE products_images pi
- JOIN (
- SELECT pi.products_attributes_id, MAX(COALESCE(pi1.image_nr, 0))+1 AS image_nr, MIN(pi1.images_id) AS min_image
- FROM products_images pi
- JOIN products_images pi1 ON pi1.products_attributes_id = pi.products_attributes_id
- WHERE pi.image_nr IS NULL
- GROUP BY pi.products_attributes_id
- ) t ON t.products_attributes_id = pi.products_attributes_id AND pi.images_id = t.min_image
- SET pi.image_nr = t.image_nr
- WHERE pi.image_nr IS NULL;
- UPDATE products_images pi
- JOIN (
- SELECT pi.products_attributes_id, MAX(COALESCE(pi1.image_nr, 0))+1 AS image_nr
- FROM products_images pi
- JOIN products_images pi1 ON pi1.products_attributes_id = pi.products_attributes_id
- WHERE pi.image_nr IS NULL
- GROUP BY pi.products_attributes_id
- ) t ON t.products_attributes_id = pi.products_attributes_id
- SET pi.image_nr = t.image_nr
- WHERE pi.image_nr IS NULL;
- ALTER TABLE call_rating_criterion ADD call_rating_criterion_prev_id INT NOT NULL DEFAULT 0 COMMENT 'Идентификатор критерия замещённого данным' AFTER call_rating_criterion_id;
- CREATE INDEX call_rating_criterion_prev_id_idx ON call_rating_criterion (call_rating_criterion_prev_id);
- ALTER TABLE call_rating_illegal_events CHANGE COLUMN `events_rating_type` `events_rating_type` enum('CALL','MAIL','CALLBACK','BRAND') NOT NULL DEFAULT 'CALL';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement