-- Portugal

INSERT INTO locales (value, name) VALUES ('pt_PT', 'Portuguese (Portugal)');
INSERT INTO markets (name, vat, currency, price_adjustment)
    VALUES ('PT', 1.23, 'EUR', (select price_adjustment from markets where name = 'PL'));
INSERT INTO market_locales (market_id, locale_id, name) VALUES
    ((SELECT id FROM markets WHERE name = 'PT'), (SELECT id FROM locales WHERE value = 'pt_PT'), 'Portugal');


-- Temporarily add everything in English before replacing with translations
INSERT INTO collections_texts (collection_id, meta_title, meta_description, title, description, slug, locale_id)
SELECT collection_id, meta_title, meta_description, title, description, slug, (SELECT id FROM locales WHERE value = 'pt_PT')
FROM collections_texts WHERE locale_id = (SELECT id FROM locales WHERE value = 'en_US');

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

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

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 = 'pt_PT'), 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 = 'en_US');

INSERT INTO "i18n-texts_data" (textid, text, locale_id)
    SELECT textid, text, (select id from locales where value = 'pt_PT')
        FROM "i18n-texts_data" WHERE locale_id = (SELECT id FROM locales WHERE value = 'en_US');


CREATE SEQUENCE "order-invoiceIdPT" start 1000;


INSERT INTO product_blacklist (product_id, group_id, market_id)
    SELECT product_id, group_id, (select id from markets where name = 'PT')
    FROM product_blacklist WHERE market_id = (select id from markets where name = 'GLOBAL');
