Guest User

Untitled

a guest
Jul 22nd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. update products set main_image_id = (
  2. select id as image_id from images where
  3. owner_type = 'Product' and owner_id = products.id and main = true
  4. limit 1
  5. )
  6.  
  7.  
  8. update products set main_category_id = (
  9. SELECT min(category_id) FROM category_products where product_id=products.id
  10. group by product_id
  11. )
  12.  
  13. update product_vendors set main_category_id = (
  14. SELECT min(category_id) FROM category_product_vendors where product_vendor_id=product_vendors.id
  15. group by product_vendor_id
  16. )
  17.  
  18. DELETE cl FROM category_languages cl
  19. INNER JOIN (
  20. select max(id) AS id, count(*) AS count from category_languages group by category_id, locale
  21. ) duplicates
  22. ON (cl.id = duplicates.id AND duplicates.count > 1);
Add Comment
Please, Sign In to add comment