From 4bf8b0bf0d3c95a267817430be0d9d2f04851dc0 Mon Sep 17 00:00:00 2001 From: jordi fita mas Date: Sat, 29 Jul 2023 04:25:56 +0200 Subject: [PATCH] Add company and company_user relations, along with their dependencies --- debian/control | 6 +- demo.sql | 9 + deploy/available_countries.sql | 767 +++++++++++++++++++++++++ deploy/available_currencies.sql | 12 + deploy/company.sql | 42 ++ deploy/company_user.sql | 39 ++ deploy/country.sql | 19 + deploy/country_code.sql | 15 + deploy/country_i18n.sql | 22 + deploy/currency.sql | 19 + deploy/currency_code.sql | 15 + deploy/extension_pg_libphonenumber.sql | 8 + deploy/extension_uri.sql | 8 + deploy/extension_vat.sql | 8 + revert/available_countries.sql | 8 + revert/available_currencies.sql | 7 + revert/company.sql | 7 + revert/company_user.sql | 8 + revert/country.sql | 7 + revert/country_code.sql | 7 + revert/country_i18n.sql | 7 + revert/currency.sql | 7 + revert/currency_code.sql | 7 + revert/extension_pg_libphonenumber.sql | 7 + revert/extension_uri.sql | 7 + revert/extension_vat.sql | 7 + sqitch.plan | 12 + test/company.sql | 203 +++++++ test/company_user.sql | 39 ++ test/country.sql | 40 ++ test/country_code.sql | 38 ++ test/country_i18n.sql | 44 ++ test/currency.sql | 41 ++ test/currency_code.sql | 39 ++ test/extensions.sql | 3 + verify/available_countries.sql | 756 ++++++++++++++++++++++++ verify/available_currencies.sql | 21 + verify/company.sql | 26 + verify/company_user.sql | 13 + verify/country.sql | 11 + verify/country_code.sql | 7 + verify/country_i18n.sql | 11 + verify/currency.sql | 11 + verify/currency_code.sql | 7 + verify/extension_pg_libphonenumber.sql | 7 + verify/extension_uri.sql | 7 + verify/extension_vat.sql | 7 + 47 files changed, 2417 insertions(+), 1 deletion(-) create mode 100644 deploy/available_countries.sql create mode 100644 deploy/available_currencies.sql create mode 100644 deploy/company.sql create mode 100644 deploy/company_user.sql create mode 100644 deploy/country.sql create mode 100644 deploy/country_code.sql create mode 100644 deploy/country_i18n.sql create mode 100644 deploy/currency.sql create mode 100644 deploy/currency_code.sql create mode 100644 deploy/extension_pg_libphonenumber.sql create mode 100644 deploy/extension_uri.sql create mode 100644 deploy/extension_vat.sql create mode 100644 revert/available_countries.sql create mode 100644 revert/available_currencies.sql create mode 100644 revert/company.sql create mode 100644 revert/company_user.sql create mode 100644 revert/country.sql create mode 100644 revert/country_code.sql create mode 100644 revert/country_i18n.sql create mode 100644 revert/currency.sql create mode 100644 revert/currency_code.sql create mode 100644 revert/extension_pg_libphonenumber.sql create mode 100644 revert/extension_uri.sql create mode 100644 revert/extension_vat.sql create mode 100644 test/company.sql create mode 100644 test/company_user.sql create mode 100644 test/country.sql create mode 100644 test/country_code.sql create mode 100644 test/country_i18n.sql create mode 100644 test/currency.sql create mode 100644 test/currency_code.sql create mode 100644 verify/available_countries.sql create mode 100644 verify/available_currencies.sql create mode 100644 verify/company.sql create mode 100644 verify/company_user.sql create mode 100644 verify/country.sql create mode 100644 verify/country_code.sql create mode 100644 verify/country_i18n.sql create mode 100644 verify/currency.sql create mode 100644 verify/currency_code.sql create mode 100644 verify/extension_pg_libphonenumber.sql create mode 100644 verify/extension_uri.sql create mode 100644 verify/extension_vat.sql diff --git a/debian/control b/debian/control index cd6ceba..34be225 100644 --- a/debian/control +++ b/debian/control @@ -12,7 +12,11 @@ Build-Depends: golang-golang-x-text-dev, postgresql-all (>= 217~), sqitch, - pgtap + pgtap, + postgresql-15-pg-libphonenumber, + postgresql-15-pgtap, + postgresql-15-pguri, + postgresql-15-vat Standards-Version: 4.6.0 XS-Go-Import-Path: dev.tandem.ws/tandem/camper Vcs-Browser: https://dev.tandem.ws/tandem/camper diff --git a/demo.sql b/demo.sql index 1c75e5b..7c2b5ef 100644 --- a/demo.sql +++ b/demo.sql @@ -8,4 +8,13 @@ values ('demo@camper', 'Demo User', 'demo', 'employee') , ('admin@camper', 'Demo Admin', 'admin', 'admin') ; +alter sequence company_company_id_seq restart with 52; +insert into company (business_name, vatin, trade_name, phone, email, web, address, city, province, postal_code, country_code, currency_code, default_lang_tag, legal_disclaimer) +values ('Càmping les mines, S.L.U.', 'ESB17616756', 'Pescamines', parse_packed_phone_number('972 50 60 70', 'ES'), 'info@lesmines.cat', 'https://lesmines.cat/', 'C/ de l’Hort', 'Castelló d’Empúries', 'Girona', '17486', 'ES', 'EUR', 'ca', 'Càmping les mines, S.L.U. és responsable del tractament de les seves dades d’acord amb el RGPD i la LOPDGDD, i les tracta per a mantenir una relació mercantil/comercial amb vostè. Les conservarà mentre es mantingui aquesta relació i no es comunicaran a tercers. Pot exercir els drets d’accés, rectificació, portabilitat, supressió, limitació i oposició a Càmping les mines, S.L.U., amb domicili Carrer de l’Hort 71, 17486 Castelló d’Empúries o enviant un correu electrònic a info@lesmines.cat. Per a qualsevol reclamació pot acudir a agpd.es. Per a més informació pot consultar la nostra política de privacitat a lesmines.cat.'); + +insert into company_user (company_id, user_id) +values (52, 42) + , (52, 43) +; + commit; diff --git a/deploy/available_countries.sql b/deploy/available_countries.sql new file mode 100644 index 0000000..3739de0 --- /dev/null +++ b/deploy/available_countries.sql @@ -0,0 +1,767 @@ +-- Deploy camper:available_countries to pg +-- requires: schema_camper +-- requires: country +-- requires: country_i18n + +begin; + +-- Downloaded from https://www.ecb.europa.eu/stats/money_credit_banking/anacredit/html/index.en.html +-- Last updated 2022-07-29. +-- Names come from Unicode’s Common Locale Data Repository (CLDR). +insert into camper.country +(country_code, name, postal_code_regex) +values ('AF', 'Afghanistan', '\d{4}') + , ('AX', 'Åland Islands', '.{1,255}') + , ('AL', 'Albania', '\d{4}') + , ('DZ', 'Algeria', '\d{5}') + , ('AS', 'American Samoa', '967\d{2}(-\d{4})?') + , ('AD', 'Andorra', 'AD\d{3}') + , ('AO', 'Angola', '.{1,255}') + , ('AI', 'Anguilla', '(AI-2640)') + , ('AQ', 'Antarctica', '(7151)') + , ('AG', 'Antigua and Barbuda', '.{1,255}') + , ('AR', 'Argentina', '([A-Z]\d{4}[A-Z]{3})|([A-Z]\d{4})') + , ('AM', 'Armenia', '(\d{4})|(\d{6})') + , ('AW', 'Aruba', '.{1,255}') + , ('AU', 'Australia', '\d{4}') + , ('AT', 'Austria', '\d{4}') + , ('AZ', 'Azerbaijan', '(AZ)(\d{4})|(AZ )(\d{4})') + , ('BS', 'Bahamas', '.{1,255}') + , ('BH', 'Bahrain', '\d{3}\d?') + , ('BD', 'Bangladesh', '\d{4}') + , ('BB', 'Barbados', 'BB\d{5}') + , ('BY', 'Belarus', '\d{6}') + , ('BE', 'Belgium', '\d{4}') + , ('PW', 'Belau', '(96939|96940)') + , ('BZ', 'Belize', '.{1,255}') + , ('BJ', 'Benin', '.{1,255}') + , ('BM', 'Bermuda', '[A-Z]{2} \d{2}') + , ('BT', 'Bhutan', '\d{5}') + , ('BO', 'Bolivia', '.{1,255}') + , ('BQ', 'Bonaire, Saint Eustatius and Saba', '.{1,255}') + , ('BA', 'Bosnia and Herzegovina', '\d{5}') + , ('BW', 'Botswana', '.{1,255}') + , ('BV', 'Bouvet Island', '.{1,255}') + , ('BR', 'Brazil', '[0-9]{5}-[0-9]{3}') + , ('IO', 'British Indian Ocean Territory', '(BB9D 1ZZ)') + , ('BN', 'Brunei', '[A-Z]{2}\d{4}') + , ('BG', 'Bulgaria', '\d{4}') + , ('BF', 'Burkina Faso', '[1-9]\d{4}') + , ('BI', 'Burundi', '.{1,255}') + , ('KH', 'Cambodia', '\d{5,6}') + , ('CM', 'Cameroon', '.{1,255}') + , ('CA', 'Canada', '[A-Z][0-9][A-Z] [0-9][A-Z][0-9]') + , ('CV', 'Cape Verde', '\d{4}') + , ('KY', 'Cayman Islands', '[K][Y][0-9]{1}[-]([0-9]){4}') + , ('CF', 'Central African Republic', '.{1,255}') + , ('TD', 'Chad', '.{1,255}') + , ('CL', 'Chile', '\d{7}') + , ('CN', 'China', '\d{6}') + , ('CX', 'Christmas Island', '(6798)') + , ('CC', 'Cocos (Keeling) Islands', '(6799)') + , ('CO', 'Colombia', '\d{6}') + , ('KM', 'Comoros', '.{1,255}') + , ('CG', 'Congo (Brazzaville)', '.{1,255}') + , ('CD', 'Congo (Kinshasa)', '.{1,255}') + , ('CK', 'Cook Islands', '.{1,255}') + , ('CR', 'Costa Rica', '\d{5}') + , ('HR', 'Croatia', '[1-5]\d{4}') + , ('CU', 'Cuba', '(CP)?\d{5}') + , ('CW', 'Curaçao', '.{1,255}') + , ('CY', 'Cyprus', '[1-9]\d{3}') + , ('CZ', 'Czech Republic', '[1-7][0-9]{2} [0-9]{2}|[1-7][0-9]{4}') + , ('DK', 'Denmark', '\d{4}') + , ('DJ', 'Djibouti', '.{1,255}') + , ('DM', 'Dominica', '.{1,255}') + , ('DO', 'Dominican Republic', '\d{5}') + , ('EC', 'Ecuador', '\d{6}') + , ('EG', 'Egypt', '\d{5}') + , ('SV', 'El Salvador', '\d{4}') + , ('GQ', 'Equatorial Guinea', '.{1,255}') + , ('ER', 'Eritrea', '.{1,255}') + , ('EE', 'Estonia', '\d{5}') + , ('ET', 'Ethiopia', '\d{4}') + , ('FK', 'Falkland Islands', '(FIQQ 1ZZ)') + , ('FO', 'Faroe Islands', '\d{3}') + , ('FJ', 'Fiji', '.{1,255}') + , ('FI', 'Finland', '\d{5}') + , ('FR', 'France', '\d{5}') + , ('GF', 'French Guiana', '.{1,255}') + , ('PF', 'French Polynesia', '((987)\d{2})') + , ('TF', 'French Southern Territories', '.{1,255}') + , ('GA', 'Gabon', '.{1,255}') + , ('GM', 'Gambia', '.{1,255}') + , ('GE', 'Georgia', '\d{4}') + , ('DE', 'Germany', '\d{5}') + , ('GH', 'Ghana', '.{1,255}') + , ('GI', 'Gibraltar', '(GX11 1AA)') + , ('GR', 'Greece', '(\d{3}) \d{2}|\d{5}') + , ('GL', 'Greenland', '39\d{2}') + , ('GD', 'Grenada', '.{1,255}') + , ('GP', 'Guadeloupe', '.{1,255}') + , ('GU', 'Guam', '((969)[1-3][0-2])(-\d{4})?') + , ('GT', 'Guatemala', '\d{5}') + , ('GG', 'Guernsey', '(GY)([0-9][0-9A-HJKPS-UW]?|[A-HK-Y][0-9][0-9ABEHMNPRV-Y]?) [0-9][ABD-HJLNP-UW-Z]{2}') + , ('GN', 'Guinea', '\d{3}') + , ('GW', 'Guinea-Bissau', '\d{4}') + , ('GY', 'Guyana', '.{1,255}') + , ('HT', 'Haiti', '(HT)(\d{4})|(HT) (\d{4})') + , ('HM', 'Heard Island and McDonald Islands', '(7151)') + , ('HN', 'Honduras', '\d{5}') + , ('HK', 'Hong Kong', '(999077)') + , ('HU', 'Hungary', '[1-9]\d{3}') + , ('IS', 'Iceland', '[1-9]\d{2}') + , ('IN', 'India', '[1-9]\d{5}') + , ('ID', 'Indonesia', '[1-9]\d{4}') + , ('IR', 'Iran', '\d{5}[\-]?\d{5}') + , ('IQ', 'Iraq', '\d{5}') + , ('IE', 'Ireland', '.{1,255}') + , ('IM', 'Isle of Man', '(IM)([0-9][0-9A-HJKPS-UW]?|[A-HK-Y][0-9][0-9ABEHMNPRV-Y]?) [0-9][ABD-HJLNP-UW-Z]{2}') + , ('IL', 'Israel', '\d{7}') + , ('IT', 'Italy', '\d{5}') + , ('CI', 'Ivory Coast', '.{1,255}') + , ('JM', 'Jamaica', '(JM)[A-Z]{3}\d{2}') + , ('JP', 'Japan', '(\d{3}-\d{4})') + , ('JE', 'Jersey', 'JE[0-9]{1}[\s]([\d][A-Z]{2})') + , ('JO', 'Jordan', '\d{5}') + , ('KZ', 'Kazakhstan', '([A-Z]\d{2}[A-Z]\d[A-Z]\d)|(\d{6})') + , ('KE', 'Kenya', '\d{5}') + , ('KI', 'Kiribati', 'KI\d{4}') + , ('KW', 'Kuwait', '\d{5}') + , ('KG', 'Kyrgyzstan', '\d{6}') + , ('LA', 'Laos', '\d{5}') + , ('LV', 'Latvia', '((LV)[\-])?(\d{4})') + , ('LB', 'Lebanon', '\d{4}( \d{4})?') + , ('LS', 'Lesotho', '\d{3}') + , ('LR', 'Liberia', '\d{4}') + , ('LY', 'Libya', '.{1,255}') + , ('LI', 'Liechtenstein', '\d{4}') + , ('LT', 'Lithuania', '((LT)[\-])?(\d{5})') + , ('LU', 'Luxembourg', '((L)[\-])?(\d{4})') + , ('MO', 'Macao', '.{1,255}') + , ('MK', 'North Macedonia', '\d{4}') + , ('MG', 'Madagascar', '\d{3}') + , ('MW', 'Malawi', '\d{6}') + , ('MY', 'Malaysia', '\d{5}') + , ('MV', 'Maldives', '\d{5}') + , ('ML', 'Mali', '.{1,255}') + , ('MT', 'Malta', '[A-Z]{3} [0-9]{4}|[A-Z]{2}[0-9]{2}|[A-Z]{2} [0-9]{2}|[A-Z]{3}[0-9]{4}|[A-Z]{3}[0-9]{2}|[A-Z]{3} [0-9]{2}') + , ('MH', 'Marshall Islands', '((969)[6-7][0-9])(-\d{4})?') + , ('MQ', 'Martinique', '.{1,255}') + , ('MR', 'Mauritania', '.{1,255}') + , ('MU', 'Mauritius', '([0-9A-R]\d{4})') + , ('YT', 'Mayotte', '.{1,255}') + , ('MX', 'Mexico', '\d{5}') + , ('FM', 'Micronesia', '9694\d{1}(-\d{4})?') + , ('MD', 'Moldova', '(MD[\-]?)?(\d{4})') + , ('MC', 'Monaco', '.{1,255}') + , ('MN', 'Mongolia', '\d{5}') + , ('ME', 'Montenegro', '\d{5}') + , ('MS', 'Montserrat', 'MSR\d{4}') + , ('MA', 'Morocco', '[1-9]\d{4}') + , ('MZ', 'Mozambique', '\d{4}') + , ('MM', 'Myanmar', '\d{5}') + , ('NA', 'Namibia', '\d{5}') + , ('NR', 'Nauru', '(NRU68)') + , ('NP', 'Nepal', '\d{5}') + , ('NL', 'Netherlands', '[1-9]\d{3} [A-Z]{2}|[1-9]\d{3}[A-Z]{2}') + , ('NC', 'New Caledonia', '988\d{2}') + , ('NZ', 'New Zealand', '\d{4}') + , ('NI', 'Nicaragua', '\d{5}') + , ('NE', 'Niger', '\d{4}') + , ('NG', 'Nigeria', '[1-9]\d{5}') + , ('NU', 'Niue', '(9974)') + , ('NF', 'Norfolk Island', '(2899)') + , ('MP', 'Northern Mariana Islands', '9695\d{1}(-\d{4})?') + , ('KP', 'North Korea', '.{1,255}') + , ('NO', 'Norway', '\d{4}') + , ('OM', 'Oman', '\d{3}') + , ('PK', 'Pakistan', '[1-9]\d{4}') + , ('PS', 'Palestinian Territory', '(P[1-9]\d{6})|(\d{3}-\d{3})') + , ('PA', 'Panama', '\d{4}') + , ('PG', 'Papua New Guinea', '\d{3}') + , ('PY', 'Paraguay', '\d{4}') + , ('PE', 'Peru', '\d{5}') + , ('PH', 'Philippines', '\d{4}') + , ('PN', 'Pitcairn', '(PCR9 1ZZ)') + , ('PL', 'Poland', '[0-9]{2}[-]([0-9]){3}') + , ('PT', 'Portugal', '[1-9]\d{3}((-)\d{3})') + , ('PR', 'Puerto Rico', '.{1,255}') + , ('QA', 'Qatar', '.{1,255}') + , ('RE', 'Reunion', '.{1,255}') + , ('RO', 'Romania', '\d{6}') + , ('RU', 'Russia', '\d{6}') + , ('RW', 'Rwanda', '.{1,255}') + , ('BL', 'Saint Barthélemy', '.{1,255}') + , ('SH', 'Saint Helena', '(ASCN 1ZZ|TDCU 1ZZ|STHL 1ZZ)') + , ('KN', 'Saint Kitts and Nevis', 'KN\d{4}(\-\d{4})?') + , ('LC', 'Saint Lucia', 'LC\d{2} \d{3}') + , ('MF', 'Saint Martin (French part)', '.{1,255}') + , ('SX', 'Saint Martin (Dutch part)', '.{1,255}') + , ('PM', 'Saint Pierre and Miquelon', '.{1,255}') + , ('VC', 'Saint Vincent and the Grenadines', '(VC)(\d{4})') + , ('SM', 'San Marino', '(4789\d)') + , ('ST', 'São Tomé and Príncipe', '.{1,255}') + , ('SA', 'Saudi Arabia', '[1-8]\d{4}([\-]\d{4})?') + , ('SN', 'Senegal', '[1-8]\d{4}') + , ('RS', 'Serbia', '\d{5,6}') + , ('SC', 'Seychelles', '.{1,255}') + , ('SL', 'Sierra Leone', '.{1,255}') + , ('SG', 'Singapore', '\d{6}') + , ('SK', 'Slovakia', '(\d{3} \d{2})|\d{5}') + , ('SI', 'Slovenia', '[1-9]\d{3}') + , ('SB', 'Solomon Islands', '.{1,255}') + , ('SO', 'Somalia', '.{1,255}') + , ('ZA', 'South Africa', '\d{4}') + , ('GS', 'South Georgia/Sandwich Islands', '(SIQQ 1ZZ)') + , ('KR', 'South Korea', '\d{5}') + , ('SS', 'South Sudan', '\d{5}') + , ('ES', 'Spain', '\d{5}') + , ('LK', 'Sri Lanka', '\d{5}') + , ('SD', 'Sudan', '\d{5}') + , ('SR', 'Suriname', '.{1,255}') + , ('SJ', 'Svalbard and Jan Mayen', '.{1,255}') + , ('SZ', 'Eswatini', '([A-Z]\d{3})') + , ('SE', 'Sweden', '[1-9]\d{2} \d{2}') + , ('CH', 'Switzerland', '[1-9]\d{3}') + , ('SY', 'Syria', '.{1,255}') + , ('TW', 'Taiwan', '(\d{3}\-\d{3})|(\d{3}[-]\d{2})|(\d{6})|(\d{3})') + , ('TJ', 'Tajikistan', '7\d{5}') + , ('TZ', 'Tanzania', '\d{5}') + , ('TH', 'Thailand', '\d{5}') + , ('TL', 'Timor-Leste', '.{1,255}') + , ('TG', 'Togo', '.{1,255}') + , ('TK', 'Tokelau', '.{1,255}') + , ('TO', 'Tonga', '.{1,255}') + , ('TT', 'Trinidad and Tobago', '\d{6}') + , ('TN', 'Tunisia', '\d{4}') + , ('TR', 'Turkey', '\d{5}') + , ('TM', 'Turkmenistan', '7\d{5}') + , ('TC', 'Turks and Caicos Islands', '(TKCA 1ZZ)') + , ('TV', 'Tuvalu', '.{1,255}') + , ('UG', 'Uganda', '.{1,255}') + , ('UA', 'Ukraine', '\d{5}') + , ('AE', 'United Arab Emirates', '.{1,255}') + , ('GB', 'United Kingdom (UK)', '([G][I][R] 0[A]{2})|((([A-Z][0-9]{1,2})|(([A-Z][A-HJ-Y][0-9]{1,2})|(([A-Z][0-9][A-Z])|([A-Z][A-HJ-Y][0-9]?[A-Z])))) [0-9][A-Z]{2})') + , ('US', 'United States (US)', '\d{5}(-\d{4})?') + , ('UM', 'United States (US) Minor Outlying Islands', '.{1,255}') + , ('UY', 'Uruguay', '[1-9]\d{4}') + , ('UZ', 'Uzbekistan', '\d{6}') + , ('VU', 'Vanuatu', '.{1,255}') + , ('VA', 'Vatican', '(00120)') + , ('VE', 'Venezuela', '[1-8]\d{3}') + , ('VN', 'Vietnam', '\d{6}') + , ('VG', 'Virgin Islands (British)', '(VG11)[0-6][0]') + , ('VI', 'Virgin Islands (US)', '008\d{2}(-\d{4})?') + , ('WF', 'Wallis and Futuna', '(986)\d{2}') + , ('EH', 'Western Sahara', '.{1,255}') + , ('WS', 'Samoa', 'WS[1-2]\d{3}') + , ('YE', 'Yemen', '.{1,255}') + , ('ZM', 'Zambia', '\d{5}') + , ('ZW', 'Zimbabwe', '.{1,255}') +; + +-- Translation from WooCommerce +insert into camper.country_i18n +(country_code, lang_tag, name) +values ('AD', 'ca', 'Andorra') + , ('AD', 'es', 'Andorra') + , ('AE', 'ca', 'Emirats Àrabs Units') + , ('AE', 'es', 'Emiratos Árabes Unidos') + , ('AF', 'ca', 'Afganistan') + , ('AF', 'es', 'Afganistán') + , ('AG', 'ca', 'Antigua i Barbuda') + , ('AG', 'es', 'Antigua y Barbuda') + , ('AI', 'ca', 'Anguilla') + , ('AI', 'es', 'Anguilla') + , ('AL', 'ca', 'Albània') + , ('AL', 'es', 'Albania') + , ('AM', 'ca', 'Armènia') + , ('AM', 'es', 'Armenia') + , ('AO', 'ca', 'Angola') + , ('AO', 'es', 'Angola') + , ('AQ', 'ca', 'Antàrtida') + , ('AQ', 'es', 'Antártida') + , ('AR', 'ca', 'Argentina') + , ('AR', 'es', 'Argentina') + , ('AS', 'ca', 'Samoa Nord-americana') + , ('AS', 'es', 'Samoa Americana') + , ('AT', 'ca', 'Àustria') + , ('AT', 'es', 'Austria') + , ('AU', 'ca', 'Austràlia') + , ('AU', 'es', 'Australia') + , ('AW', 'ca', 'Aruba') + , ('AW', 'es', 'Aruba') + , ('AX', 'ca', 'Illes Åland') + , ('AX', 'es', 'Islas Åland') + , ('AZ', 'ca', 'Azerbaidjan') + , ('AZ', 'es', 'Azerbaijan') + , ('BA', 'ca', 'Bòsnia i Hercegovina') + , ('BA', 'es', 'Bosnia y Herzegovina') + , ('BB', 'ca', 'Barbados') + , ('BB', 'es', 'Barbados') + , ('BD', 'ca', 'Bangladesh') + , ('BD', 'es', 'Bangladesh') + , ('BE', 'ca', 'Bèlgica') + , ('BE', 'es', 'Bélgica') + , ('BF', 'ca', 'Burkina Fasso') + , ('BF', 'es', 'Burkina Faso') + , ('BG', 'ca', 'Bulgària') + , ('BG', 'es', 'Bulgaria') + , ('BH', 'ca', 'Bahrain') + , ('BH', 'es', 'Bahrain') + , ('BI', 'ca', 'Burundi') + , ('BI', 'es', 'Burundi') + , ('BJ', 'ca', 'Benín') + , ('BJ', 'es', 'Benin') + , ('BL', 'ca', 'Saint-Barthélemy') + , ('BL', 'es', 'San Bartolomé') + , ('BM', 'ca', 'Bermuda') + , ('BM', 'es', 'Bermuda') + , ('BN', 'ca', 'Brunei') + , ('BN', 'es', 'Brunéi') + , ('BO', 'ca', 'Bolívia') + , ('BO', 'es', 'Bolivia') + , ('BQ', 'ca', 'Bonaire, Saint Eustatius and Saba') + , ('BQ', 'es', 'Bonaire, San Eustaquio y Saba') + , ('BR', 'ca', 'Brasil') + , ('BR', 'es', 'Brasil') + , ('BS', 'ca', 'Bahames') + , ('BS', 'es', 'Bahamas') + , ('BT', 'ca', 'Bhutan') + , ('BT', 'es', 'Bhutan') + , ('BV', 'ca', 'Illa Bouvet') + , ('BV', 'es', 'Isla Bouvet') + , ('BW', 'ca', 'Botswana') + , ('BW', 'es', 'Botswana') + , ('BY', 'ca', 'Bielorússia') + , ('BY', 'es', 'Bielorrusia') + , ('BZ', 'ca', 'Belize') + , ('BZ', 'es', 'Belize') + , ('CA', 'ca', 'Canadà') + , ('CA', 'es', 'Canadá') + , ('CC', 'ca', 'Illes Cocos (Keeling)') + , ('CC', 'es', 'Islas Cocos') + , ('CD', 'ca', 'Congo (Kinshasa)') + , ('CD', 'es', 'Congo (Kinshasa)') + , ('CF', 'ca', 'República Centreafricana') + , ('CF', 'es', 'República Centroafricana') + , ('CG', 'ca', 'Congo (Brazzaville)') + , ('CG', 'es', 'Congo (Brazzaville)') + , ('CH', 'ca', 'Suïssa') + , ('CH', 'es', 'Suiza') + , ('CI', 'ca', 'Costa d’Ivori') + , ('CI', 'es', 'Costa de Marfil') + , ('CK', 'ca', 'Illes Cook') + , ('CK', 'es', 'Islas Cook') + , ('CL', 'ca', 'Xile') + , ('CL', 'es', 'Chile') + , ('CM', 'ca', 'Camerun') + , ('CM', 'es', 'Camerún') + , ('CN', 'ca', 'Xina') + , ('CN', 'es', 'China') + , ('CO', 'ca', 'Colòmbia') + , ('CO', 'es', 'Colombia') + , ('CR', 'ca', 'Costa Rica') + , ('CR', 'es', 'Costa Rica') + , ('CU', 'ca', 'Cuba') + , ('CU', 'es', 'Cuba') + , ('CV', 'ca', 'Cap Verd') + , ('CV', 'es', 'Cabo Verde') + , ('CW', 'ca', 'Curaçao') + , ('CW', 'es', 'Curaçao') + , ('CX', 'ca', 'Illa Christmas') + , ('CX', 'es', 'Isla de Navidad') + , ('CY', 'ca', 'Xipre') + , ('CY', 'es', 'Chipre') + , ('CZ', 'ca', 'República Txeca') + , ('CZ', 'es', 'República Checa') + , ('DE', 'ca', 'Alemanya') + , ('DE', 'es', 'Alemania') + , ('DJ', 'ca', 'Djibouti') + , ('DJ', 'es', 'Djibouti') + , ('DK', 'ca', 'Dinamarca') + , ('DK', 'es', 'Dinamarca') + , ('DM', 'ca', 'Dominica') + , ('DM', 'es', 'Dominica') + , ('DO', 'ca', 'República Dominicana') + , ('DO', 'es', 'República Dominicana') + , ('DZ', 'ca', 'Algèria') + , ('DZ', 'es', 'Argelia') + , ('EC', 'ca', 'Equador') + , ('EC', 'es', 'Ecuador') + , ('EE', 'ca', 'Estònia') + , ('EE', 'es', 'Estonia') + , ('EG', 'ca', 'Egipte') + , ('EG', 'es', 'Egipto') + , ('EH', 'ca', 'Sàhara Occidental') + , ('EH', 'es', 'Sahara Occidental') + , ('ER', 'ca', 'Eritrea') + , ('ER', 'es', 'Eritrea') + , ('ES', 'ca', 'Espanya') + , ('ES', 'es', 'España') + , ('ET', 'ca', 'Etiòpia') + , ('ET', 'es', 'Etiopía') + , ('FI', 'ca', 'Finlàndia') + , ('FI', 'es', 'Finlandia') + , ('FJ', 'ca', 'Fiji') + , ('FJ', 'es', 'Fiyi') + , ('FK', 'ca', 'Illes Falkland') + , ('FK', 'es', 'Islas Malvinas') + , ('FM', 'ca', 'Micronèsia') + , ('FM', 'es', 'Micronesia') + , ('FO', 'ca', 'Illes Faroe') + , ('FO', 'es', 'Islas Feroe') + , ('FR', 'ca', 'França') + , ('FR', 'es', 'Francia') + , ('GA', 'ca', 'Gabon') + , ('GA', 'es', 'Gabón') + , ('GB', 'ca', 'Regne Unit (UK)') + , ('GB', 'es', 'Reino Unido (UK)') + , ('GD', 'ca', 'Grenada') + , ('GD', 'es', 'Granada') + , ('GE', 'ca', 'Geòrgia') + , ('GE', 'es', 'Georgia') + , ('GF', 'ca', 'Guaiana Francesa') + , ('GF', 'es', 'Guayana Francesa') + , ('GG', 'ca', 'Guernsey') + , ('GG', 'es', 'Guernsey') + , ('GH', 'ca', 'Ghana') + , ('GH', 'es', 'Ghana') + , ('GI', 'ca', 'Gibraltar') + , ('GI', 'es', 'Gibraltar') + , ('GL', 'ca', 'Groenlàndia') + , ('GL', 'es', 'Groenlandia') + , ('GM', 'ca', 'Gàmbia') + , ('GM', 'es', 'Gambia') + , ('GN', 'ca', 'Guinea') + , ('GN', 'es', 'Guinea') + , ('GP', 'ca', 'Guadalupe') + , ('GP', 'es', 'Guadalupe') + , ('GQ', 'ca', 'Guinea Equatorial') + , ('GQ', 'es', 'Guinea Ecuatorial') + , ('GR', 'ca', 'Grècia') + , ('GR', 'es', 'Grecia') + , ('GS', 'ca', 'Illes Geòrgia del Sud i Sandwich del Sud') + , ('GS', 'es', 'Islas Georgias y Sandwich del Sur') + , ('GT', 'ca', 'Guatemala') + , ('GT', 'es', 'Guatemala') + , ('GU', 'ca', 'Guam') + , ('GU', 'es', 'Guam') + , ('GW', 'ca', 'Guinea Bissau') + , ('GW', 'es', 'Guinea-Bisáu') + , ('GY', 'ca', 'Guyana') + , ('GY', 'es', 'Guyana') + , ('HK', 'ca', 'Hong Kong') + , ('HK', 'es', 'Hong Kong') + , ('HM', 'ca', 'Illes Heard i McDonald') + , ('HM', 'es', 'Islas Heard y McDonald') + , ('HN', 'ca', 'Hondures') + , ('HN', 'es', 'Honduras') + , ('HR', 'ca', 'Croàcia') + , ('HR', 'es', 'Croacia') + , ('HT', 'ca', 'Haití') + , ('HT', 'es', 'Haití') + , ('HU', 'ca', 'Hongria') + , ('HU', 'es', 'Hungría') + , ('ID', 'ca', 'Indonèsia') + , ('ID', 'es', 'Indonesia') + , ('IE', 'ca', 'Irlanda') + , ('IE', 'es', 'Irlanda') + , ('IL', 'ca', 'Israel') + , ('IL', 'es', 'Israel') + , ('IM', 'ca', 'Illa de Man') + , ('IM', 'es', 'Isla de Man') + , ('IN', 'ca', 'Índia') + , ('IN', 'es', 'India') + , ('IO', 'ca', 'Territori Britànic de l’Oceà Índic') + , ('IO', 'es', 'Territorio Británico del Océano Índico') + , ('IQ', 'ca', 'Iraq') + , ('IQ', 'es', 'Irak') + , ('IR', 'ca', 'Iran') + , ('IR', 'es', 'Irán') + , ('IS', 'ca', 'Islàndia') + , ('IS', 'es', 'Islandia') + , ('IT', 'ca', 'Itàlia') + , ('IT', 'es', 'Italia') + , ('JE', 'ca', 'Jersey') + , ('JE', 'es', 'Jersey') + , ('JM', 'ca', 'Jamaica') + , ('JM', 'es', 'Jamaica') + , ('JO', 'ca', 'Jordània') + , ('JO', 'es', 'Jordania') + , ('JP', 'ca', 'Japó') + , ('JP', 'es', 'Japón') + , ('KE', 'ca', 'Kenya') + , ('KE', 'es', 'Kenia') + , ('KG', 'ca', 'Kirguizistan') + , ('KG', 'es', 'Kirguistán') + , ('KH', 'ca', 'Cambodja') + , ('KH', 'es', 'Camboya') + , ('KI', 'ca', 'Kiribati') + , ('KI', 'es', 'Kiribati') + , ('KM', 'ca', 'Comores') + , ('KM', 'es', 'Comoras') + , ('KN', 'ca', 'Saint Kitts i Nevis') + , ('KN', 'es', 'San Cristóbal y Nieves') + , ('KP', 'ca', 'Corea del Nord') + , ('KP', 'es', 'Corea del Norte') + , ('KR', 'ca', 'Corea del Sud') + , ('KR', 'es', 'Corea del Sur') + , ('KW', 'ca', 'Kuwait') + , ('KW', 'es', 'Kuwait') + , ('KY', 'ca', 'Illes Caiman') + , ('KY', 'es', 'Islas Caimán') + , ('KZ', 'ca', 'Kazakhstan') + , ('KZ', 'es', 'Kazajistán') + , ('LA', 'ca', 'Laos') + , ('LA', 'es', 'Laos') + , ('LB', 'ca', 'Líban') + , ('LB', 'es', 'Líbano') + , ('LC', 'ca', 'Saint Lucia') + , ('LC', 'es', 'Santa Lucía') + , ('LI', 'ca', 'Liechtenstein') + , ('LI', 'es', 'Liechtenstein') + , ('LK', 'ca', 'Sri Lanka') + , ('LK', 'es', 'Sri Lanka') + , ('LR', 'ca', 'Libèria') + , ('LR', 'es', 'Liberia') + , ('LS', 'ca', 'Lesotho') + , ('LS', 'es', 'Lesoto') + , ('LT', 'ca', 'Lituània') + , ('LT', 'es', 'Lituania') + , ('LU', 'ca', 'Luxemburg') + , ('LU', 'es', 'Luxemburgo') + , ('LV', 'ca', 'Letònia') + , ('LV', 'es', 'Letonia') + , ('LY', 'ca', 'Líbia') + , ('LY', 'es', 'Libia') + , ('MA', 'ca', 'Marroc') + , ('MA', 'es', 'Marruecos') + , ('MC', 'ca', 'Mònaco') + , ('MC', 'es', 'Mónaco') + , ('MD', 'ca', 'Moldàvia') + , ('MD', 'es', 'Moldavia') + , ('ME', 'ca', 'Montenegro') + , ('ME', 'es', 'Montenegro') + , ('MF', 'ca', 'Saint Martin (part francesa)') + , ('MF', 'es', 'San Martín (parte de Francia)') + , ('MG', 'ca', 'Madagascar') + , ('MG', 'es', 'Madagascar') + , ('MH', 'ca', 'Illes Marshall') + , ('MH', 'es', 'Islas Marshall') + , ('MK', 'ca', 'Macedònia del Nord') + , ('MK', 'es', 'Macedonia del Norte') + , ('ML', 'ca', 'Mali') + , ('ML', 'es', 'Malí') + , ('MM', 'ca', 'Myanmar') + , ('MM', 'es', 'Birmania') + , ('MN', 'ca', 'Mongòlia') + , ('MN', 'es', 'Mongolia') + , ('MO', 'ca', 'Macau') + , ('MO', 'es', 'Macao') + , ('MP', 'ca', 'Illes Mariannes Septentrionals') + , ('MP', 'es', 'Islas Marianas del Norte') + , ('MQ', 'ca', 'Martinica') + , ('MQ', 'es', 'Martinica') + , ('MR', 'ca', 'Mauritània') + , ('MR', 'es', 'Mauritania') + , ('MS', 'ca', 'Montserrat') + , ('MS', 'es', 'Montserrat') + , ('MT', 'ca', 'Malta') + , ('MT', 'es', 'Malta') + , ('MU', 'ca', 'Maurici') + , ('MU', 'es', 'Mauricio') + , ('MV', 'ca', 'Maldives') + , ('MV', 'es', 'Maldivas') + , ('MW', 'ca', 'Malawi') + , ('MW', 'es', 'Malaui') + , ('MX', 'ca', 'Mèxic') + , ('MX', 'es', 'México') + , ('MY', 'ca', 'Malàisia') + , ('MY', 'es', 'Malasia') + , ('MZ', 'ca', 'Moçambic') + , ('MZ', 'es', 'Mozambique') + , ('NA', 'ca', 'Namíbia') + , ('NA', 'es', 'Namibia') + , ('NC', 'ca', 'Nova Caledònia') + , ('NC', 'es', 'Nueva Caledonia') + , ('NE', 'ca', 'Níger') + , ('NE', 'es', 'Níger') + , ('NF', 'ca', 'Illa Norfolk') + , ('NF', 'es', 'Isla Norfolk') + , ('NG', 'ca', 'Nigèria') + , ('NG', 'es', 'Nigeria') + , ('NI', 'ca', 'Nicaragua') + , ('NI', 'es', 'Nicaragua') + , ('NL', 'ca', 'Països Baixos') + , ('NL', 'es', 'Países Bajos') + , ('NO', 'ca', 'Noruega') + , ('NO', 'es', 'Noruega') + , ('NP', 'ca', 'Nepal') + , ('NP', 'es', 'Nepal') + , ('NR', 'ca', 'Nauru') + , ('NR', 'es', 'Nauru') + , ('NU', 'ca', 'Niue') + , ('NU', 'es', 'Niue') + , ('NZ', 'ca', 'Nova Zelanda') + , ('NZ', 'es', 'Nueva Zelanda') + , ('OM', 'ca', 'Oman') + , ('OM', 'es', 'Omán') + , ('PA', 'ca', 'Panamà') + , ('PA', 'es', 'Panamá') + , ('PE', 'ca', 'Perú') + , ('PE', 'es', 'Perú') + , ('PF', 'ca', 'Polinèsia Francesa') + , ('PF', 'es', 'Polinesia Francesa') + , ('PG', 'ca', 'Papua Nova Guinea') + , ('PG', 'es', 'Papúa Nueva Guinea') + , ('PH', 'ca', 'Filipines') + , ('PH', 'es', 'Filipinas') + , ('PK', 'ca', 'Pakistan') + , ('PK', 'es', 'Pakistán') + , ('PL', 'ca', 'Polònia') + , ('PL', 'es', 'Polonia') + , ('PM', 'ca', 'Saint-Pierre i Miquelon') + , ('PM', 'es', 'San Pedro y Miquelón') + , ('PN', 'ca', 'Pitcairn') + , ('PN', 'es', 'Pitcairn') + , ('PR', 'ca', 'Puerto Rico') + , ('PR', 'es', 'Puerto Rico') + , ('PS', 'ca', 'Palestina') + , ('PS', 'es', 'Territorios Palestinos') + , ('PT', 'ca', 'Portugal') + , ('PT', 'es', 'Portugal') + , ('PW', 'ca', 'Belau') + , ('PW', 'es', 'Belau') + , ('PY', 'ca', 'Paraguai') + , ('PY', 'es', 'Paraguay') + , ('QA', 'ca', 'Qatar') + , ('QA', 'es', 'Qatar') + , ('RE', 'ca', 'Reunió') + , ('RE', 'es', 'Reunión') + , ('RO', 'ca', 'Romania') + , ('RO', 'es', 'Rumania') + , ('RS', 'ca', 'Sèrbia') + , ('RS', 'es', 'Serbia') + , ('RU', 'ca', 'Rússia') + , ('RU', 'es', 'Rusia') + , ('RW', 'ca', 'Ruanda') + , ('RW', 'es', 'Ruanda') + , ('SA', 'ca', 'Aràbia Saudita') + , ('SA', 'es', 'Arabia Saudita') + , ('SB', 'ca', 'Illes Salomó') + , ('SB', 'es', 'Islas Salomón') + , ('SC', 'ca', 'Seychelles') + , ('SC', 'es', 'Seychelles') + , ('SD', 'ca', 'Sudan') + , ('SD', 'es', 'Sudán') + , ('SE', 'ca', 'Suècia') + , ('SE', 'es', 'Suecia') + , ('SG', 'ca', 'Singapur') + , ('SG', 'es', 'Singapur') + , ('SH', 'ca', 'Saint Helena') + , ('SH', 'es', 'Isla Santa Elena') + , ('SI', 'ca', 'Eslovènia') + , ('SI', 'es', 'Eslovenia') + , ('SJ', 'ca', 'Svalbard i Jan Mayen') + , ('SJ', 'es', 'Svalbard y Jan Mayen') + , ('SK', 'ca', 'Eslovàquia') + , ('SK', 'es', 'Eslovaquia') + , ('SL', 'ca', 'Sierra Leone') + , ('SL', 'es', 'Sierra Leona') + , ('SM', 'ca', 'San Marino') + , ('SM', 'es', 'San Marino') + , ('SN', 'ca', 'Senegal') + , ('SN', 'es', 'Senegal') + , ('SO', 'ca', 'Somàlia') + , ('SO', 'es', 'Somalia') + , ('SR', 'ca', 'Surinam') + , ('SR', 'es', 'Surinam') + , ('SS', 'ca', 'Sudan del Sud') + , ('SS', 'es', 'Sudán del Sur') + , ('ST', 'ca', 'São Tomé i Príncipe') + , ('ST', 'es', 'Santo Tomé y Príncipe') + , ('SV', 'ca', 'El Salvador') + , ('SV', 'es', 'El Salvador') + , ('SX', 'ca', 'Saint Martin (part holandesa)') + , ('SX', 'es', 'San Martín (Países Bajos)') + , ('SY', 'ca', 'Síria') + , ('SY', 'es', 'Siria') + , ('SZ', 'ca', 'Eswatini') + , ('SZ', 'es', 'Esuatini') + , ('TC', 'ca', 'Illes Turks i Caicos') + , ('TC', 'es', 'Islas Turcas y Caicos') + , ('TD', 'ca', 'Txad') + , ('TD', 'es', 'Chad') + , ('TF', 'ca', 'Terres Australs Franceses') + , ('TF', 'es', 'Territorios australes franceses') + , ('TG', 'ca', 'Togo') + , ('TG', 'es', 'Togo') + , ('TH', 'ca', 'Tailàndia') + , ('TH', 'es', 'Tailandia') + , ('TJ', 'ca', 'Tadjikistan') + , ('TJ', 'es', 'Tayikistán') + , ('TK', 'ca', 'Tokelau') + , ('TK', 'es', 'Tokelau') + , ('TL', 'ca', 'Timor Oriental') + , ('TL', 'es', 'Timor Oriental') + , ('TM', 'ca', 'Turkmenistan') + , ('TM', 'es', 'Turkmenistán') + , ('TN', 'ca', 'Tunísia') + , ('TN', 'es', 'Túnez') + , ('TO', 'ca', 'Tonga') + , ('TO', 'es', 'Tonga') + , ('TR', 'ca', 'Turquia') + , ('TR', 'es', 'Turquía') + , ('TT', 'ca', 'Trinitat i Tobago') + , ('TT', 'es', 'Trinidad y Tobago') + , ('TV', 'ca', 'Tuvalu') + , ('TV', 'es', 'Tuvalu') + , ('TW', 'ca', 'Taiwan') + , ('TW', 'es', 'Taiwán') + , ('TZ', 'ca', 'Tanzània') + , ('TZ', 'es', 'Tanzania') + , ('UA', 'ca', 'Ucraïna') + , ('UA', 'es', 'Ucrania') + , ('UG', 'ca', 'Uganda') + , ('UG', 'es', 'Uganda') + , ('UM', 'ca', 'Illes d’Ultramar Menors dels Estats Units') + , ('UM', 'es', 'Islas de ultramar menores de Estados Unidos (EEUU)') + , ('US', 'ca', 'Estats Units (US)') + , ('US', 'es', 'Estados Unidos (EEUU)') + , ('UY', 'ca', 'Uruguai') + , ('UY', 'es', 'Uruguay') + , ('UZ', 'ca', 'Uzbekistan') + , ('UZ', 'es', 'Uzbekistán') + , ('VA', 'ca', 'Vaticà') + , ('VA', 'es', 'Ciudad del Vaticano') + , ('VC', 'ca', 'Saint Vincent i les Grenadines') + , ('VC', 'es', 'San Vicente y las Granadinas') + , ('VE', 'ca', 'Veneçuela') + , ('VE', 'es', 'Venezuela') + , ('VG', 'ca', 'Illes Verges (Britàniques)') + , ('VG', 'es', 'Islas Vírgenes (Británicas)') + , ('VI', 'ca', 'Illes Verges (EUA)') + , ('VI', 'es', 'Islas Vírgenes (EEUU)') + , ('VN', 'ca', 'Vietnam') + , ('VN', 'es', 'Vietnam') + , ('VU', 'ca', 'Vanuatu') + , ('VU', 'es', 'Vanuatu') + , ('WF', 'ca', 'Wallis i Futuna') + , ('WF', 'es', 'Wallis y Futuna') + , ('WS', 'ca', 'Samoa') + , ('WS', 'es', 'Samoa') + , ('YE', 'ca', 'Iemen') + , ('YE', 'es', 'Yemen') + , ('YT', 'ca', 'Mayotte') + , ('YT', 'es', 'Mayotte') + , ('ZA', 'ca', 'Sud-àfrica') + , ('ZA', 'es', 'Sudáfrica') + , ('ZM', 'ca', 'Zàmbia') + , ('ZM', 'es', 'Zambia') + , ('ZW', 'ca', 'Zimbàbue') + , ('ZW', 'es', 'Zimbabue') +; + +commit; diff --git a/deploy/available_currencies.sql b/deploy/available_currencies.sql new file mode 100644 index 0000000..03a7e68 --- /dev/null +++ b/deploy/available_currencies.sql @@ -0,0 +1,12 @@ +-- Deploy camper:available_currencies to pg +-- requires: schema_camper +-- requires: currency + +begin; + +insert into camper.currency(currency_code, currency_symbol) +values ('EUR', '€') + , ('USD', '$') +; + +commit; diff --git a/deploy/company.sql b/deploy/company.sql new file mode 100644 index 0000000..fa3560d --- /dev/null +++ b/deploy/company.sql @@ -0,0 +1,42 @@ +-- Deploy camper:company to pg +-- requires: roles +-- requires: schema_camper +-- requires: extension_vat +-- requires: email +-- requires: extension_pg_libphonenumber +-- requires: extension_uri +-- requires: currency_code +-- requires: currency +-- requires: country_code +-- requires: country +-- requires: language + +begin; + +set search_path to camper, public; + +create table company ( + company_id serial primary key, + slug uuid not null unique default gen_random_uuid(), + business_name text not null constraint business_name_not_empty check (length(trim(business_name)) > 1), + vatin vatin not null, + trade_name text not null, + phone packed_phone_number not null, + email email not null, + web uri not null, + address text not null, + city text not null, + province text not null, + postal_code text not null, + country_code country_code not null references country, + currency_code currency_code not null references currency, + default_lang_tag text not null references language, + invoice_number_format text not null default '"FRA"YYYY0000', + legal_disclaimer text not null default '', + created_at timestamptz not null default current_timestamp +); + +grant select, update on table company to employee; +grant select, update on table company to admin; + +commit; diff --git a/deploy/company_user.sql b/deploy/company_user.sql new file mode 100644 index 0000000..b08b27a --- /dev/null +++ b/deploy/company_user.sql @@ -0,0 +1,39 @@ +-- Deploy camper:company_user to pg +-- requires: roles +-- requires: schema_camper +-- requires: user +-- requires: company + +begin; + +set search_path to camper, auth, public; + +create table company_user ( + company_id integer not null references company, + user_id integer not null references "user", + primary key (company_id, user_id) +); + +grant select on table company_user to employee; +grant select on table company_user to admin; + + +alter table company enable row level security; + +create policy company_policy +on company +using ( + exists( + select 1 + from company_user + join user_profile using (user_id) + where company_user.company_id = company.company_id + ) +); + +-- TODO: +-- I think we can not do the same for company_user because it would be +-- an infinite loop, but in this case i think it is fine because we can +-- only see ids, nothing more. + +commit; diff --git a/deploy/country.sql b/deploy/country.sql new file mode 100644 index 0000000..420d9d1 --- /dev/null +++ b/deploy/country.sql @@ -0,0 +1,19 @@ +-- Deploy camper:country to pg +-- requires: roles +-- requires: schema_camper +-- requires: country_code + +begin; + +set search_path to camper, public; + +create table country ( + country_code country_code primary key, + name text not null, + postal_code_regex text not null +); + +grant select on table country to employee; +grant select on table country to admin; + +commit; diff --git a/deploy/country_code.sql b/deploy/country_code.sql new file mode 100644 index 0000000..5431a91 --- /dev/null +++ b/deploy/country_code.sql @@ -0,0 +1,15 @@ +-- Deploy camper:country_code to pg +-- requires: schema_camper + +begin; + +set search_path to camper, public; + +create domain country_code as text +check (value ~ '^[A-Z]{2}$'); +; + +comment on domain country_code is +'A correctly formated, but not necessarily valid, ISO 3166-1 alpha-2 country code.'; + +commit; diff --git a/deploy/country_i18n.sql b/deploy/country_i18n.sql new file mode 100644 index 0000000..590e148 --- /dev/null +++ b/deploy/country_i18n.sql @@ -0,0 +1,22 @@ +-- Deploy camper:country_i18n to pg +-- requires: roles +-- requires: schema_camper +-- requires: country_code +-- requires: language +-- requires: country + +begin; + +set search_path to camper, public; + +create table country_i18n ( + country_code country_code not null references country, + lang_tag text not null references language, + name text not null, + primary key (country_code, lang_tag) +); + +grant select on table country_i18n to employee; +grant select on table country_i18n to admin; + +commit; diff --git a/deploy/currency.sql b/deploy/currency.sql new file mode 100644 index 0000000..dfb00b8 --- /dev/null +++ b/deploy/currency.sql @@ -0,0 +1,19 @@ +-- Deploy camper:currency to pg +-- requires: roles +-- requires: schema_camper +-- requires: currency_code + +begin; + +set search_path to camper, public; + +create table currency ( + currency_code currency_code primary key, + currency_symbol text not null, + decimal_digits integer not null default 2 +); + +grant select on table currency to employee; +grant select on table currency to admin; + +commit; diff --git a/deploy/currency_code.sql b/deploy/currency_code.sql new file mode 100644 index 0000000..d112172 --- /dev/null +++ b/deploy/currency_code.sql @@ -0,0 +1,15 @@ +-- Deploy camper:currency_code to pg +-- requires: schema_camper + +begin; + +set search_path to camper, public; + +create domain currency_code as text +check (value ~ '^[A-Z]{3}$'); +; + +comment on domain currency_code is +'A correctly formatted, but not necessarily valid, ISO 4217 currency code.'; + +commit; diff --git a/deploy/extension_pg_libphonenumber.sql b/deploy/extension_pg_libphonenumber.sql new file mode 100644 index 0000000..662d166 --- /dev/null +++ b/deploy/extension_pg_libphonenumber.sql @@ -0,0 +1,8 @@ +-- Deploy camper:extension_pg_libphonenumber to pg +-- requires: schema_public + +begin; + +create extension if not exists pg_libphonenumber; + +commit; diff --git a/deploy/extension_uri.sql b/deploy/extension_uri.sql new file mode 100644 index 0000000..d9f0c07 --- /dev/null +++ b/deploy/extension_uri.sql @@ -0,0 +1,8 @@ +-- Deploy camper:extension_uri to pg +-- requires: schema_public + +begin; + +create extension if not exists uri; + +commit; diff --git a/deploy/extension_vat.sql b/deploy/extension_vat.sql new file mode 100644 index 0000000..c374000 --- /dev/null +++ b/deploy/extension_vat.sql @@ -0,0 +1,8 @@ +-- Deploy camper:extension_vat to pg +-- requires: schema_public + +begin; + +create extension if not exists vat; + +commit; diff --git a/revert/available_countries.sql b/revert/available_countries.sql new file mode 100644 index 0000000..a801902 --- /dev/null +++ b/revert/available_countries.sql @@ -0,0 +1,8 @@ +-- Revert camper:available_countries from pg + +begin; + +delete from camper.country_i18n; +delete from camper.country; + +commit; diff --git a/revert/available_currencies.sql b/revert/available_currencies.sql new file mode 100644 index 0000000..f93c2f3 --- /dev/null +++ b/revert/available_currencies.sql @@ -0,0 +1,7 @@ +-- Revert numerus:available_currencies from pg + +begin; + +delete from camper.currency; + +commit; diff --git a/revert/company.sql b/revert/company.sql new file mode 100644 index 0000000..2223361 --- /dev/null +++ b/revert/company.sql @@ -0,0 +1,7 @@ +-- Revert camper:company from pg + +begin; + +drop table if exists camper.company; + +commit; diff --git a/revert/company_user.sql b/revert/company_user.sql new file mode 100644 index 0000000..0476377 --- /dev/null +++ b/revert/company_user.sql @@ -0,0 +1,8 @@ +-- Revert camper:company_user from pg + +begin; + +drop policy if exists company_policy on camper.company; +drop table if exists camper.company_user; + +commit; diff --git a/revert/country.sql b/revert/country.sql new file mode 100644 index 0000000..d3a5752 --- /dev/null +++ b/revert/country.sql @@ -0,0 +1,7 @@ +-- Revert camper:country from pg + +begin; + +drop table if exists camper.country; + +commit; diff --git a/revert/country_code.sql b/revert/country_code.sql new file mode 100644 index 0000000..2f47eb5 --- /dev/null +++ b/revert/country_code.sql @@ -0,0 +1,7 @@ +-- Revert camper:country_code from pg + +begin; + +drop domain if exists camper.country_code; + +commit; diff --git a/revert/country_i18n.sql b/revert/country_i18n.sql new file mode 100644 index 0000000..309684e --- /dev/null +++ b/revert/country_i18n.sql @@ -0,0 +1,7 @@ +-- Revert camper:country_i18n from pg + +begin; + +drop table if exists camper.country_i18n; + +commit; diff --git a/revert/currency.sql b/revert/currency.sql new file mode 100644 index 0000000..1e3a42c --- /dev/null +++ b/revert/currency.sql @@ -0,0 +1,7 @@ +-- Revert camper:currency from pg + +begin; + +drop table if exists camper.currency; + +commit; diff --git a/revert/currency_code.sql b/revert/currency_code.sql new file mode 100644 index 0000000..2adc937 --- /dev/null +++ b/revert/currency_code.sql @@ -0,0 +1,7 @@ +-- Revert camper:currency_code from pg + +begin; + +drop domain if exists camper.currency_code; + +commit; diff --git a/revert/extension_pg_libphonenumber.sql b/revert/extension_pg_libphonenumber.sql new file mode 100644 index 0000000..16d4972 --- /dev/null +++ b/revert/extension_pg_libphonenumber.sql @@ -0,0 +1,7 @@ +-- Revert camper:extension_pg_libphonenumber from pg + +begin; + +drop extension if exists pg_libphonenumber; + +commit; diff --git a/revert/extension_uri.sql b/revert/extension_uri.sql new file mode 100644 index 0000000..7e92ce6 --- /dev/null +++ b/revert/extension_uri.sql @@ -0,0 +1,7 @@ +-- Revert camper:extension_uri from pg + +begin; + +drop extension if exists uri; + +commit; diff --git a/revert/extension_vat.sql b/revert/extension_vat.sql new file mode 100644 index 0000000..a817011 --- /dev/null +++ b/revert/extension_vat.sql @@ -0,0 +1,7 @@ +-- Revert camper:extension_vat from pg + +begin; + +drop extension if exists vat; + +commit; diff --git a/sqitch.plan b/sqitch.plan index 87aed9b..012ce07 100644 --- a/sqitch.plan +++ b/sqitch.plan @@ -24,3 +24,15 @@ check_cookie [roles schema_public schema_auth user] 2023-07-21T23:40:55Z jordi f set_cookie [roles schema_public check_cookie] 2023-07-21T23:44:30Z jordi fita mas # Add function to set the role base don the cookie user_profile [roles schema_camper user current_user_email current_user_cookie] 2023-07-21T23:47:36Z jordi fita mas # Add view for user profile change_password [roles schema_auth schema_camper user] 2023-07-21T23:54:52Z jordi fita mas # Add function to change the current user’s password +extension_vat [schema_public] 2023-07-29T01:18:45Z jordi fita mas # Add vat extension +extension_pg_libphonenumber [schema_public] 2023-07-29T01:21:12Z jordi fita mas # Add phone numbers extension +extension_uri [schema_public] 2023-07-29T01:23:46Z jordi fita mas # Add URI extension +currency_code [schema_camper] 2023-07-29T01:27:28Z jordi fita mas # Add domain for currency core in ISO 4217 +currency [roles schema_camper currency_code] 2023-07-29T01:32:53Z jordi fita mas # Add relation for currencies +available_currencies [schema_camper currency] 2023-07-29T01:36:57Z jordi fita mas # Add the initial list of available currencies +country_code [schema_camper] 2023-07-29T01:39:07Z jordi fita mas # Add domain for country code +country [roles schema_camper country_code] 2023-07-29T01:42:45Z jordi fita mas # Add relation for country +country_i18n [roles schema_camper country_code language country] 2023-07-29T01:45:48Z jordi fita mas # Add relation of country internationalization +available_countries [schema_camper country country_i18n] 2023-07-29T01:48:40Z jordi fita mas # Add the list of available countries +company [roles schema_camper extension_vat email extension_pg_libphonenumber extension_uri currency_code currency country_code country language] 2023-07-29T01:56:41Z jordi fita mas # Add relation for company +company_user [roles schema_camper user company] 2023-07-29T02:08:07Z jordi fita mas # Add relation of company user diff --git a/test/company.sql b/test/company.sql new file mode 100644 index 0000000..36eed64 --- /dev/null +++ b/test/company.sql @@ -0,0 +1,203 @@ +-- Test company +set client_min_messages to warning; +create extension if not exists pgtap; +reset client_min_messages; + +begin; + +select plan(101); + +set search_path to camper, public; + +select has_table('company'); +select has_pk('company' ); +select table_privs_are('company', 'guest', array []::text[]); +select table_privs_are('company', 'employee', array ['SELECT', 'UPDATE']); +select table_privs_are('company', 'admin', array ['SELECT', 'UPDATE']); +select table_privs_are('company', 'authenticator', array []::text[]); + +select has_sequence('company_company_id_seq'); +select sequence_privs_are('company_company_id_seq', 'guest', array[]::text[]); +select sequence_privs_are('company_company_id_seq', 'employee', array[]::text[]); +select sequence_privs_are('company_company_id_seq', 'admin', array[]::text[]); +select sequence_privs_are('company_company_id_seq', 'authenticator', array[]::text[]); + +select has_column('company', 'company_id'); +select col_is_pk('company', 'company_id'); +select col_type_is('company', 'company_id', 'integer'); +select col_not_null('company', 'company_id'); +select col_has_default('company', 'company_id'); +select col_default_is('company', 'company_id', 'nextval(''company_company_id_seq''::regclass)'); + +select has_column('company', 'slug'); +select col_is_unique('company', 'slug'); +select col_type_is('company', 'slug', 'uuid'); +select col_not_null('company', 'slug'); +select col_has_default('company', 'slug'); +select col_default_is('company', 'slug', 'gen_random_uuid()'); + +select has_column('company', 'business_name'); +select col_type_is('company', 'business_name', 'text'); +select col_not_null('company', 'business_name'); +select col_hasnt_default('company', 'business_name'); + +select has_column('company', 'vatin'); +select col_type_is('company', 'vatin', 'vatin'); +select col_not_null('company', 'vatin'); +select col_hasnt_default('company', 'vatin'); + +select has_column('company', 'trade_name'); +select col_type_is('company', 'trade_name', 'text'); +select col_not_null('company', 'trade_name'); +select col_hasnt_default('company', 'trade_name'); + +select has_column('company', 'phone'); +select col_type_is('company', 'phone', 'packed_phone_number'); +select col_not_null('company', 'phone'); +select col_hasnt_default('company', 'phone'); + +select has_column('company', 'email'); +select col_type_is('company', 'email', 'email'); +select col_not_null('company', 'email'); +select col_hasnt_default('company', 'email'); + +select has_column('company', 'web'); +select col_type_is('company', 'web', 'uri'); +select col_not_null('company', 'web'); +select col_hasnt_default('company', 'web'); + +select has_column('company', 'address'); +select col_type_is('company', 'address', 'text'); +select col_not_null('company', 'address'); +select col_hasnt_default('company', 'address'); + +select has_column('company', 'city'); +select col_type_is('company', 'city', 'text'); +select col_not_null('company', 'city'); +select col_hasnt_default('company', 'city'); + +select has_column('company', 'province'); +select col_type_is('company', 'province', 'text'); +select col_not_null('company', 'province'); +select col_hasnt_default('company', 'province'); + +select has_column('company', 'postal_code'); +select col_type_is('company', 'postal_code', 'text'); +select col_not_null('company', 'postal_code'); +select col_hasnt_default('company', 'postal_code'); + +select has_column('company', 'country_code'); +select col_is_fk('company', 'country_code'); +select fk_ok('company', 'country_code', 'country', 'country_code'); +select col_type_is('company', 'country_code', 'country_code'); +select col_not_null('company', 'country_code'); +select col_hasnt_default('company', 'country_code'); + +select has_column('company', 'currency_code'); +select col_is_fk('company', 'currency_code'); +select fk_ok('company', 'currency_code', 'currency', 'currency_code'); +select col_type_is('company', 'currency_code', 'currency_code'); +select col_not_null('company', 'currency_code'); +select col_hasnt_default('company', 'currency_code'); + +select has_column('company', 'default_lang_tag'); +select col_is_fk('company', 'default_lang_tag'); +select fk_ok('company', 'default_lang_tag', 'language', 'lang_tag'); +select col_type_is('company', 'default_lang_tag', 'text'); +select col_not_null('company', 'default_lang_tag'); +select col_hasnt_default('company', 'default_lang_tag'); + +select has_column('company', 'invoice_number_format'); +select col_type_is('company', 'invoice_number_format', 'text'); +select col_not_null('company', 'invoice_number_format'); +select col_has_default('company', 'invoice_number_format'); +select col_default_is('company', 'invoice_number_format', '"FRA"YYYY0000'); + +select has_column('company', 'legal_disclaimer'); +select col_type_is('company', 'legal_disclaimer', 'text'); +select col_not_null('company', 'legal_disclaimer'); +select col_has_default('company', 'legal_disclaimer'); +select col_default_is('company', 'legal_disclaimer', ''); + +select has_column('company', 'created_at'); +select col_type_is('company', 'created_at', 'timestamp with time zone'); +select col_not_null('company', 'created_at'); +select col_has_default('company', 'created_at'); +select col_default_is('company', 'created_at', 'CURRENT_TIMESTAMP'); + + +set client_min_messages to warning; +truncate company_user cascade; +truncate company cascade; +truncate auth."user" cascade; +reset client_min_messages; + +insert into auth."user" (user_id, email, name, password, role, cookie, cookie_expires_at) +values (1, 'demo@tandem.blog', 'Demo', 'test', 'employee', '44facbb30d8a419dfd4bfbc44a4b5539d4970148dfc84bed0e', current_timestamp + interval '1 month') + , (5, 'admin@tandem.blog', 'Demo', 'test', 'admin', '12af4c88b528c2ad4222e3740496ecbc58e76e26f087657524', current_timestamp + interval '1 month') +; + +insert into company (company_id, business_name, vatin, trade_name, phone, email, web, address, city, province, postal_code, country_code, currency_code, default_lang_tag) +values (2, 'Company 2', 'XX123', '', '555-555-555', 'a@a', '', '', '', '', '', 'ES', 'EUR', 'ca') + , (4, 'Company 4', 'XX234', '', '666-666-666', 'b@b', '', '', '', '', '', 'FR', 'USD', 'es') + , (6, 'Company 6', 'XX345', '', '777-777-777', 'c@c', '', '', '', '', '', 'DE', 'USD', 'ca') +; + +insert into company_user (company_id, user_id) +values (2, 1) + , (2, 5) + , (4, 1) + , (6, 5) +; + +prepare company_data as +select company_id, business_name +from company +order by company_id; + +set role employee; +select is_empty('company_data', 'Should show no data when cookie is not set yet'); +reset role; + +select set_cookie('44facbb30d8a419dfd4bfbc44a4b5539d4970148dfc84bed0e/demo@tandem.blog'); +select results_eq( + 'company_data', + $$ values ( 2, 'Company 2' ) + , ( 4, 'Company 4' ) + $$, + 'Should only list companies where demo@tandem.blog is user of' +); +reset role; + +select set_cookie('12af4c88b528c2ad4222e3740496ecbc58e76e26f087657524/admin@tandem.blog'); +select results_eq( + 'company_data', + $$ values ( 2, 'Company 2' ) + , ( 6, 'Company 6' ) + $$, + 'Should only list companies where admin@tandem.blog is user of' +); +reset role; + +select set_cookie('not-a-cookie'); +select throws_ok( + 'company_data', + '42501', 'permission denied for table company', + 'Should not allow select to guest users' +); +reset role; + +select throws_ok( $$ + insert into company (company_id, business_name, vatin, trade_name, phone, email, web, address, city, province, postal_code, country_code, currency_code, default_lang_tag) + values (7, ' ', 'XX123', '', '555-555-555', 'a@a', '', '', '', '', '', 'ES', 'EUR', 'ca') + $$, + '23514', 'new row for relation "company" violates check constraint "business_name_not_empty"', + 'Should not allow companies with blank business name' +); + + +select * +from finish(); + +rollback; + diff --git a/test/company_user.sql b/test/company_user.sql new file mode 100644 index 0000000..2954745 --- /dev/null +++ b/test/company_user.sql @@ -0,0 +1,39 @@ +-- Test company_user +set client_min_messages to warning; +create extension if not exists pgtap; +reset client_min_messages; + +begin; + +select plan(19); + +set search_path to camper, public; + +select has_table('company_user'); +select has_pk('company_user' ); +select col_is_pk('company_user', array['company_id', 'user_id']); +select table_privs_are('company_user', 'guest', array []::text[]); +select table_privs_are('company_user', 'employee', array ['SELECT']); +select table_privs_are('company_user', 'admin', array ['SELECT']); +select table_privs_are('company_user', 'authenticator', array []::text[]); + +select has_column('company_user', 'company_id'); +select col_is_fk('company_user', 'company_id'); +select fk_ok('company_user', 'company_id', 'company', 'company_id'); +select col_type_is('company_user', 'company_id', 'integer'); +select col_not_null('company_user', 'company_id'); +select col_hasnt_default('company_user', 'company_id'); + +select has_column('company_user', 'user_id'); +select col_is_fk('company_user', 'user_id'); +select fk_ok('company_user', 'user_id', 'user', 'user_id'); +select col_type_is('company_user', 'user_id', 'integer'); +select col_not_null('company_user', 'user_id'); +select col_hasnt_default('company_user', 'user_id'); + + +select * +from finish(); + +rollback; + diff --git a/test/country.sql b/test/country.sql new file mode 100644 index 0000000..7e32160 --- /dev/null +++ b/test/country.sql @@ -0,0 +1,40 @@ +-- Test country +set client_min_messages to warning; +create extension if not exists pgtap; +reset client_min_messages; + +begin; + +select plan(19); + +set search_path to camper, public; + +select has_table('country'); +select has_pk('country' ); +select table_privs_are('country', 'guest', array []::text[]); +select table_privs_are('country', 'employee', array ['SELECT']); +select table_privs_are('country', 'admin', array ['SELECT']); +select table_privs_are('country', 'authenticator', array []::text[]); + +select has_column('country', 'country_code'); +select col_is_pk('country', 'country_code'); +select col_type_is('country', 'country_code', 'country_code'); +select col_not_null('country', 'country_code'); +select col_hasnt_default('country', 'country_code'); + +select has_column('country', 'name'); +select col_type_is('country', 'name', 'text'); +select col_not_null('country', 'name'); +select col_hasnt_default('country', 'name'); + +select has_column('country', 'postal_code_regex'); +select col_type_is('country', 'postal_code_regex', 'text'); +select col_not_null('country', 'postal_code_regex'); +select col_hasnt_default('country', 'postal_code_regex'); + + +select * +from finish(); + +rollback; + diff --git a/test/country_code.sql b/test/country_code.sql new file mode 100644 index 0000000..b6f3068 --- /dev/null +++ b/test/country_code.sql @@ -0,0 +1,38 @@ +-- Test country_code +set client_min_messages to warning; +create extension if not exists pgtap; +reset client_min_messages; + +begin; + +select plan(6); + +set search_path to camper, public; + +select has_domain('country_code'); +select domain_type_is('country_code', 'text'); + +select lives_ok($$ select 'FR'::country_code $$, 'Should be able to cast valid text to country code'); + +select throws_ok( + $$ SELECT '12'::country_code $$, + 23514, null, + 'Should reject numeric text' +); + +select throws_ok( + $$ SELECT 'fr'::country_code $$, + 23514, null, + 'Should reject lowecase text' +); + +select throws_ok( + $$ SELECT 'FRA'::country_code $$, + 23514, null, + 'Should reject text longer than three letters' +); + +select * +from finish(); + +rollback; diff --git a/test/country_i18n.sql b/test/country_i18n.sql new file mode 100644 index 0000000..d4bba51 --- /dev/null +++ b/test/country_i18n.sql @@ -0,0 +1,44 @@ +-- Test country_i18n +set client_min_messages to warning; +create extension if not exists pgtap; +reset client_min_messages; + +begin; + +select plan(23); + +set search_path to camper, public; + +select has_table('country_i18n'); +select has_pk('country_i18n' ); +select col_is_pk('country_i18n', array['country_code', 'lang_tag']); +select table_privs_are('country_i18n', 'guest', array []::text[]); +select table_privs_are('country_i18n', 'employee', array ['SELECT']); +select table_privs_are('country_i18n', 'admin', array ['SELECT']); +select table_privs_are('country_i18n', 'authenticator', array []::text[]); + +select has_column('country_i18n', 'country_code'); +select col_is_fk('country_i18n', 'country_code'); +select fk_ok('country_i18n', 'country_code', 'country', 'country_code'); +select col_type_is('country_i18n', 'country_code', 'country_code'); +select col_not_null('country_i18n', 'country_code'); +select col_hasnt_default('country_i18n', 'country_code'); + +select has_column('country_i18n', 'lang_tag'); +select col_is_fk('country_i18n', 'lang_tag'); +select fk_ok('country_i18n', 'lang_tag', 'language', 'lang_tag'); +select col_type_is('country_i18n', 'lang_tag', 'text'); +select col_not_null('country_i18n', 'lang_tag'); +select col_hasnt_default('country_i18n', 'lang_tag'); + +select has_column('country_i18n', 'name'); +select col_type_is('country_i18n', 'name', 'text'); +select col_not_null('country_i18n', 'name'); +select col_hasnt_default('country_i18n', 'name'); + + +select * +from finish(); + +rollback; + diff --git a/test/currency.sql b/test/currency.sql new file mode 100644 index 0000000..73b735a --- /dev/null +++ b/test/currency.sql @@ -0,0 +1,41 @@ +-- Test currency +set client_min_messages to warning; +create extension if not exists pgtap; +reset client_min_messages; + +begin; + +select plan(20); + +set search_path to camper, public; + +select has_table('currency'); +select has_pk('currency' ); +select table_privs_are('currency', 'guest', array []::text[]); +select table_privs_are('currency', 'employee', array ['SELECT']); +select table_privs_are('currency', 'admin', array ['SELECT']); +select table_privs_are('currency', 'authenticator', array []::text[]); + +select has_column('currency', 'currency_code'); +select col_is_pk('currency', 'currency_code'); +select col_type_is('currency', 'currency_code', 'currency_code'); +select col_not_null('currency', 'currency_code'); +select col_hasnt_default('currency', 'currency_code'); + +select has_column('currency', 'currency_symbol'); +select col_type_is('currency', 'currency_symbol', 'text'); +select col_not_null('currency', 'currency_symbol'); +select col_hasnt_default('currency', 'currency_symbol'); + +select has_column('currency', 'decimal_digits'); +select col_type_is('currency', 'decimal_digits', 'integer'); +select col_not_null('currency', 'decimal_digits'); +select col_has_default('currency', 'decimal_digits'); +select col_default_is('currency', 'decimal_digits', 2); + + +select * +from finish(); + +rollback; + diff --git a/test/currency_code.sql b/test/currency_code.sql new file mode 100644 index 0000000..2f428b4 --- /dev/null +++ b/test/currency_code.sql @@ -0,0 +1,39 @@ +-- Test currency_code +set client_min_messages to warning; +create extension if not exists pgtap; +reset client_min_messages; + +begin; + +select plan(6); + +set search_path to camper, public; + +select has_domain('currency_code'); +select domain_type_is('currency_code', 'text'); + +select lives_ok($$ select 'EUR'::currency_code $$, 'Should be able to cast valid text to currency code'); + +select throws_ok( + $$ SELECT '123'::currency_code $$, + 23514, null, + 'Should reject numeric text' +); + +select throws_ok( + $$ SELECT 'eur'::currency_code $$, + 23514, null, + 'Should reject lowecase text' +); + +select throws_ok( + $$ SELECT 'EURO'::currency_code $$, + 23514, null, + 'Should reject text longer than three letters' +); + + +select * +from finish(); + +rollback; diff --git a/test/extensions.sql b/test/extensions.sql index a9e1e62..aebb976 100644 --- a/test/extensions.sql +++ b/test/extensions.sql @@ -11,7 +11,10 @@ select extensions_are(array [ 'citext' , 'pgtap' , 'pgcrypto' + , 'pg_libphonenumber' , 'plpgsql' + , 'uri' + , 'vat' ]); select * diff --git a/verify/available_countries.sql b/verify/available_countries.sql new file mode 100644 index 0000000..2e23c47 --- /dev/null +++ b/verify/available_countries.sql @@ -0,0 +1,756 @@ +-- Verify camper:available_countries on pg + +begin; + +set search_path to camper; + +select 1 / count(*) from country where country_code = 'AF' and name = 'Afghanistan'; +select 1 / count(*) from country where country_code = 'AX' and name = 'Åland Islands'; +select 1 / count(*) from country where country_code = 'AL' and name = 'Albania'; +select 1 / count(*) from country where country_code = 'DZ' and name = 'Algeria'; +select 1 / count(*) from country where country_code = 'AS' and name = 'American Samoa'; +select 1 / count(*) from country where country_code = 'AD' and name = 'Andorra'; +select 1 / count(*) from country where country_code = 'AO' and name = 'Angola'; +select 1 / count(*) from country where country_code = 'AI' and name = 'Anguilla'; +select 1 / count(*) from country where country_code = 'AQ' and name = 'Antarctica'; +select 1 / count(*) from country where country_code = 'AG' and name = 'Antigua and Barbuda'; +select 1 / count(*) from country where country_code = 'AR' and name = 'Argentina'; +select 1 / count(*) from country where country_code = 'AM' and name = 'Armenia'; +select 1 / count(*) from country where country_code = 'AW' and name = 'Aruba'; +select 1 / count(*) from country where country_code = 'AU' and name = 'Australia'; +select 1 / count(*) from country where country_code = 'AT' and name = 'Austria'; +select 1 / count(*) from country where country_code = 'AZ' and name = 'Azerbaijan'; +select 1 / count(*) from country where country_code = 'BS' and name = 'Bahamas'; +select 1 / count(*) from country where country_code = 'BH' and name = 'Bahrain'; +select 1 / count(*) from country where country_code = 'BD' and name = 'Bangladesh'; +select 1 / count(*) from country where country_code = 'BB' and name = 'Barbados'; +select 1 / count(*) from country where country_code = 'BY' and name = 'Belarus'; +select 1 / count(*) from country where country_code = 'BE' and name = 'Belgium'; +select 1 / count(*) from country where country_code = 'PW' and name = 'Belau'; +select 1 / count(*) from country where country_code = 'BZ' and name = 'Belize'; +select 1 / count(*) from country where country_code = 'BJ' and name = 'Benin'; +select 1 / count(*) from country where country_code = 'BM' and name = 'Bermuda'; +select 1 / count(*) from country where country_code = 'BT' and name = 'Bhutan'; +select 1 / count(*) from country where country_code = 'BO' and name = 'Bolivia'; +select 1 / count(*) from country where country_code = 'BQ' and name = 'Bonaire, Saint Eustatius and Saba'; +select 1 / count(*) from country where country_code = 'BA' and name = 'Bosnia and Herzegovina'; +select 1 / count(*) from country where country_code = 'BW' and name = 'Botswana'; +select 1 / count(*) from country where country_code = 'BV' and name = 'Bouvet Island'; +select 1 / count(*) from country where country_code = 'BR' and name = 'Brazil'; +select 1 / count(*) from country where country_code = 'IO' and name = 'British Indian Ocean Territory'; +select 1 / count(*) from country where country_code = 'BN' and name = 'Brunei'; +select 1 / count(*) from country where country_code = 'BG' and name = 'Bulgaria'; +select 1 / count(*) from country where country_code = 'BF' and name = 'Burkina Faso'; +select 1 / count(*) from country where country_code = 'BI' and name = 'Burundi'; +select 1 / count(*) from country where country_code = 'KH' and name = 'Cambodia'; +select 1 / count(*) from country where country_code = 'CM' and name = 'Cameroon'; +select 1 / count(*) from country where country_code = 'CA' and name = 'Canada'; +select 1 / count(*) from country where country_code = 'CV' and name = 'Cape Verde'; +select 1 / count(*) from country where country_code = 'KY' and name = 'Cayman Islands'; +select 1 / count(*) from country where country_code = 'CF' and name = 'Central African Republic'; +select 1 / count(*) from country where country_code = 'TD' and name = 'Chad'; +select 1 / count(*) from country where country_code = 'CL' and name = 'Chile'; +select 1 / count(*) from country where country_code = 'CN' and name = 'China'; +select 1 / count(*) from country where country_code = 'CX' and name = 'Christmas Island'; +select 1 / count(*) from country where country_code = 'CC' and name = 'Cocos (Keeling) Islands'; +select 1 / count(*) from country where country_code = 'CO' and name = 'Colombia'; +select 1 / count(*) from country where country_code = 'KM' and name = 'Comoros'; +select 1 / count(*) from country where country_code = 'CG' and name = 'Congo (Brazzaville)'; +select 1 / count(*) from country where country_code = 'CD' and name = 'Congo (Kinshasa)'; +select 1 / count(*) from country where country_code = 'CK' and name = 'Cook Islands'; +select 1 / count(*) from country where country_code = 'CR' and name = 'Costa Rica'; +select 1 / count(*) from country where country_code = 'HR' and name = 'Croatia'; +select 1 / count(*) from country where country_code = 'CU' and name = 'Cuba'; +select 1 / count(*) from country where country_code = 'CW' and name = 'Curaçao'; +select 1 / count(*) from country where country_code = 'CY' and name = 'Cyprus'; +select 1 / count(*) from country where country_code = 'CZ' and name = 'Czech Republic'; +select 1 / count(*) from country where country_code = 'DK' and name = 'Denmark'; +select 1 / count(*) from country where country_code = 'DJ' and name = 'Djibouti'; +select 1 / count(*) from country where country_code = 'DM' and name = 'Dominica'; +select 1 / count(*) from country where country_code = 'DO' and name = 'Dominican Republic'; +select 1 / count(*) from country where country_code = 'EC' and name = 'Ecuador'; +select 1 / count(*) from country where country_code = 'EG' and name = 'Egypt'; +select 1 / count(*) from country where country_code = 'SV' and name = 'El Salvador'; +select 1 / count(*) from country where country_code = 'GQ' and name = 'Equatorial Guinea'; +select 1 / count(*) from country where country_code = 'ER' and name = 'Eritrea'; +select 1 / count(*) from country where country_code = 'EE' and name = 'Estonia'; +select 1 / count(*) from country where country_code = 'ET' and name = 'Ethiopia'; +select 1 / count(*) from country where country_code = 'FK' and name = 'Falkland Islands'; +select 1 / count(*) from country where country_code = 'FO' and name = 'Faroe Islands'; +select 1 / count(*) from country where country_code = 'FJ' and name = 'Fiji'; +select 1 / count(*) from country where country_code = 'FI' and name = 'Finland'; +select 1 / count(*) from country where country_code = 'FR' and name = 'France'; +select 1 / count(*) from country where country_code = 'GF' and name = 'French Guiana'; +select 1 / count(*) from country where country_code = 'PF' and name = 'French Polynesia'; +select 1 / count(*) from country where country_code = 'TF' and name = 'French Southern Territories'; +select 1 / count(*) from country where country_code = 'GA' and name = 'Gabon'; +select 1 / count(*) from country where country_code = 'GM' and name = 'Gambia'; +select 1 / count(*) from country where country_code = 'GE' and name = 'Georgia'; +select 1 / count(*) from country where country_code = 'DE' and name = 'Germany'; +select 1 / count(*) from country where country_code = 'GH' and name = 'Ghana'; +select 1 / count(*) from country where country_code = 'GI' and name = 'Gibraltar'; +select 1 / count(*) from country where country_code = 'GR' and name = 'Greece'; +select 1 / count(*) from country where country_code = 'GL' and name = 'Greenland'; +select 1 / count(*) from country where country_code = 'GD' and name = 'Grenada'; +select 1 / count(*) from country where country_code = 'GP' and name = 'Guadeloupe'; +select 1 / count(*) from country where country_code = 'GU' and name = 'Guam'; +select 1 / count(*) from country where country_code = 'GT' and name = 'Guatemala'; +select 1 / count(*) from country where country_code = 'GG' and name = 'Guernsey'; +select 1 / count(*) from country where country_code = 'GN' and name = 'Guinea'; +select 1 / count(*) from country where country_code = 'GW' and name = 'Guinea-Bissau'; +select 1 / count(*) from country where country_code = 'GY' and name = 'Guyana'; +select 1 / count(*) from country where country_code = 'HT' and name = 'Haiti'; +select 1 / count(*) from country where country_code = 'HM' and name = 'Heard Island and McDonald Islands'; +select 1 / count(*) from country where country_code = 'HN' and name = 'Honduras'; +select 1 / count(*) from country where country_code = 'HK' and name = 'Hong Kong'; +select 1 / count(*) from country where country_code = 'HU' and name = 'Hungary'; +select 1 / count(*) from country where country_code = 'IS' and name = 'Iceland'; +select 1 / count(*) from country where country_code = 'IN' and name = 'India'; +select 1 / count(*) from country where country_code = 'ID' and name = 'Indonesia'; +select 1 / count(*) from country where country_code = 'IR' and name = 'Iran'; +select 1 / count(*) from country where country_code = 'IQ' and name = 'Iraq'; +select 1 / count(*) from country where country_code = 'IE' and name = 'Ireland'; +select 1 / count(*) from country where country_code = 'IM' and name = 'Isle of Man'; +select 1 / count(*) from country where country_code = 'IL' and name = 'Israel'; +select 1 / count(*) from country where country_code = 'IT' and name = 'Italy'; +select 1 / count(*) from country where country_code = 'CI' and name = 'Ivory Coast'; +select 1 / count(*) from country where country_code = 'JM' and name = 'Jamaica'; +select 1 / count(*) from country where country_code = 'JP' and name = 'Japan'; +select 1 / count(*) from country where country_code = 'JE' and name = 'Jersey'; +select 1 / count(*) from country where country_code = 'JO' and name = 'Jordan'; +select 1 / count(*) from country where country_code = 'KZ' and name = 'Kazakhstan'; +select 1 / count(*) from country where country_code = 'KE' and name = 'Kenya'; +select 1 / count(*) from country where country_code = 'KI' and name = 'Kiribati'; +select 1 / count(*) from country where country_code = 'KW' and name = 'Kuwait'; +select 1 / count(*) from country where country_code = 'KG' and name = 'Kyrgyzstan'; +select 1 / count(*) from country where country_code = 'LA' and name = 'Laos'; +select 1 / count(*) from country where country_code = 'LV' and name = 'Latvia'; +select 1 / count(*) from country where country_code = 'LB' and name = 'Lebanon'; +select 1 / count(*) from country where country_code = 'LS' and name = 'Lesotho'; +select 1 / count(*) from country where country_code = 'LR' and name = 'Liberia'; +select 1 / count(*) from country where country_code = 'LY' and name = 'Libya'; +select 1 / count(*) from country where country_code = 'LI' and name = 'Liechtenstein'; +select 1 / count(*) from country where country_code = 'LT' and name = 'Lithuania'; +select 1 / count(*) from country where country_code = 'LU' and name = 'Luxembourg'; +select 1 / count(*) from country where country_code = 'MO' and name = 'Macao'; +select 1 / count(*) from country where country_code = 'MK' and name = 'North Macedonia'; +select 1 / count(*) from country where country_code = 'MG' and name = 'Madagascar'; +select 1 / count(*) from country where country_code = 'MW' and name = 'Malawi'; +select 1 / count(*) from country where country_code = 'MY' and name = 'Malaysia'; +select 1 / count(*) from country where country_code = 'MV' and name = 'Maldives'; +select 1 / count(*) from country where country_code = 'ML' and name = 'Mali'; +select 1 / count(*) from country where country_code = 'MT' and name = 'Malta'; +select 1 / count(*) from country where country_code = 'MH' and name = 'Marshall Islands'; +select 1 / count(*) from country where country_code = 'MQ' and name = 'Martinique'; +select 1 / count(*) from country where country_code = 'MR' and name = 'Mauritania'; +select 1 / count(*) from country where country_code = 'MU' and name = 'Mauritius'; +select 1 / count(*) from country where country_code = 'YT' and name = 'Mayotte'; +select 1 / count(*) from country where country_code = 'MX' and name = 'Mexico'; +select 1 / count(*) from country where country_code = 'FM' and name = 'Micronesia'; +select 1 / count(*) from country where country_code = 'MD' and name = 'Moldova'; +select 1 / count(*) from country where country_code = 'MC' and name = 'Monaco'; +select 1 / count(*) from country where country_code = 'MN' and name = 'Mongolia'; +select 1 / count(*) from country where country_code = 'ME' and name = 'Montenegro'; +select 1 / count(*) from country where country_code = 'MS' and name = 'Montserrat'; +select 1 / count(*) from country where country_code = 'MA' and name = 'Morocco'; +select 1 / count(*) from country where country_code = 'MZ' and name = 'Mozambique'; +select 1 / count(*) from country where country_code = 'MM' and name = 'Myanmar'; +select 1 / count(*) from country where country_code = 'NA' and name = 'Namibia'; +select 1 / count(*) from country where country_code = 'NR' and name = 'Nauru'; +select 1 / count(*) from country where country_code = 'NP' and name = 'Nepal'; +select 1 / count(*) from country where country_code = 'NL' and name = 'Netherlands'; +select 1 / count(*) from country where country_code = 'NC' and name = 'New Caledonia'; +select 1 / count(*) from country where country_code = 'NZ' and name = 'New Zealand'; +select 1 / count(*) from country where country_code = 'NI' and name = 'Nicaragua'; +select 1 / count(*) from country where country_code = 'NE' and name = 'Niger'; +select 1 / count(*) from country where country_code = 'NG' and name = 'Nigeria'; +select 1 / count(*) from country where country_code = 'NU' and name = 'Niue'; +select 1 / count(*) from country where country_code = 'NF' and name = 'Norfolk Island'; +select 1 / count(*) from country where country_code = 'MP' and name = 'Northern Mariana Islands'; +select 1 / count(*) from country where country_code = 'KP' and name = 'North Korea'; +select 1 / count(*) from country where country_code = 'NO' and name = 'Norway'; +select 1 / count(*) from country where country_code = 'OM' and name = 'Oman'; +select 1 / count(*) from country where country_code = 'PK' and name = 'Pakistan'; +select 1 / count(*) from country where country_code = 'PS' and name = 'Palestinian Territory'; +select 1 / count(*) from country where country_code = 'PA' and name = 'Panama'; +select 1 / count(*) from country where country_code = 'PG' and name = 'Papua New Guinea'; +select 1 / count(*) from country where country_code = 'PY' and name = 'Paraguay'; +select 1 / count(*) from country where country_code = 'PE' and name = 'Peru'; +select 1 / count(*) from country where country_code = 'PH' and name = 'Philippines'; +select 1 / count(*) from country where country_code = 'PN' and name = 'Pitcairn'; +select 1 / count(*) from country where country_code = 'PL' and name = 'Poland'; +select 1 / count(*) from country where country_code = 'PT' and name = 'Portugal'; +select 1 / count(*) from country where country_code = 'PR' and name = 'Puerto Rico'; +select 1 / count(*) from country where country_code = 'QA' and name = 'Qatar'; +select 1 / count(*) from country where country_code = 'RE' and name = 'Reunion'; +select 1 / count(*) from country where country_code = 'RO' and name = 'Romania'; +select 1 / count(*) from country where country_code = 'RU' and name = 'Russia'; +select 1 / count(*) from country where country_code = 'RW' and name = 'Rwanda'; +select 1 / count(*) from country where country_code = 'BL' and name = 'Saint Barthélemy'; +select 1 / count(*) from country where country_code = 'SH' and name = 'Saint Helena'; +select 1 / count(*) from country where country_code = 'KN' and name = 'Saint Kitts and Nevis'; +select 1 / count(*) from country where country_code = 'LC' and name = 'Saint Lucia'; +select 1 / count(*) from country where country_code = 'MF' and name = 'Saint Martin (French part)'; +select 1 / count(*) from country where country_code = 'SX' and name = 'Saint Martin (Dutch part)'; +select 1 / count(*) from country where country_code = 'PM' and name = 'Saint Pierre and Miquelon'; +select 1 / count(*) from country where country_code = 'VC' and name = 'Saint Vincent and the Grenadines'; +select 1 / count(*) from country where country_code = 'SM' and name = 'San Marino'; +select 1 / count(*) from country where country_code = 'ST' and name = 'São Tomé and Príncipe'; +select 1 / count(*) from country where country_code = 'SA' and name = 'Saudi Arabia'; +select 1 / count(*) from country where country_code = 'SN' and name = 'Senegal'; +select 1 / count(*) from country where country_code = 'RS' and name = 'Serbia'; +select 1 / count(*) from country where country_code = 'SC' and name = 'Seychelles'; +select 1 / count(*) from country where country_code = 'SL' and name = 'Sierra Leone'; +select 1 / count(*) from country where country_code = 'SG' and name = 'Singapore'; +select 1 / count(*) from country where country_code = 'SK' and name = 'Slovakia'; +select 1 / count(*) from country where country_code = 'SI' and name = 'Slovenia'; +select 1 / count(*) from country where country_code = 'SB' and name = 'Solomon Islands'; +select 1 / count(*) from country where country_code = 'SO' and name = 'Somalia'; +select 1 / count(*) from country where country_code = 'ZA' and name = 'South Africa'; +select 1 / count(*) from country where country_code = 'GS' and name = 'South Georgia/Sandwich Islands'; +select 1 / count(*) from country where country_code = 'KR' and name = 'South Korea'; +select 1 / count(*) from country where country_code = 'SS' and name = 'South Sudan'; +select 1 / count(*) from country where country_code = 'ES' and name = 'Spain'; +select 1 / count(*) from country where country_code = 'LK' and name = 'Sri Lanka'; +select 1 / count(*) from country where country_code = 'SD' and name = 'Sudan'; +select 1 / count(*) from country where country_code = 'SR' and name = 'Suriname'; +select 1 / count(*) from country where country_code = 'SJ' and name = 'Svalbard and Jan Mayen'; +select 1 / count(*) from country where country_code = 'SZ' and name = 'Eswatini'; +select 1 / count(*) from country where country_code = 'SE' and name = 'Sweden'; +select 1 / count(*) from country where country_code = 'CH' and name = 'Switzerland'; +select 1 / count(*) from country where country_code = 'SY' and name = 'Syria'; +select 1 / count(*) from country where country_code = 'TW' and name = 'Taiwan'; +select 1 / count(*) from country where country_code = 'TJ' and name = 'Tajikistan'; +select 1 / count(*) from country where country_code = 'TZ' and name = 'Tanzania'; +select 1 / count(*) from country where country_code = 'TH' and name = 'Thailand'; +select 1 / count(*) from country where country_code = 'TL' and name = 'Timor-Leste'; +select 1 / count(*) from country where country_code = 'TG' and name = 'Togo'; +select 1 / count(*) from country where country_code = 'TK' and name = 'Tokelau'; +select 1 / count(*) from country where country_code = 'TO' and name = 'Tonga'; +select 1 / count(*) from country where country_code = 'TT' and name = 'Trinidad and Tobago'; +select 1 / count(*) from country where country_code = 'TN' and name = 'Tunisia'; +select 1 / count(*) from country where country_code = 'TR' and name = 'Turkey'; +select 1 / count(*) from country where country_code = 'TM' and name = 'Turkmenistan'; +select 1 / count(*) from country where country_code = 'TC' and name = 'Turks and Caicos Islands'; +select 1 / count(*) from country where country_code = 'TV' and name = 'Tuvalu'; +select 1 / count(*) from country where country_code = 'UG' and name = 'Uganda'; +select 1 / count(*) from country where country_code = 'UA' and name = 'Ukraine'; +select 1 / count(*) from country where country_code = 'AE' and name = 'United Arab Emirates'; +select 1 / count(*) from country where country_code = 'GB' and name = 'United Kingdom (UK)'; +select 1 / count(*) from country where country_code = 'US' and name = 'United States (US)'; +select 1 / count(*) from country where country_code = 'UM' and name = 'United States (US) Minor Outlying Islands'; +select 1 / count(*) from country where country_code = 'UY' and name = 'Uruguay'; +select 1 / count(*) from country where country_code = 'UZ' and name = 'Uzbekistan'; +select 1 / count(*) from country where country_code = 'VU' and name = 'Vanuatu'; +select 1 / count(*) from country where country_code = 'VA' and name = 'Vatican'; +select 1 / count(*) from country where country_code = 'VE' and name = 'Venezuela'; +select 1 / count(*) from country where country_code = 'VN' and name = 'Vietnam'; +select 1 / count(*) from country where country_code = 'VG' and name = 'Virgin Islands (British)'; +select 1 / count(*) from country where country_code = 'VI' and name = 'Virgin Islands (US)'; +select 1 / count(*) from country where country_code = 'WF' and name = 'Wallis and Futuna'; +select 1 / count(*) from country where country_code = 'EH' and name = 'Western Sahara'; +select 1 / count(*) from country where country_code = 'WS' and name = 'Samoa'; +select 1 / count(*) from country where country_code = 'YE' and name = 'Yemen'; +select 1 / count(*) from country where country_code = 'ZM' and name = 'Zambia'; +select 1 / count(*) from country where country_code = 'ZW' and name = 'Zimbabwe'; + +select 1 / count(*) from country_i18n where country_code = 'AD' and lang_tag = 'ca' and name = 'Andorra'; +select 1 / count(*) from country_i18n where country_code = 'AD' and lang_tag = 'es' and name = 'Andorra'; +select 1 / count(*) from country_i18n where country_code = 'AE' and lang_tag = 'ca' and name = 'Emirats Àrabs Units'; +select 1 / count(*) from country_i18n where country_code = 'AE' and lang_tag = 'es' and name = 'Emiratos Árabes Unidos'; +select 1 / count(*) from country_i18n where country_code = 'AF' and lang_tag = 'ca' and name = 'Afganistan'; +select 1 / count(*) from country_i18n where country_code = 'AF' and lang_tag = 'es' and name = 'Afganistán'; +select 1 / count(*) from country_i18n where country_code = 'AG' and lang_tag = 'ca' and name = 'Antigua i Barbuda'; +select 1 / count(*) from country_i18n where country_code = 'AG' and lang_tag = 'es' and name = 'Antigua y Barbuda'; +select 1 / count(*) from country_i18n where country_code = 'AI' and lang_tag = 'ca' and name = 'Anguilla'; +select 1 / count(*) from country_i18n where country_code = 'AI' and lang_tag = 'es' and name = 'Anguilla'; +select 1 / count(*) from country_i18n where country_code = 'AL' and lang_tag = 'ca' and name = 'Albània'; +select 1 / count(*) from country_i18n where country_code = 'AL' and lang_tag = 'es' and name = 'Albania'; +select 1 / count(*) from country_i18n where country_code = 'AM' and lang_tag = 'ca' and name = 'Armènia'; +select 1 / count(*) from country_i18n where country_code = 'AM' and lang_tag = 'es' and name = 'Armenia'; +select 1 / count(*) from country_i18n where country_code = 'AO' and lang_tag = 'ca' and name = 'Angola'; +select 1 / count(*) from country_i18n where country_code = 'AO' and lang_tag = 'es' and name = 'Angola'; +select 1 / count(*) from country_i18n where country_code = 'AQ' and lang_tag = 'ca' and name = 'Antàrtida'; +select 1 / count(*) from country_i18n where country_code = 'AQ' and lang_tag = 'es' and name = 'Antártida'; +select 1 / count(*) from country_i18n where country_code = 'AR' and lang_tag = 'ca' and name = 'Argentina'; +select 1 / count(*) from country_i18n where country_code = 'AR' and lang_tag = 'es' and name = 'Argentina'; +select 1 / count(*) from country_i18n where country_code = 'AS' and lang_tag = 'ca' and name = 'Samoa Nord-americana'; +select 1 / count(*) from country_i18n where country_code = 'AS' and lang_tag = 'es' and name = 'Samoa Americana'; +select 1 / count(*) from country_i18n where country_code = 'AT' and lang_tag = 'ca' and name = 'Àustria'; +select 1 / count(*) from country_i18n where country_code = 'AT' and lang_tag = 'es' and name = 'Austria'; +select 1 / count(*) from country_i18n where country_code = 'AU' and lang_tag = 'ca' and name = 'Austràlia'; +select 1 / count(*) from country_i18n where country_code = 'AU' and lang_tag = 'es' and name = 'Australia'; +select 1 / count(*) from country_i18n where country_code = 'AW' and lang_tag = 'ca' and name = 'Aruba'; +select 1 / count(*) from country_i18n where country_code = 'AW' and lang_tag = 'es' and name = 'Aruba'; +select 1 / count(*) from country_i18n where country_code = 'AX' and lang_tag = 'ca' and name = 'Illes Åland'; +select 1 / count(*) from country_i18n where country_code = 'AX' and lang_tag = 'es' and name = 'Islas Åland'; +select 1 / count(*) from country_i18n where country_code = 'AZ' and lang_tag = 'ca' and name = 'Azerbaidjan'; +select 1 / count(*) from country_i18n where country_code = 'AZ' and lang_tag = 'es' and name = 'Azerbaijan'; +select 1 / count(*) from country_i18n where country_code = 'BA' and lang_tag = 'ca' and name = 'Bòsnia i Hercegovina'; +select 1 / count(*) from country_i18n where country_code = 'BA' and lang_tag = 'es' and name = 'Bosnia y Herzegovina'; +select 1 / count(*) from country_i18n where country_code = 'BB' and lang_tag = 'ca' and name = 'Barbados'; +select 1 / count(*) from country_i18n where country_code = 'BB' and lang_tag = 'es' and name = 'Barbados'; +select 1 / count(*) from country_i18n where country_code = 'BD' and lang_tag = 'ca' and name = 'Bangladesh'; +select 1 / count(*) from country_i18n where country_code = 'BD' and lang_tag = 'es' and name = 'Bangladesh'; +select 1 / count(*) from country_i18n where country_code = 'BE' and lang_tag = 'ca' and name = 'Bèlgica'; +select 1 / count(*) from country_i18n where country_code = 'BE' and lang_tag = 'es' and name = 'Bélgica'; +select 1 / count(*) from country_i18n where country_code = 'BF' and lang_tag = 'ca' and name = 'Burkina Fasso'; +select 1 / count(*) from country_i18n where country_code = 'BF' and lang_tag = 'es' and name = 'Burkina Faso'; +select 1 / count(*) from country_i18n where country_code = 'BG' and lang_tag = 'ca' and name = 'Bulgària'; +select 1 / count(*) from country_i18n where country_code = 'BG' and lang_tag = 'es' and name = 'Bulgaria'; +select 1 / count(*) from country_i18n where country_code = 'BH' and lang_tag = 'ca' and name = 'Bahrain'; +select 1 / count(*) from country_i18n where country_code = 'BH' and lang_tag = 'es' and name = 'Bahrain'; +select 1 / count(*) from country_i18n where country_code = 'BI' and lang_tag = 'ca' and name = 'Burundi'; +select 1 / count(*) from country_i18n where country_code = 'BI' and lang_tag = 'es' and name = 'Burundi'; +select 1 / count(*) from country_i18n where country_code = 'BJ' and lang_tag = 'ca' and name = 'Benín'; +select 1 / count(*) from country_i18n where country_code = 'BJ' and lang_tag = 'es' and name = 'Benin'; +select 1 / count(*) from country_i18n where country_code = 'BL' and lang_tag = 'ca' and name = 'Saint-Barthélemy'; +select 1 / count(*) from country_i18n where country_code = 'BL' and lang_tag = 'es' and name = 'San Bartolomé'; +select 1 / count(*) from country_i18n where country_code = 'BM' and lang_tag = 'ca' and name = 'Bermuda'; +select 1 / count(*) from country_i18n where country_code = 'BM' and lang_tag = 'es' and name = 'Bermuda'; +select 1 / count(*) from country_i18n where country_code = 'BN' and lang_tag = 'ca' and name = 'Brunei'; +select 1 / count(*) from country_i18n where country_code = 'BN' and lang_tag = 'es' and name = 'Brunéi'; +select 1 / count(*) from country_i18n where country_code = 'BO' and lang_tag = 'ca' and name = 'Bolívia'; +select 1 / count(*) from country_i18n where country_code = 'BO' and lang_tag = 'es' and name = 'Bolivia'; +select 1 / count(*) from country_i18n where country_code = 'BQ' and lang_tag = 'ca' and name = 'Bonaire, Saint Eustatius and Saba'; +select 1 / count(*) from country_i18n where country_code = 'BQ' and lang_tag = 'es' and name = 'Bonaire, San Eustaquio y Saba'; +select 1 / count(*) from country_i18n where country_code = 'BR' and lang_tag = 'ca' and name = 'Brasil'; +select 1 / count(*) from country_i18n where country_code = 'BR' and lang_tag = 'es' and name = 'Brasil'; +select 1 / count(*) from country_i18n where country_code = 'BS' and lang_tag = 'ca' and name = 'Bahames'; +select 1 / count(*) from country_i18n where country_code = 'BS' and lang_tag = 'es' and name = 'Bahamas'; +select 1 / count(*) from country_i18n where country_code = 'BT' and lang_tag = 'ca' and name = 'Bhutan'; +select 1 / count(*) from country_i18n where country_code = 'BT' and lang_tag = 'es' and name = 'Bhutan'; +select 1 / count(*) from country_i18n where country_code = 'BV' and lang_tag = 'ca' and name = 'Illa Bouvet'; +select 1 / count(*) from country_i18n where country_code = 'BV' and lang_tag = 'es' and name = 'Isla Bouvet'; +select 1 / count(*) from country_i18n where country_code = 'BW' and lang_tag = 'ca' and name = 'Botswana'; +select 1 / count(*) from country_i18n where country_code = 'BW' and lang_tag = 'es' and name = 'Botswana'; +select 1 / count(*) from country_i18n where country_code = 'BY' and lang_tag = 'ca' and name = 'Bielorússia'; +select 1 / count(*) from country_i18n where country_code = 'BY' and lang_tag = 'es' and name = 'Bielorrusia'; +select 1 / count(*) from country_i18n where country_code = 'BZ' and lang_tag = 'ca' and name = 'Belize'; +select 1 / count(*) from country_i18n where country_code = 'BZ' and lang_tag = 'es' and name = 'Belize'; +select 1 / count(*) from country_i18n where country_code = 'CA' and lang_tag = 'ca' and name = 'Canadà'; +select 1 / count(*) from country_i18n where country_code = 'CA' and lang_tag = 'es' and name = 'Canadá'; +select 1 / count(*) from country_i18n where country_code = 'CC' and lang_tag = 'ca' and name = 'Illes Cocos (Keeling)'; +select 1 / count(*) from country_i18n where country_code = 'CC' and lang_tag = 'es' and name = 'Islas Cocos'; +select 1 / count(*) from country_i18n where country_code = 'CD' and lang_tag = 'ca' and name = 'Congo (Kinshasa)'; +select 1 / count(*) from country_i18n where country_code = 'CD' and lang_tag = 'es' and name = 'Congo (Kinshasa)'; +select 1 / count(*) from country_i18n where country_code = 'CF' and lang_tag = 'ca' and name = 'República Centreafricana'; +select 1 / count(*) from country_i18n where country_code = 'CF' and lang_tag = 'es' and name = 'República Centroafricana'; +select 1 / count(*) from country_i18n where country_code = 'CG' and lang_tag = 'ca' and name = 'Congo (Brazzaville)'; +select 1 / count(*) from country_i18n where country_code = 'CG' and lang_tag = 'es' and name = 'Congo (Brazzaville)'; +select 1 / count(*) from country_i18n where country_code = 'CH' and lang_tag = 'ca' and name = 'Suïssa'; +select 1 / count(*) from country_i18n where country_code = 'CH' and lang_tag = 'es' and name = 'Suiza'; +select 1 / count(*) from country_i18n where country_code = 'CI' and lang_tag = 'ca' and name = 'Costa d’Ivori'; +select 1 / count(*) from country_i18n where country_code = 'CI' and lang_tag = 'es' and name = 'Costa de Marfil'; +select 1 / count(*) from country_i18n where country_code = 'CK' and lang_tag = 'ca' and name = 'Illes Cook'; +select 1 / count(*) from country_i18n where country_code = 'CK' and lang_tag = 'es' and name = 'Islas Cook'; +select 1 / count(*) from country_i18n where country_code = 'CL' and lang_tag = 'ca' and name = 'Xile'; +select 1 / count(*) from country_i18n where country_code = 'CL' and lang_tag = 'es' and name = 'Chile'; +select 1 / count(*) from country_i18n where country_code = 'CM' and lang_tag = 'ca' and name = 'Camerun'; +select 1 / count(*) from country_i18n where country_code = 'CM' and lang_tag = 'es' and name = 'Camerún'; +select 1 / count(*) from country_i18n where country_code = 'CN' and lang_tag = 'ca' and name = 'Xina'; +select 1 / count(*) from country_i18n where country_code = 'CN' and lang_tag = 'es' and name = 'China'; +select 1 / count(*) from country_i18n where country_code = 'CO' and lang_tag = 'ca' and name = 'Colòmbia'; +select 1 / count(*) from country_i18n where country_code = 'CO' and lang_tag = 'es' and name = 'Colombia'; +select 1 / count(*) from country_i18n where country_code = 'CR' and lang_tag = 'ca' and name = 'Costa Rica'; +select 1 / count(*) from country_i18n where country_code = 'CR' and lang_tag = 'es' and name = 'Costa Rica'; +select 1 / count(*) from country_i18n where country_code = 'CU' and lang_tag = 'ca' and name = 'Cuba'; +select 1 / count(*) from country_i18n where country_code = 'CU' and lang_tag = 'es' and name = 'Cuba'; +select 1 / count(*) from country_i18n where country_code = 'CV' and lang_tag = 'ca' and name = 'Cap Verd'; +select 1 / count(*) from country_i18n where country_code = 'CV' and lang_tag = 'es' and name = 'Cabo Verde'; +select 1 / count(*) from country_i18n where country_code = 'CW' and lang_tag = 'ca' and name = 'Curaçao'; +select 1 / count(*) from country_i18n where country_code = 'CW' and lang_tag = 'es' and name = 'Curaçao'; +select 1 / count(*) from country_i18n where country_code = 'CX' and lang_tag = 'ca' and name = 'Illa Christmas'; +select 1 / count(*) from country_i18n where country_code = 'CX' and lang_tag = 'es' and name = 'Isla de Navidad'; +select 1 / count(*) from country_i18n where country_code = 'CY' and lang_tag = 'ca' and name = 'Xipre'; +select 1 / count(*) from country_i18n where country_code = 'CY' and lang_tag = 'es' and name = 'Chipre'; +select 1 / count(*) from country_i18n where country_code = 'CZ' and lang_tag = 'ca' and name = 'República Txeca'; +select 1 / count(*) from country_i18n where country_code = 'CZ' and lang_tag = 'es' and name = 'República Checa'; +select 1 / count(*) from country_i18n where country_code = 'DE' and lang_tag = 'ca' and name = 'Alemanya'; +select 1 / count(*) from country_i18n where country_code = 'DE' and lang_tag = 'es' and name = 'Alemania'; +select 1 / count(*) from country_i18n where country_code = 'DJ' and lang_tag = 'ca' and name = 'Djibouti'; +select 1 / count(*) from country_i18n where country_code = 'DJ' and lang_tag = 'es' and name = 'Djibouti'; +select 1 / count(*) from country_i18n where country_code = 'DK' and lang_tag = 'ca' and name = 'Dinamarca'; +select 1 / count(*) from country_i18n where country_code = 'DK' and lang_tag = 'es' and name = 'Dinamarca'; +select 1 / count(*) from country_i18n where country_code = 'DM' and lang_tag = 'ca' and name = 'Dominica'; +select 1 / count(*) from country_i18n where country_code = 'DM' and lang_tag = 'es' and name = 'Dominica'; +select 1 / count(*) from country_i18n where country_code = 'DO' and lang_tag = 'ca' and name = 'República Dominicana'; +select 1 / count(*) from country_i18n where country_code = 'DO' and lang_tag = 'es' and name = 'República Dominicana'; +select 1 / count(*) from country_i18n where country_code = 'DZ' and lang_tag = 'ca' and name = 'Algèria'; +select 1 / count(*) from country_i18n where country_code = 'DZ' and lang_tag = 'es' and name = 'Argelia'; +select 1 / count(*) from country_i18n where country_code = 'EC' and lang_tag = 'ca' and name = 'Equador'; +select 1 / count(*) from country_i18n where country_code = 'EC' and lang_tag = 'es' and name = 'Ecuador'; +select 1 / count(*) from country_i18n where country_code = 'EE' and lang_tag = 'ca' and name = 'Estònia'; +select 1 / count(*) from country_i18n where country_code = 'EE' and lang_tag = 'es' and name = 'Estonia'; +select 1 / count(*) from country_i18n where country_code = 'EG' and lang_tag = 'ca' and name = 'Egipte'; +select 1 / count(*) from country_i18n where country_code = 'EG' and lang_tag = 'es' and name = 'Egipto'; +select 1 / count(*) from country_i18n where country_code = 'EH' and lang_tag = 'ca' and name = 'Sàhara Occidental'; +select 1 / count(*) from country_i18n where country_code = 'EH' and lang_tag = 'es' and name = 'Sahara Occidental'; +select 1 / count(*) from country_i18n where country_code = 'ER' and lang_tag = 'ca' and name = 'Eritrea'; +select 1 / count(*) from country_i18n where country_code = 'ER' and lang_tag = 'es' and name = 'Eritrea'; +select 1 / count(*) from country_i18n where country_code = 'ES' and lang_tag = 'ca' and name = 'Espanya'; +select 1 / count(*) from country_i18n where country_code = 'ES' and lang_tag = 'es' and name = 'España'; +select 1 / count(*) from country_i18n where country_code = 'ET' and lang_tag = 'ca' and name = 'Etiòpia'; +select 1 / count(*) from country_i18n where country_code = 'ET' and lang_tag = 'es' and name = 'Etiopía'; +select 1 / count(*) from country_i18n where country_code = 'FI' and lang_tag = 'ca' and name = 'Finlàndia'; +select 1 / count(*) from country_i18n where country_code = 'FI' and lang_tag = 'es' and name = 'Finlandia'; +select 1 / count(*) from country_i18n where country_code = 'FJ' and lang_tag = 'ca' and name = 'Fiji'; +select 1 / count(*) from country_i18n where country_code = 'FJ' and lang_tag = 'es' and name = 'Fiyi'; +select 1 / count(*) from country_i18n where country_code = 'FK' and lang_tag = 'ca' and name = 'Illes Falkland'; +select 1 / count(*) from country_i18n where country_code = 'FK' and lang_tag = 'es' and name = 'Islas Malvinas'; +select 1 / count(*) from country_i18n where country_code = 'FM' and lang_tag = 'ca' and name = 'Micronèsia'; +select 1 / count(*) from country_i18n where country_code = 'FM' and lang_tag = 'es' and name = 'Micronesia'; +select 1 / count(*) from country_i18n where country_code = 'FO' and lang_tag = 'ca' and name = 'Illes Faroe'; +select 1 / count(*) from country_i18n where country_code = 'FO' and lang_tag = 'es' and name = 'Islas Feroe'; +select 1 / count(*) from country_i18n where country_code = 'FR' and lang_tag = 'ca' and name = 'França'; +select 1 / count(*) from country_i18n where country_code = 'FR' and lang_tag = 'es' and name = 'Francia'; +select 1 / count(*) from country_i18n where country_code = 'GA' and lang_tag = 'ca' and name = 'Gabon'; +select 1 / count(*) from country_i18n where country_code = 'GA' and lang_tag = 'es' and name = 'Gabón'; +select 1 / count(*) from country_i18n where country_code = 'GB' and lang_tag = 'ca' and name = 'Regne Unit (UK)'; +select 1 / count(*) from country_i18n where country_code = 'GB' and lang_tag = 'es' and name = 'Reino Unido (UK)'; +select 1 / count(*) from country_i18n where country_code = 'GD' and lang_tag = 'ca' and name = 'Grenada'; +select 1 / count(*) from country_i18n where country_code = 'GD' and lang_tag = 'es' and name = 'Granada'; +select 1 / count(*) from country_i18n where country_code = 'GE' and lang_tag = 'ca' and name = 'Geòrgia'; +select 1 / count(*) from country_i18n where country_code = 'GE' and lang_tag = 'es' and name = 'Georgia'; +select 1 / count(*) from country_i18n where country_code = 'GF' and lang_tag = 'ca' and name = 'Guaiana Francesa'; +select 1 / count(*) from country_i18n where country_code = 'GF' and lang_tag = 'es' and name = 'Guayana Francesa'; +select 1 / count(*) from country_i18n where country_code = 'GG' and lang_tag = 'ca' and name = 'Guernsey'; +select 1 / count(*) from country_i18n where country_code = 'GG' and lang_tag = 'es' and name = 'Guernsey'; +select 1 / count(*) from country_i18n where country_code = 'GH' and lang_tag = 'ca' and name = 'Ghana'; +select 1 / count(*) from country_i18n where country_code = 'GH' and lang_tag = 'es' and name = 'Ghana'; +select 1 / count(*) from country_i18n where country_code = 'GI' and lang_tag = 'ca' and name = 'Gibraltar'; +select 1 / count(*) from country_i18n where country_code = 'GI' and lang_tag = 'es' and name = 'Gibraltar'; +select 1 / count(*) from country_i18n where country_code = 'GL' and lang_tag = 'ca' and name = 'Groenlàndia'; +select 1 / count(*) from country_i18n where country_code = 'GL' and lang_tag = 'es' and name = 'Groenlandia'; +select 1 / count(*) from country_i18n where country_code = 'GM' and lang_tag = 'ca' and name = 'Gàmbia'; +select 1 / count(*) from country_i18n where country_code = 'GM' and lang_tag = 'es' and name = 'Gambia'; +select 1 / count(*) from country_i18n where country_code = 'GN' and lang_tag = 'ca' and name = 'Guinea'; +select 1 / count(*) from country_i18n where country_code = 'GN' and lang_tag = 'es' and name = 'Guinea'; +select 1 / count(*) from country_i18n where country_code = 'GP' and lang_tag = 'ca' and name = 'Guadalupe'; +select 1 / count(*) from country_i18n where country_code = 'GP' and lang_tag = 'es' and name = 'Guadalupe'; +select 1 / count(*) from country_i18n where country_code = 'GQ' and lang_tag = 'ca' and name = 'Guinea Equatorial'; +select 1 / count(*) from country_i18n where country_code = 'GQ' and lang_tag = 'es' and name = 'Guinea Ecuatorial'; +select 1 / count(*) from country_i18n where country_code = 'GR' and lang_tag = 'ca' and name = 'Grècia'; +select 1 / count(*) from country_i18n where country_code = 'GR' and lang_tag = 'es' and name = 'Grecia'; +select 1 / count(*) from country_i18n where country_code = 'GS' and lang_tag = 'ca' and name = 'Illes Geòrgia del Sud i Sandwich del Sud'; +select 1 / count(*) from country_i18n where country_code = 'GS' and lang_tag = 'es' and name = 'Islas Georgias y Sandwich del Sur'; +select 1 / count(*) from country_i18n where country_code = 'GT' and lang_tag = 'ca' and name = 'Guatemala'; +select 1 / count(*) from country_i18n where country_code = 'GT' and lang_tag = 'es' and name = 'Guatemala'; +select 1 / count(*) from country_i18n where country_code = 'GU' and lang_tag = 'ca' and name = 'Guam'; +select 1 / count(*) from country_i18n where country_code = 'GU' and lang_tag = 'es' and name = 'Guam'; +select 1 / count(*) from country_i18n where country_code = 'GW' and lang_tag = 'ca' and name = 'Guinea Bissau'; +select 1 / count(*) from country_i18n where country_code = 'GW' and lang_tag = 'es' and name = 'Guinea-Bisáu'; +select 1 / count(*) from country_i18n where country_code = 'GY' and lang_tag = 'ca' and name = 'Guyana'; +select 1 / count(*) from country_i18n where country_code = 'GY' and lang_tag = 'es' and name = 'Guyana'; +select 1 / count(*) from country_i18n where country_code = 'HK' and lang_tag = 'ca' and name = 'Hong Kong'; +select 1 / count(*) from country_i18n where country_code = 'HK' and lang_tag = 'es' and name = 'Hong Kong'; +select 1 / count(*) from country_i18n where country_code = 'HM' and lang_tag = 'ca' and name = 'Illes Heard i McDonald'; +select 1 / count(*) from country_i18n where country_code = 'HM' and lang_tag = 'es' and name = 'Islas Heard y McDonald'; +select 1 / count(*) from country_i18n where country_code = 'HN' and lang_tag = 'ca' and name = 'Hondures'; +select 1 / count(*) from country_i18n where country_code = 'HN' and lang_tag = 'es' and name = 'Honduras'; +select 1 / count(*) from country_i18n where country_code = 'HR' and lang_tag = 'ca' and name = 'Croàcia'; +select 1 / count(*) from country_i18n where country_code = 'HR' and lang_tag = 'es' and name = 'Croacia'; +select 1 / count(*) from country_i18n where country_code = 'HT' and lang_tag = 'ca' and name = 'Haití'; +select 1 / count(*) from country_i18n where country_code = 'HT' and lang_tag = 'es' and name = 'Haití'; +select 1 / count(*) from country_i18n where country_code = 'HU' and lang_tag = 'ca' and name = 'Hongria'; +select 1 / count(*) from country_i18n where country_code = 'HU' and lang_tag = 'es' and name = 'Hungría'; +select 1 / count(*) from country_i18n where country_code = 'ID' and lang_tag = 'ca' and name = 'Indonèsia'; +select 1 / count(*) from country_i18n where country_code = 'ID' and lang_tag = 'es' and name = 'Indonesia'; +select 1 / count(*) from country_i18n where country_code = 'IE' and lang_tag = 'ca' and name = 'Irlanda'; +select 1 / count(*) from country_i18n where country_code = 'IE' and lang_tag = 'es' and name = 'Irlanda'; +select 1 / count(*) from country_i18n where country_code = 'IL' and lang_tag = 'ca' and name = 'Israel'; +select 1 / count(*) from country_i18n where country_code = 'IL' and lang_tag = 'es' and name = 'Israel'; +select 1 / count(*) from country_i18n where country_code = 'IM' and lang_tag = 'ca' and name = 'Illa de Man'; +select 1 / count(*) from country_i18n where country_code = 'IM' and lang_tag = 'es' and name = 'Isla de Man'; +select 1 / count(*) from country_i18n where country_code = 'IN' and lang_tag = 'ca' and name = 'Índia'; +select 1 / count(*) from country_i18n where country_code = 'IN' and lang_tag = 'es' and name = 'India'; +select 1 / count(*) from country_i18n where country_code = 'IO' and lang_tag = 'ca' and name = 'Territori Britànic de l’Oceà Índic'; +select 1 / count(*) from country_i18n where country_code = 'IO' and lang_tag = 'es' and name = 'Territorio Británico del Océano Índico'; +select 1 / count(*) from country_i18n where country_code = 'IQ' and lang_tag = 'ca' and name = 'Iraq'; +select 1 / count(*) from country_i18n where country_code = 'IQ' and lang_tag = 'es' and name = 'Irak'; +select 1 / count(*) from country_i18n where country_code = 'IR' and lang_tag = 'ca' and name = 'Iran'; +select 1 / count(*) from country_i18n where country_code = 'IR' and lang_tag = 'es' and name = 'Irán'; +select 1 / count(*) from country_i18n where country_code = 'IS' and lang_tag = 'ca' and name = 'Islàndia'; +select 1 / count(*) from country_i18n where country_code = 'IS' and lang_tag = 'es' and name = 'Islandia'; +select 1 / count(*) from country_i18n where country_code = 'IT' and lang_tag = 'ca' and name = 'Itàlia'; +select 1 / count(*) from country_i18n where country_code = 'IT' and lang_tag = 'es' and name = 'Italia'; +select 1 / count(*) from country_i18n where country_code = 'JE' and lang_tag = 'ca' and name = 'Jersey'; +select 1 / count(*) from country_i18n where country_code = 'JE' and lang_tag = 'es' and name = 'Jersey'; +select 1 / count(*) from country_i18n where country_code = 'JM' and lang_tag = 'ca' and name = 'Jamaica'; +select 1 / count(*) from country_i18n where country_code = 'JM' and lang_tag = 'es' and name = 'Jamaica'; +select 1 / count(*) from country_i18n where country_code = 'JO' and lang_tag = 'ca' and name = 'Jordània'; +select 1 / count(*) from country_i18n where country_code = 'JO' and lang_tag = 'es' and name = 'Jordania'; +select 1 / count(*) from country_i18n where country_code = 'JP' and lang_tag = 'ca' and name = 'Japó'; +select 1 / count(*) from country_i18n where country_code = 'JP' and lang_tag = 'es' and name = 'Japón'; +select 1 / count(*) from country_i18n where country_code = 'KE' and lang_tag = 'ca' and name = 'Kenya'; +select 1 / count(*) from country_i18n where country_code = 'KE' and lang_tag = 'es' and name = 'Kenia'; +select 1 / count(*) from country_i18n where country_code = 'KG' and lang_tag = 'ca' and name = 'Kirguizistan'; +select 1 / count(*) from country_i18n where country_code = 'KG' and lang_tag = 'es' and name = 'Kirguistán'; +select 1 / count(*) from country_i18n where country_code = 'KH' and lang_tag = 'ca' and name = 'Cambodja'; +select 1 / count(*) from country_i18n where country_code = 'KH' and lang_tag = 'es' and name = 'Camboya'; +select 1 / count(*) from country_i18n where country_code = 'KI' and lang_tag = 'ca' and name = 'Kiribati'; +select 1 / count(*) from country_i18n where country_code = 'KI' and lang_tag = 'es' and name = 'Kiribati'; +select 1 / count(*) from country_i18n where country_code = 'KM' and lang_tag = 'ca' and name = 'Comores'; +select 1 / count(*) from country_i18n where country_code = 'KM' and lang_tag = 'es' and name = 'Comoras'; +select 1 / count(*) from country_i18n where country_code = 'KN' and lang_tag = 'ca' and name = 'Saint Kitts i Nevis'; +select 1 / count(*) from country_i18n where country_code = 'KN' and lang_tag = 'es' and name = 'San Cristóbal y Nieves'; +select 1 / count(*) from country_i18n where country_code = 'KP' and lang_tag = 'ca' and name = 'Corea del Nord'; +select 1 / count(*) from country_i18n where country_code = 'KP' and lang_tag = 'es' and name = 'Corea del Norte'; +select 1 / count(*) from country_i18n where country_code = 'KR' and lang_tag = 'ca' and name = 'Corea del Sud'; +select 1 / count(*) from country_i18n where country_code = 'KR' and lang_tag = 'es' and name = 'Corea del Sur'; +select 1 / count(*) from country_i18n where country_code = 'KW' and lang_tag = 'ca' and name = 'Kuwait'; +select 1 / count(*) from country_i18n where country_code = 'KW' and lang_tag = 'es' and name = 'Kuwait'; +select 1 / count(*) from country_i18n where country_code = 'KY' and lang_tag = 'ca' and name = 'Illes Caiman'; +select 1 / count(*) from country_i18n where country_code = 'KY' and lang_tag = 'es' and name = 'Islas Caimán'; +select 1 / count(*) from country_i18n where country_code = 'KZ' and lang_tag = 'ca' and name = 'Kazakhstan'; +select 1 / count(*) from country_i18n where country_code = 'KZ' and lang_tag = 'es' and name = 'Kazajistán'; +select 1 / count(*) from country_i18n where country_code = 'LA' and lang_tag = 'ca' and name = 'Laos'; +select 1 / count(*) from country_i18n where country_code = 'LA' and lang_tag = 'es' and name = 'Laos'; +select 1 / count(*) from country_i18n where country_code = 'LB' and lang_tag = 'ca' and name = 'Líban'; +select 1 / count(*) from country_i18n where country_code = 'LB' and lang_tag = 'es' and name = 'Líbano'; +select 1 / count(*) from country_i18n where country_code = 'LC' and lang_tag = 'ca' and name = 'Saint Lucia'; +select 1 / count(*) from country_i18n where country_code = 'LC' and lang_tag = 'es' and name = 'Santa Lucía'; +select 1 / count(*) from country_i18n where country_code = 'LI' and lang_tag = 'ca' and name = 'Liechtenstein'; +select 1 / count(*) from country_i18n where country_code = 'LI' and lang_tag = 'es' and name = 'Liechtenstein'; +select 1 / count(*) from country_i18n where country_code = 'LK' and lang_tag = 'ca' and name = 'Sri Lanka'; +select 1 / count(*) from country_i18n where country_code = 'LK' and lang_tag = 'es' and name = 'Sri Lanka'; +select 1 / count(*) from country_i18n where country_code = 'LR' and lang_tag = 'ca' and name = 'Libèria'; +select 1 / count(*) from country_i18n where country_code = 'LR' and lang_tag = 'es' and name = 'Liberia'; +select 1 / count(*) from country_i18n where country_code = 'LS' and lang_tag = 'ca' and name = 'Lesotho'; +select 1 / count(*) from country_i18n where country_code = 'LS' and lang_tag = 'es' and name = 'Lesoto'; +select 1 / count(*) from country_i18n where country_code = 'LT' and lang_tag = 'ca' and name = 'Lituània'; +select 1 / count(*) from country_i18n where country_code = 'LT' and lang_tag = 'es' and name = 'Lituania'; +select 1 / count(*) from country_i18n where country_code = 'LU' and lang_tag = 'ca' and name = 'Luxemburg'; +select 1 / count(*) from country_i18n where country_code = 'LU' and lang_tag = 'es' and name = 'Luxemburgo'; +select 1 / count(*) from country_i18n where country_code = 'LV' and lang_tag = 'ca' and name = 'Letònia'; +select 1 / count(*) from country_i18n where country_code = 'LV' and lang_tag = 'es' and name = 'Letonia'; +select 1 / count(*) from country_i18n where country_code = 'LY' and lang_tag = 'ca' and name = 'Líbia'; +select 1 / count(*) from country_i18n where country_code = 'LY' and lang_tag = 'es' and name = 'Libia'; +select 1 / count(*) from country_i18n where country_code = 'MA' and lang_tag = 'ca' and name = 'Marroc'; +select 1 / count(*) from country_i18n where country_code = 'MA' and lang_tag = 'es' and name = 'Marruecos'; +select 1 / count(*) from country_i18n where country_code = 'MC' and lang_tag = 'ca' and name = 'Mònaco'; +select 1 / count(*) from country_i18n where country_code = 'MC' and lang_tag = 'es' and name = 'Mónaco'; +select 1 / count(*) from country_i18n where country_code = 'MD' and lang_tag = 'ca' and name = 'Moldàvia'; +select 1 / count(*) from country_i18n where country_code = 'MD' and lang_tag = 'es' and name = 'Moldavia'; +select 1 / count(*) from country_i18n where country_code = 'ME' and lang_tag = 'ca' and name = 'Montenegro'; +select 1 / count(*) from country_i18n where country_code = 'ME' and lang_tag = 'es' and name = 'Montenegro'; +select 1 / count(*) from country_i18n where country_code = 'MF' and lang_tag = 'ca' and name = 'Saint Martin (part francesa)'; +select 1 / count(*) from country_i18n where country_code = 'MF' and lang_tag = 'es' and name = 'San Martín (parte de Francia)'; +select 1 / count(*) from country_i18n where country_code = 'MG' and lang_tag = 'ca' and name = 'Madagascar'; +select 1 / count(*) from country_i18n where country_code = 'MG' and lang_tag = 'es' and name = 'Madagascar'; +select 1 / count(*) from country_i18n where country_code = 'MH' and lang_tag = 'ca' and name = 'Illes Marshall'; +select 1 / count(*) from country_i18n where country_code = 'MH' and lang_tag = 'es' and name = 'Islas Marshall'; +select 1 / count(*) from country_i18n where country_code = 'MK' and lang_tag = 'ca' and name = 'Macedònia del Nord'; +select 1 / count(*) from country_i18n where country_code = 'MK' and lang_tag = 'es' and name = 'Macedonia del Norte'; +select 1 / count(*) from country_i18n where country_code = 'ML' and lang_tag = 'ca' and name = 'Mali'; +select 1 / count(*) from country_i18n where country_code = 'ML' and lang_tag = 'es' and name = 'Malí'; +select 1 / count(*) from country_i18n where country_code = 'MM' and lang_tag = 'ca' and name = 'Myanmar'; +select 1 / count(*) from country_i18n where country_code = 'MM' and lang_tag = 'es' and name = 'Birmania'; +select 1 / count(*) from country_i18n where country_code = 'MN' and lang_tag = 'ca' and name = 'Mongòlia'; +select 1 / count(*) from country_i18n where country_code = 'MN' and lang_tag = 'es' and name = 'Mongolia'; +select 1 / count(*) from country_i18n where country_code = 'MO' and lang_tag = 'ca' and name = 'Macau'; +select 1 / count(*) from country_i18n where country_code = 'MO' and lang_tag = 'es' and name = 'Macao'; +select 1 / count(*) from country_i18n where country_code = 'MP' and lang_tag = 'ca' and name = 'Illes Mariannes Septentrionals'; +select 1 / count(*) from country_i18n where country_code = 'MP' and lang_tag = 'es' and name = 'Islas Marianas del Norte'; +select 1 / count(*) from country_i18n where country_code = 'MQ' and lang_tag = 'ca' and name = 'Martinica'; +select 1 / count(*) from country_i18n where country_code = 'MQ' and lang_tag = 'es' and name = 'Martinica'; +select 1 / count(*) from country_i18n where country_code = 'MR' and lang_tag = 'ca' and name = 'Mauritània'; +select 1 / count(*) from country_i18n where country_code = 'MR' and lang_tag = 'es' and name = 'Mauritania'; +select 1 / count(*) from country_i18n where country_code = 'MS' and lang_tag = 'ca' and name = 'Montserrat'; +select 1 / count(*) from country_i18n where country_code = 'MS' and lang_tag = 'es' and name = 'Montserrat'; +select 1 / count(*) from country_i18n where country_code = 'MT' and lang_tag = 'ca' and name = 'Malta'; +select 1 / count(*) from country_i18n where country_code = 'MT' and lang_tag = 'es' and name = 'Malta'; +select 1 / count(*) from country_i18n where country_code = 'MU' and lang_tag = 'ca' and name = 'Maurici'; +select 1 / count(*) from country_i18n where country_code = 'MU' and lang_tag = 'es' and name = 'Mauricio'; +select 1 / count(*) from country_i18n where country_code = 'MV' and lang_tag = 'ca' and name = 'Maldives'; +select 1 / count(*) from country_i18n where country_code = 'MV' and lang_tag = 'es' and name = 'Maldivas'; +select 1 / count(*) from country_i18n where country_code = 'MW' and lang_tag = 'ca' and name = 'Malawi'; +select 1 / count(*) from country_i18n where country_code = 'MW' and lang_tag = 'es' and name = 'Malaui'; +select 1 / count(*) from country_i18n where country_code = 'MX' and lang_tag = 'ca' and name = 'Mèxic'; +select 1 / count(*) from country_i18n where country_code = 'MX' and lang_tag = 'es' and name = 'México'; +select 1 / count(*) from country_i18n where country_code = 'MY' and lang_tag = 'ca' and name = 'Malàisia'; +select 1 / count(*) from country_i18n where country_code = 'MY' and lang_tag = 'es' and name = 'Malasia'; +select 1 / count(*) from country_i18n where country_code = 'MZ' and lang_tag = 'ca' and name = 'Moçambic'; +select 1 / count(*) from country_i18n where country_code = 'MZ' and lang_tag = 'es' and name = 'Mozambique'; +select 1 / count(*) from country_i18n where country_code = 'NA' and lang_tag = 'ca' and name = 'Namíbia'; +select 1 / count(*) from country_i18n where country_code = 'NA' and lang_tag = 'es' and name = 'Namibia'; +select 1 / count(*) from country_i18n where country_code = 'NC' and lang_tag = 'ca' and name = 'Nova Caledònia'; +select 1 / count(*) from country_i18n where country_code = 'NC' and lang_tag = 'es' and name = 'Nueva Caledonia'; +select 1 / count(*) from country_i18n where country_code = 'NE' and lang_tag = 'ca' and name = 'Níger'; +select 1 / count(*) from country_i18n where country_code = 'NE' and lang_tag = 'es' and name = 'Níger'; +select 1 / count(*) from country_i18n where country_code = 'NF' and lang_tag = 'ca' and name = 'Illa Norfolk'; +select 1 / count(*) from country_i18n where country_code = 'NF' and lang_tag = 'es' and name = 'Isla Norfolk'; +select 1 / count(*) from country_i18n where country_code = 'NG' and lang_tag = 'ca' and name = 'Nigèria'; +select 1 / count(*) from country_i18n where country_code = 'NG' and lang_tag = 'es' and name = 'Nigeria'; +select 1 / count(*) from country_i18n where country_code = 'NI' and lang_tag = 'ca' and name = 'Nicaragua'; +select 1 / count(*) from country_i18n where country_code = 'NI' and lang_tag = 'es' and name = 'Nicaragua'; +select 1 / count(*) from country_i18n where country_code = 'NL' and lang_tag = 'ca' and name = 'Països Baixos'; +select 1 / count(*) from country_i18n where country_code = 'NL' and lang_tag = 'es' and name = 'Países Bajos'; +select 1 / count(*) from country_i18n where country_code = 'NO' and lang_tag = 'ca' and name = 'Noruega'; +select 1 / count(*) from country_i18n where country_code = 'NO' and lang_tag = 'es' and name = 'Noruega'; +select 1 / count(*) from country_i18n where country_code = 'NP' and lang_tag = 'ca' and name = 'Nepal'; +select 1 / count(*) from country_i18n where country_code = 'NP' and lang_tag = 'es' and name = 'Nepal'; +select 1 / count(*) from country_i18n where country_code = 'NR' and lang_tag = 'ca' and name = 'Nauru'; +select 1 / count(*) from country_i18n where country_code = 'NR' and lang_tag = 'es' and name = 'Nauru'; +select 1 / count(*) from country_i18n where country_code = 'NU' and lang_tag = 'ca' and name = 'Niue'; +select 1 / count(*) from country_i18n where country_code = 'NU' and lang_tag = 'es' and name = 'Niue'; +select 1 / count(*) from country_i18n where country_code = 'NZ' and lang_tag = 'ca' and name = 'Nova Zelanda'; +select 1 / count(*) from country_i18n where country_code = 'NZ' and lang_tag = 'es' and name = 'Nueva Zelanda'; +select 1 / count(*) from country_i18n where country_code = 'OM' and lang_tag = 'ca' and name = 'Oman'; +select 1 / count(*) from country_i18n where country_code = 'OM' and lang_tag = 'es' and name = 'Omán'; +select 1 / count(*) from country_i18n where country_code = 'PA' and lang_tag = 'ca' and name = 'Panamà'; +select 1 / count(*) from country_i18n where country_code = 'PA' and lang_tag = 'es' and name = 'Panamá'; +select 1 / count(*) from country_i18n where country_code = 'PE' and lang_tag = 'ca' and name = 'Perú'; +select 1 / count(*) from country_i18n where country_code = 'PE' and lang_tag = 'es' and name = 'Perú'; +select 1 / count(*) from country_i18n where country_code = 'PF' and lang_tag = 'ca' and name = 'Polinèsia Francesa'; +select 1 / count(*) from country_i18n where country_code = 'PF' and lang_tag = 'es' and name = 'Polinesia Francesa'; +select 1 / count(*) from country_i18n where country_code = 'PG' and lang_tag = 'ca' and name = 'Papua Nova Guinea'; +select 1 / count(*) from country_i18n where country_code = 'PG' and lang_tag = 'es' and name = 'Papúa Nueva Guinea'; +select 1 / count(*) from country_i18n where country_code = 'PH' and lang_tag = 'ca' and name = 'Filipines'; +select 1 / count(*) from country_i18n where country_code = 'PH' and lang_tag = 'es' and name = 'Filipinas'; +select 1 / count(*) from country_i18n where country_code = 'PK' and lang_tag = 'ca' and name = 'Pakistan'; +select 1 / count(*) from country_i18n where country_code = 'PK' and lang_tag = 'es' and name = 'Pakistán'; +select 1 / count(*) from country_i18n where country_code = 'PL' and lang_tag = 'ca' and name = 'Polònia'; +select 1 / count(*) from country_i18n where country_code = 'PL' and lang_tag = 'es' and name = 'Polonia'; +select 1 / count(*) from country_i18n where country_code = 'PM' and lang_tag = 'ca' and name = 'Saint-Pierre i Miquelon'; +select 1 / count(*) from country_i18n where country_code = 'PM' and lang_tag = 'es' and name = 'San Pedro y Miquelón'; +select 1 / count(*) from country_i18n where country_code = 'PN' and lang_tag = 'ca' and name = 'Pitcairn'; +select 1 / count(*) from country_i18n where country_code = 'PN' and lang_tag = 'es' and name = 'Pitcairn'; +select 1 / count(*) from country_i18n where country_code = 'PR' and lang_tag = 'ca' and name = 'Puerto Rico'; +select 1 / count(*) from country_i18n where country_code = 'PR' and lang_tag = 'es' and name = 'Puerto Rico'; +select 1 / count(*) from country_i18n where country_code = 'PS' and lang_tag = 'ca' and name = 'Palestina'; +select 1 / count(*) from country_i18n where country_code = 'PS' and lang_tag = 'es' and name = 'Territorios Palestinos'; +select 1 / count(*) from country_i18n where country_code = 'PT' and lang_tag = 'ca' and name = 'Portugal'; +select 1 / count(*) from country_i18n where country_code = 'PT' and lang_tag = 'es' and name = 'Portugal'; +select 1 / count(*) from country_i18n where country_code = 'PW' and lang_tag = 'ca' and name = 'Belau'; +select 1 / count(*) from country_i18n where country_code = 'PW' and lang_tag = 'es' and name = 'Belau'; +select 1 / count(*) from country_i18n where country_code = 'PY' and lang_tag = 'ca' and name = 'Paraguai'; +select 1 / count(*) from country_i18n where country_code = 'PY' and lang_tag = 'es' and name = 'Paraguay'; +select 1 / count(*) from country_i18n where country_code = 'QA' and lang_tag = 'ca' and name = 'Qatar'; +select 1 / count(*) from country_i18n where country_code = 'QA' and lang_tag = 'es' and name = 'Qatar'; +select 1 / count(*) from country_i18n where country_code = 'RE' and lang_tag = 'ca' and name = 'Reunió'; +select 1 / count(*) from country_i18n where country_code = 'RE' and lang_tag = 'es' and name = 'Reunión'; +select 1 / count(*) from country_i18n where country_code = 'RO' and lang_tag = 'ca' and name = 'Romania'; +select 1 / count(*) from country_i18n where country_code = 'RO' and lang_tag = 'es' and name = 'Rumania'; +select 1 / count(*) from country_i18n where country_code = 'RS' and lang_tag = 'ca' and name = 'Sèrbia'; +select 1 / count(*) from country_i18n where country_code = 'RS' and lang_tag = 'es' and name = 'Serbia'; +select 1 / count(*) from country_i18n where country_code = 'RU' and lang_tag = 'ca' and name = 'Rússia'; +select 1 / count(*) from country_i18n where country_code = 'RU' and lang_tag = 'es' and name = 'Rusia'; +select 1 / count(*) from country_i18n where country_code = 'RW' and lang_tag = 'ca' and name = 'Ruanda'; +select 1 / count(*) from country_i18n where country_code = 'RW' and lang_tag = 'es' and name = 'Ruanda'; +select 1 / count(*) from country_i18n where country_code = 'SA' and lang_tag = 'ca' and name = 'Aràbia Saudita'; +select 1 / count(*) from country_i18n where country_code = 'SA' and lang_tag = 'es' and name = 'Arabia Saudita'; +select 1 / count(*) from country_i18n where country_code = 'SB' and lang_tag = 'ca' and name = 'Illes Salomó'; +select 1 / count(*) from country_i18n where country_code = 'SB' and lang_tag = 'es' and name = 'Islas Salomón'; +select 1 / count(*) from country_i18n where country_code = 'SC' and lang_tag = 'ca' and name = 'Seychelles'; +select 1 / count(*) from country_i18n where country_code = 'SC' and lang_tag = 'es' and name = 'Seychelles'; +select 1 / count(*) from country_i18n where country_code = 'SD' and lang_tag = 'ca' and name = 'Sudan'; +select 1 / count(*) from country_i18n where country_code = 'SD' and lang_tag = 'es' and name = 'Sudán'; +select 1 / count(*) from country_i18n where country_code = 'SE' and lang_tag = 'ca' and name = 'Suècia'; +select 1 / count(*) from country_i18n where country_code = 'SE' and lang_tag = 'es' and name = 'Suecia'; +select 1 / count(*) from country_i18n where country_code = 'SG' and lang_tag = 'ca' and name = 'Singapur'; +select 1 / count(*) from country_i18n where country_code = 'SG' and lang_tag = 'es' and name = 'Singapur'; +select 1 / count(*) from country_i18n where country_code = 'SH' and lang_tag = 'ca' and name = 'Saint Helena'; +select 1 / count(*) from country_i18n where country_code = 'SH' and lang_tag = 'es' and name = 'Isla Santa Elena'; +select 1 / count(*) from country_i18n where country_code = 'SI' and lang_tag = 'ca' and name = 'Eslovènia'; +select 1 / count(*) from country_i18n where country_code = 'SI' and lang_tag = 'es' and name = 'Eslovenia'; +select 1 / count(*) from country_i18n where country_code = 'SJ' and lang_tag = 'ca' and name = 'Svalbard i Jan Mayen'; +select 1 / count(*) from country_i18n where country_code = 'SJ' and lang_tag = 'es' and name = 'Svalbard y Jan Mayen'; +select 1 / count(*) from country_i18n where country_code = 'SK' and lang_tag = 'ca' and name = 'Eslovàquia'; +select 1 / count(*) from country_i18n where country_code = 'SK' and lang_tag = 'es' and name = 'Eslovaquia'; +select 1 / count(*) from country_i18n where country_code = 'SL' and lang_tag = 'ca' and name = 'Sierra Leone'; +select 1 / count(*) from country_i18n where country_code = 'SL' and lang_tag = 'es' and name = 'Sierra Leona'; +select 1 / count(*) from country_i18n where country_code = 'SM' and lang_tag = 'ca' and name = 'San Marino'; +select 1 / count(*) from country_i18n where country_code = 'SM' and lang_tag = 'es' and name = 'San Marino'; +select 1 / count(*) from country_i18n where country_code = 'SN' and lang_tag = 'ca' and name = 'Senegal'; +select 1 / count(*) from country_i18n where country_code = 'SN' and lang_tag = 'es' and name = 'Senegal'; +select 1 / count(*) from country_i18n where country_code = 'SO' and lang_tag = 'ca' and name = 'Somàlia'; +select 1 / count(*) from country_i18n where country_code = 'SO' and lang_tag = 'es' and name = 'Somalia'; +select 1 / count(*) from country_i18n where country_code = 'SR' and lang_tag = 'ca' and name = 'Surinam'; +select 1 / count(*) from country_i18n where country_code = 'SR' and lang_tag = 'es' and name = 'Surinam'; +select 1 / count(*) from country_i18n where country_code = 'SS' and lang_tag = 'ca' and name = 'Sudan del Sud'; +select 1 / count(*) from country_i18n where country_code = 'SS' and lang_tag = 'es' and name = 'Sudán del Sur'; +select 1 / count(*) from country_i18n where country_code = 'ST' and lang_tag = 'ca' and name = 'São Tomé i Príncipe'; +select 1 / count(*) from country_i18n where country_code = 'ST' and lang_tag = 'es' and name = 'Santo Tomé y Príncipe'; +select 1 / count(*) from country_i18n where country_code = 'SV' and lang_tag = 'ca' and name = 'El Salvador'; +select 1 / count(*) from country_i18n where country_code = 'SV' and lang_tag = 'es' and name = 'El Salvador'; +select 1 / count(*) from country_i18n where country_code = 'SX' and lang_tag = 'ca' and name = 'Saint Martin (part holandesa)'; +select 1 / count(*) from country_i18n where country_code = 'SX' and lang_tag = 'es' and name = 'San Martín (Países Bajos)'; +select 1 / count(*) from country_i18n where country_code = 'SY' and lang_tag = 'ca' and name = 'Síria'; +select 1 / count(*) from country_i18n where country_code = 'SY' and lang_tag = 'es' and name = 'Siria'; +select 1 / count(*) from country_i18n where country_code = 'SZ' and lang_tag = 'ca' and name = 'Eswatini'; +select 1 / count(*) from country_i18n where country_code = 'SZ' and lang_tag = 'es' and name = 'Esuatini'; +select 1 / count(*) from country_i18n where country_code = 'TC' and lang_tag = 'ca' and name = 'Illes Turks i Caicos'; +select 1 / count(*) from country_i18n where country_code = 'TC' and lang_tag = 'es' and name = 'Islas Turcas y Caicos'; +select 1 / count(*) from country_i18n where country_code = 'TD' and lang_tag = 'ca' and name = 'Txad'; +select 1 / count(*) from country_i18n where country_code = 'TD' and lang_tag = 'es' and name = 'Chad'; +select 1 / count(*) from country_i18n where country_code = 'TF' and lang_tag = 'ca' and name = 'Terres Australs Franceses'; +select 1 / count(*) from country_i18n where country_code = 'TF' and lang_tag = 'es' and name = 'Territorios australes franceses'; +select 1 / count(*) from country_i18n where country_code = 'TG' and lang_tag = 'ca' and name = 'Togo'; +select 1 / count(*) from country_i18n where country_code = 'TG' and lang_tag = 'es' and name = 'Togo'; +select 1 / count(*) from country_i18n where country_code = 'TH' and lang_tag = 'ca' and name = 'Tailàndia'; +select 1 / count(*) from country_i18n where country_code = 'TH' and lang_tag = 'es' and name = 'Tailandia'; +select 1 / count(*) from country_i18n where country_code = 'TJ' and lang_tag = 'ca' and name = 'Tadjikistan'; +select 1 / count(*) from country_i18n where country_code = 'TJ' and lang_tag = 'es' and name = 'Tayikistán'; +select 1 / count(*) from country_i18n where country_code = 'TK' and lang_tag = 'ca' and name = 'Tokelau'; +select 1 / count(*) from country_i18n where country_code = 'TK' and lang_tag = 'es' and name = 'Tokelau'; +select 1 / count(*) from country_i18n where country_code = 'TL' and lang_tag = 'ca' and name = 'Timor Oriental'; +select 1 / count(*) from country_i18n where country_code = 'TL' and lang_tag = 'es' and name = 'Timor Oriental'; +select 1 / count(*) from country_i18n where country_code = 'TM' and lang_tag = 'ca' and name = 'Turkmenistan'; +select 1 / count(*) from country_i18n where country_code = 'TM' and lang_tag = 'es' and name = 'Turkmenistán'; +select 1 / count(*) from country_i18n where country_code = 'TN' and lang_tag = 'ca' and name = 'Tunísia'; +select 1 / count(*) from country_i18n where country_code = 'TN' and lang_tag = 'es' and name = 'Túnez'; +select 1 / count(*) from country_i18n where country_code = 'TO' and lang_tag = 'ca' and name = 'Tonga'; +select 1 / count(*) from country_i18n where country_code = 'TO' and lang_tag = 'es' and name = 'Tonga'; +select 1 / count(*) from country_i18n where country_code = 'TR' and lang_tag = 'ca' and name = 'Turquia'; +select 1 / count(*) from country_i18n where country_code = 'TR' and lang_tag = 'es' and name = 'Turquía'; +select 1 / count(*) from country_i18n where country_code = 'TT' and lang_tag = 'ca' and name = 'Trinitat i Tobago'; +select 1 / count(*) from country_i18n where country_code = 'TT' and lang_tag = 'es' and name = 'Trinidad y Tobago'; +select 1 / count(*) from country_i18n where country_code = 'TV' and lang_tag = 'ca' and name = 'Tuvalu'; +select 1 / count(*) from country_i18n where country_code = 'TV' and lang_tag = 'es' and name = 'Tuvalu'; +select 1 / count(*) from country_i18n where country_code = 'TW' and lang_tag = 'ca' and name = 'Taiwan'; +select 1 / count(*) from country_i18n where country_code = 'TW' and lang_tag = 'es' and name = 'Taiwán'; +select 1 / count(*) from country_i18n where country_code = 'TZ' and lang_tag = 'ca' and name = 'Tanzània'; +select 1 / count(*) from country_i18n where country_code = 'TZ' and lang_tag = 'es' and name = 'Tanzania'; +select 1 / count(*) from country_i18n where country_code = 'UA' and lang_tag = 'ca' and name = 'Ucraïna'; +select 1 / count(*) from country_i18n where country_code = 'UA' and lang_tag = 'es' and name = 'Ucrania'; +select 1 / count(*) from country_i18n where country_code = 'UG' and lang_tag = 'ca' and name = 'Uganda'; +select 1 / count(*) from country_i18n where country_code = 'UG' and lang_tag = 'es' and name = 'Uganda'; +select 1 / count(*) from country_i18n where country_code = 'UM' and lang_tag = 'ca' and name = 'Illes d’Ultramar Menors dels Estats Units'; +select 1 / count(*) from country_i18n where country_code = 'UM' and lang_tag = 'es' and name = 'Islas de ultramar menores de Estados Unidos (EEUU)'; +select 1 / count(*) from country_i18n where country_code = 'US' and lang_tag = 'ca' and name = 'Estats Units (US)'; +select 1 / count(*) from country_i18n where country_code = 'US' and lang_tag = 'es' and name = 'Estados Unidos (EEUU)'; +select 1 / count(*) from country_i18n where country_code = 'UY' and lang_tag = 'ca' and name = 'Uruguai'; +select 1 / count(*) from country_i18n where country_code = 'UY' and lang_tag = 'es' and name = 'Uruguay'; +select 1 / count(*) from country_i18n where country_code = 'UZ' and lang_tag = 'ca' and name = 'Uzbekistan'; +select 1 / count(*) from country_i18n where country_code = 'UZ' and lang_tag = 'es' and name = 'Uzbekistán'; +select 1 / count(*) from country_i18n where country_code = 'VA' and lang_tag = 'ca' and name = 'Vaticà'; +select 1 / count(*) from country_i18n where country_code = 'VA' and lang_tag = 'es' and name = 'Ciudad del Vaticano'; +select 1 / count(*) from country_i18n where country_code = 'VC' and lang_tag = 'ca' and name = 'Saint Vincent i les Grenadines'; +select 1 / count(*) from country_i18n where country_code = 'VC' and lang_tag = 'es' and name = 'San Vicente y las Granadinas'; +select 1 / count(*) from country_i18n where country_code = 'VE' and lang_tag = 'ca' and name = 'Veneçuela'; +select 1 / count(*) from country_i18n where country_code = 'VE' and lang_tag = 'es' and name = 'Venezuela'; +select 1 / count(*) from country_i18n where country_code = 'VG' and lang_tag = 'ca' and name = 'Illes Verges (Britàniques)'; +select 1 / count(*) from country_i18n where country_code = 'VG' and lang_tag = 'es' and name = 'Islas Vírgenes (Británicas)'; +select 1 / count(*) from country_i18n where country_code = 'VI' and lang_tag = 'ca' and name = 'Illes Verges (EUA)'; +select 1 / count(*) from country_i18n where country_code = 'VI' and lang_tag = 'es' and name = 'Islas Vírgenes (EEUU)'; +select 1 / count(*) from country_i18n where country_code = 'VN' and lang_tag = 'ca' and name = 'Vietnam'; +select 1 / count(*) from country_i18n where country_code = 'VN' and lang_tag = 'es' and name = 'Vietnam'; +select 1 / count(*) from country_i18n where country_code = 'VU' and lang_tag = 'ca' and name = 'Vanuatu'; +select 1 / count(*) from country_i18n where country_code = 'VU' and lang_tag = 'es' and name = 'Vanuatu'; +select 1 / count(*) from country_i18n where country_code = 'WF' and lang_tag = 'ca' and name = 'Wallis i Futuna'; +select 1 / count(*) from country_i18n where country_code = 'WF' and lang_tag = 'es' and name = 'Wallis y Futuna'; +select 1 / count(*) from country_i18n where country_code = 'WS' and lang_tag = 'ca' and name = 'Samoa'; +select 1 / count(*) from country_i18n where country_code = 'WS' and lang_tag = 'es' and name = 'Samoa'; +select 1 / count(*) from country_i18n where country_code = 'YE' and lang_tag = 'ca' and name = 'Iemen'; +select 1 / count(*) from country_i18n where country_code = 'YE' and lang_tag = 'es' and name = 'Yemen'; +select 1 / count(*) from country_i18n where country_code = 'YT' and lang_tag = 'ca' and name = 'Mayotte'; +select 1 / count(*) from country_i18n where country_code = 'YT' and lang_tag = 'es' and name = 'Mayotte'; +select 1 / count(*) from country_i18n where country_code = 'ZA' and lang_tag = 'ca' and name = 'Sud-àfrica'; +select 1 / count(*) from country_i18n where country_code = 'ZA' and lang_tag = 'es' and name = 'Sudáfrica'; +select 1 / count(*) from country_i18n where country_code = 'ZM' and lang_tag = 'ca' and name = 'Zàmbia'; +select 1 / count(*) from country_i18n where country_code = 'ZM' and lang_tag = 'es' and name = 'Zambia'; +select 1 / count(*) from country_i18n where country_code = 'ZW' and lang_tag = 'ca' and name = 'Zimbàbue'; +select 1 / count(*) from country_i18n where country_code = 'ZW' and lang_tag = 'es' and name = 'Zimbabue'; + +rollback; diff --git a/verify/available_currencies.sql b/verify/available_currencies.sql new file mode 100644 index 0000000..f308500 --- /dev/null +++ b/verify/available_currencies.sql @@ -0,0 +1,21 @@ +-- Verify numerus:available_currencies on pg + +begin; + +set search_path to camper; + +select 1 / count(*) +from currency +where currency_code = 'EUR' + and currency_symbol = '€' + and decimal_digits = 2 +; + +select 1 / count(*) +from currency +where currency_code = 'USD' + and currency_symbol = '$' + and decimal_digits = 2 +; + +rollback; diff --git a/verify/company.sql b/verify/company.sql new file mode 100644 index 0000000..eb146be --- /dev/null +++ b/verify/company.sql @@ -0,0 +1,26 @@ +-- Verify camper:company on pg + +begin; + +select company_id + , slug + , business_name + , vatin + , trade_name + , phone + , email + , web + , address + , city + , province + , postal_code + , country_code + , currency_code + , default_lang_tag + , invoice_number_format + , legal_disclaimer + , created_at +from camper.company +where false; + +rollback; diff --git a/verify/company_user.sql b/verify/company_user.sql new file mode 100644 index 0000000..1b5a048 --- /dev/null +++ b/verify/company_user.sql @@ -0,0 +1,13 @@ +-- Verify camper:company_user on pg + +begin; + +select company_id + , user_id +from camper.company_user +where false; + +select 1 / count(*) from pg_class where oid = 'camper.company'::regclass and relrowsecurity; +select 1 / count(*) from pg_policy where polname = 'company_policy' and polrelid = 'camper.company'::regclass; + +rollback; diff --git a/verify/country.sql b/verify/country.sql new file mode 100644 index 0000000..3bb66c1 --- /dev/null +++ b/verify/country.sql @@ -0,0 +1,11 @@ +-- Verify camper:country on pg + +begin; + +select country_code + , name + , postal_code_regex +from camper.country +where false; + +rollback; diff --git a/verify/country_code.sql b/verify/country_code.sql new file mode 100644 index 0000000..88a8fba --- /dev/null +++ b/verify/country_code.sql @@ -0,0 +1,7 @@ +-- Verify camper:country_code on pg + +begin; + +select pg_catalog.has_type_privilege('camper.country_code', 'usage'); + +rollback; diff --git a/verify/country_i18n.sql b/verify/country_i18n.sql new file mode 100644 index 0000000..b059850 --- /dev/null +++ b/verify/country_i18n.sql @@ -0,0 +1,11 @@ +-- Verify camper:country_i18n on pg + +begin; + +select country_code + , lang_tag + , name +from camper.country_i18n +where false; + +rollback; diff --git a/verify/currency.sql b/verify/currency.sql new file mode 100644 index 0000000..6b89c9a --- /dev/null +++ b/verify/currency.sql @@ -0,0 +1,11 @@ +-- Verify camper:currency on pg + +begin; + +select currency_code + , currency_symbol + , decimal_digits +from camper.currency +where false; + +rollback; diff --git a/verify/currency_code.sql b/verify/currency_code.sql new file mode 100644 index 0000000..b3b86d0 --- /dev/null +++ b/verify/currency_code.sql @@ -0,0 +1,7 @@ +-- Verify camper:currency_code on pg + +begin; + +select pg_catalog.has_type_privilege('camper.currency_code', 'usage'); + +rollback; diff --git a/verify/extension_pg_libphonenumber.sql b/verify/extension_pg_libphonenumber.sql new file mode 100644 index 0000000..696162b --- /dev/null +++ b/verify/extension_pg_libphonenumber.sql @@ -0,0 +1,7 @@ +-- Verify camper:extension_pg_libphonenumber on pg + +begin; + +select 1/count(*) from pg_extension where extname = 'pg_libphonenumber'; + +rollback; diff --git a/verify/extension_uri.sql b/verify/extension_uri.sql new file mode 100644 index 0000000..10cd6af --- /dev/null +++ b/verify/extension_uri.sql @@ -0,0 +1,7 @@ +-- Verify camper:extension_uri on pg + +begin; + +select 1/count(*) from pg_extension where extname = 'uri'; + +rollback; diff --git a/verify/extension_vat.sql b/verify/extension_vat.sql new file mode 100644 index 0000000..dad7686 --- /dev/null +++ b/verify/extension_vat.sql @@ -0,0 +1,7 @@ +-- Verify camper:extension_vat on pg + +begin; + +select 1/count(*) from pg_extension where extname = 'vat'; + +rollback;