Skip to content

Instantly share code, notes, and snippets.

@dzhuryn
Created June 13, 2023 10:30
Show Gist options
  • Save dzhuryn/d457e0350d718bb18d4fea925d9f005c to your computer and use it in GitHub Desktop.
Save dzhuryn/d457e0350d718bb18d4fea925d9f005c to your computer and use it in GitHub Desktop.
test
-- DROP function test2;
CREATE OR REPLACE FUNCTION test2() RETURNS void AS $$
DECLARE
siteId integer;
attributeId int;
enumId int;
BEGIN
FOR siteId IN select id from site LOOP
attributeId := (select id from attribute where site_id = siteId and slug = 'cls_opt_current_country');
INSERT INTO attribute_enum (id, value, sort_order, uuid, attribute_id) VALUES (nextval('attribute_enum_id_seq'), 'bd', 66, 'fdc6f46f-71d7-4112-aec2-611529e5461e', attributeId);
enumId := (select id from attribute_enum where attribute_id = attributeId and value = 'bd');
INSERT INTO attribute_enum_l10n (id, name, localizable_id, locale) VALUES (NEXTVAL('attribute_enum_l10n_id_seq'), 'Bangladesh', enumId, 'en_US');
attributeId := (select id from attribute where site_id = siteId and slug = 'cls_opt_country');
INSERT INTO attribute_enum (id, value, sort_order, uuid, attribute_id) VALUES (nextval('attribute_enum_id_seq'), 'bd', 64, '90caebac-38e9-4eb9-a483-7ebba8116ffa', attributeId);
enumId := (select id from attribute_enum where attribute_id = attributeId and value = 'bd');
INSERT INTO attribute_enum_l10n (id, name, localizable_id, locale) VALUES (NEXTVAL('attribute_enum_l10n_id_seq'), 'Bangladesh', enumId, 'en_US');
END LOOP;
END;
$$ LANGUAGE plpgsql;
DO $$ BEGIN
PERFORM "test2"();
END $$;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment