-- P5-6976 Add Canadian collections_texts, designer_texts, categorydata

INSERT INTO collections_texts
    (locale_id, collection_id, meta_title, meta_description, title, description, slug)
        SELECT
            (SELECT id FROM locales WHERE value = 'fr_CA'),
            collection_id, meta_title, meta_description, title, description, slug
        FROM collections_texts
        WHERE locale_id = (SELECT id FROM locales WHERE value = 'fr_FR')
ON CONFLICT DO NOTHING;

INSERT INTO collections_texts
    (locale_id, collection_id, meta_title, meta_description, title, description, slug)
        SELECT
            (SELECT id FROM locales WHERE value = 'en_CA'),
            collection_id, meta_title, meta_description, title, description, slug
        FROM collections_texts
        WHERE locale_id = (SELECT id FROM locales WHERE value = 'en_US')
ON CONFLICT DO NOTHING;

INSERT INTO designer_texts (locale_id, designerid, header, description)
    SELECT
        (SELECT id FROM locales WHERE value = 'fr_CA'),
        designerid, header, description
    FROM designer_texts
    WHERE locale_id = (SELECT id FROM locales WHERE value = 'fr_FR')
ON CONFLICT DO NOTHING;

INSERT INTO designer_texts (locale_id, designerid, header, description)
    SELECT
        (SELECT id FROM locales WHERE value = 'en_CA'),
        designerid, header, description
    FROM designer_texts
    WHERE locale_id = (SELECT id FROM locales WHERE value = 'en_US')
ON CONFLICT DO NOTHING;

INSERT INTO categorydata (locale_id, category_id, datakey_id, text) SELECT
    (SELECT id FROM locales WHERE value = 'fr_CA'), category_id, datakey_id, text
    FROM categorydata WHERE locale_id = (SELECT id FROM locales WHERE value = 'fr_FR')
    ON CONFLICT DO NOTHING;

INSERT INTO categorydata (locale_id, category_id, datakey_id, text) SELECT
    (SELECT id FROM locales WHERE value = 'en_CA'), category_id, datakey_id, text
    FROM categorydata WHERE locale_id = (SELECT id FROM locales WHERE value = 'en_US')
    ON CONFLICT DO NOTHING;

