-- Add belgium market with texts from NL and FR

INSERT INTO locales (value, name) VALUES ('fr_BE', 'French (Belgium)');
INSERT INTO locales (value, name) VALUES ('nl_BE', 'Dutch (Belgium)');

INSERT INTO markets (name, locale_id, vat, currency, price_adjustment) VALUES ('BE', (SELECT id FROM locales WHERE value = 'fr_BE'), 1.21, 'EUR', 1.15);

INSERT INTO market_locales (market_id, locale_id, name)
    VALUES ((SELECT id FROM markets WHERE name = 'BE'),
            (SELECT id FROM locales WHERE value = 'fr_BE'),
            'Belgium (French)');

INSERT INTO market_locales (market_id, locale_id, name)
    VALUES ((SELECT id FROM markets WHERE name = 'BE'),
            (SELECT id FROM locales WHERE value = 'nl_BE'),
            'Belgium (Dutch)');


-- collection_texts
INSERT INTO collections_texts
   (locale_id, collection_id, meta_title, meta_description, title, description, slug)
    SELECT
      (SELECT id FROM locales WHERE value = 'fr_BE'), collection_id, meta_title, meta_description, title, description, slug
    FROM collections_texts WHERE locale_id = (SELECT id FROM locales WHERE value = 'fr_FR');

INSERT INTO collections_texts
   (locale_id, collection_id, meta_title, meta_description, title, description, slug)
    SELECT
      (SELECT id FROM locales WHERE value = 'nl_BE'), collection_id, meta_title, meta_description, title, description, slug
    FROM collections_texts WHERE locale_id = (SELECT id FROM locales WHERE value = 'nl_NL');


-- designer texts
INSERT INTO designer_texts (locale_id, designerid, header, description)
  SELECT
    (SELECT id FROM locales WHERE value = 'nl_BE'), designerid, header, description
    FROM designer_texts WHERE locale_id = (SELECT id FROM locales WHERE value = 'nl_NL');

INSERT INTO designer_texts (locale_id, designerid, header, description)
  SELECT
    (SELECT id FROM locales WHERE value = 'fr_BE'), designerid, header, description
    FROM designer_texts WHERE locale_id = (SELECT id FROM locales WHERE value = 'fr_FR');


-- text tags
INSERT INTO "i18n-texts_data" (locale_id, textid, text)
  SELECT
    (SELECT id FROM locales WHERE value = 'fr_BE'), textid, text
    FROM "i18n-texts_data" WHERE locale_id = (SELECT id FROM locales WHERE value = 'fr_FR');

INSERT INTO "i18n-texts_data" (locale_id, textid, text)
  SELECT
    (SELECT id FROM locales WHERE value = 'nl_BE'), textid, text
    FROM "i18n-texts_data" WHERE locale_id = (SELECT id FROM locales WHERE value = 'nl_NL');

-- categorydata
INSERT INTO categorydata (locale_id, category_id, datakey_id, text)
  SELECT
    (SELECT id FROM locales WHERE value = 'fr_BE'), category_id, datakey_id, text
    FROM categorydata WHERE locale_id = (SELECT id FROM locales WHERE value = 'fr_FR');

INSERT INTO categorydata (locale_id, category_id, datakey_id, text)
  SELECT
    (SELECT id FROM locales WHERE value = 'nl_BE'), category_id, datakey_id, text
    FROM categorydata WHERE locale_id = (SELECT id FROM locales WHERE value = 'nl_NL');

-- category_texts
INSERT INTO category_texts (locale_id, category_id, wallpaper_name, wallpaper_h1, wallpaper_description, canvas_name, canvas_h1, canvas_description, name, design_wallpaper_h1, design_wallpaper_description, poster_name, poster_h1, poster_description, framed_print_name, framed_print_h1, framed_print_description)
  SELECT
    (SELECT id FROM locales WHERE value = 'fr_BE'), category_id, wallpaper_name, wallpaper_h1, wallpaper_description, canvas_name, canvas_h1, canvas_description, name, design_wallpaper_h1, design_wallpaper_description, poster_name, poster_h1, poster_description, framed_print_name, framed_print_h1, framed_print_description
    FROM category_texts WHERE locale_id = (SELECT id FROM locales WHERE value = 'fr_FR');

INSERT INTO category_texts (locale_id, category_id, wallpaper_name, wallpaper_h1, wallpaper_description, canvas_name, canvas_h1, canvas_description, name, design_wallpaper_h1, design_wallpaper_description, poster_name, poster_h1, poster_description, framed_print_name, framed_print_h1, framed_print_description)
  SELECT
    (SELECT id FROM locales WHERE value = 'nl_BE'), category_id, wallpaper_name, wallpaper_h1, wallpaper_description, canvas_name, canvas_h1, canvas_description, name, design_wallpaper_h1, design_wallpaper_description, poster_name, poster_h1, poster_description, framed_print_name, framed_print_h1, framed_print_description
    FROM category_texts WHERE locale_id = (SELECT id FROM locales WHERE value = 'nl_NL');
