-- Add New Zealand

INSERT INTO locales (value, name, fallback_id) VALUES
    ('en_NZ', 'English (New Zealand)', (select id from locales where value = 'en_GB'));

INSERT INTO markets (name, vat, currency, price_adjustment) VALUES ('NZ', 1.0, 'USD', (select price_adjustment from markets where name = 'AU'));

INSERT INTO market_locales (market_id, locale_id, name) VALUES
    ((SELECT id FROM markets WHERE name = 'NZ'), (SELECT id FROM locales WHERE value = 'en_NZ'), 'New Zealand');

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 = 'en_NZ')
    FROM collections_texts WHERE locale_id = (SELECT id FROM locales WHERE value = 'en_AU');

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

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

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 = 'en_NZ'), 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_AU');

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

INSERT INTO "delivery-methods_prices" (territory, currency, option, option_value, price, method) VALUES
	('NZ', 'USD', '', '', 0, (select id from "delivery-methods" where name = 'fedexStandardWorld')),
	('NZ', 'USD', '', '', 7, (select id from "delivery-methods" where name = 'fedexExpressWorld'));

CREATE SEQUENCE "order-invoiceIdNZ" start 1000;
