--access to backend database
DROP TABLE IF EXISTS erp_config;

-- user_user.sql
DROP TABLE IF EXISTS useruser_corefeature_rel;
DROP TABLE IF EXISTS user_confirm;
DROP TABLE IF EXISTS user_detail;
DROP TABLE IF EXISTS user_user;

-- core.sql
DROP TABLE IF EXISTS core_feature;
DROP TABLE IF EXISTS core_feature_translation;
DROP TABLE IF EXISTS core_config;
DROP TABLE IF EXISTS core_translation;
DROP TABLE IF EXISTS core_country;
DROP TABLE IF EXISTS core_lang;
DROP TABLE IF EXISTS core_currency;
DROP TABLE IF EXISTS core_theme;

CREATE TABLE core_theme (
	id SERIAL,
	create_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
	code VARCHAR(16) NOT NULL,
	name VARCHAR(128) NOT NULL,
	is_prod_available BOOLEAN NOT NULL DEFAULT FALSE,
  is_active BOOLEAN NOT NULL DEFAULT TRUE,
	CONSTRAINT coreTheme_id_pk PRIMARY KEY(id),
	CONSTRAINT coreTheme_code_uk UNIQUE(id)
);

CREATE TABLE core_currency (
  id SERIAL,
  create_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  code VARCHAR(16) NOT NULL,
  name VARCHAR(128) NOT NULL,
  symbol VARCHAR(16) NOT NULL,
  rounding DECIMAL(12,8) NOT NULL,
  priority INTEGER NOT NULL DEFAULT 100,
  decimal_precision INTEGER NOT NULL DEFAULT 2,
  is_active BOOLEAN NOT NULL DEFAULT TRUE,
  CONSTRAINT coreCurrency_id_pk PRIMARY KEY(id),
  CONSTRAINT coreCurrency_name_uk UNIQUE(name),
  CONSTRAINT coreCurrency_name_chk CHECK(name !='')
);

CREATE TABLE core_lang (
  id SERIAL,
  create_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  code VARCHAR(16) NOT NULL,
  name VARCHAR(128) NOT NULL,
  is_active BOOLEAN NOT NULL DEFAULT FALSE,
  comment TEXT NOT NULL DEFAULT '',
  CONSTRAINT coreLang_id_pk PRIMARY KEY(id),
  CONSTRAINT coreLang_name_uk UNIQUE(name)
);

CREATE TABLE core_country (
  id SERIAL,
  create_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  code VARCHAR(16) NOT NULL,
  name VARCHAR(128) NOT NULL,
  core_currency_id INTEGER,
  priority INTEGER NOT NULL DEFAULT 100,
  is_active BOOLEAN NOT NULL DEFAULT TRUE,
  CONSTRAINT coreCountry_id_pk PRIMARY KEY(id),
  CONSTRAINT coreCountry_code_uk UNIQUE(code),
  CONSTRAINT coreCountry_code_chk CHECK(code !=''),
  CONSTRAINT coreCountry_name_chk CHECK(name !=''),
  CONSTRAINT coreCountry_coreCurrencyId_fk FOREIGN KEY(core_currency_id) REFERENCES core_currency(id)
);

CREATE TABLE core_translation (
  id SERIAL,
  create_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  code VARCHAR(128) NOT NULL,
  source TEXT NOT NULL,
  ab_RU TEXT NOT NULL DEFAULT '',
  am_ET TEXT NOT NULL DEFAULT '',
  ar_SY TEXT NOT NULL DEFAULT '',
  bg_BG TEXT NOT NULL DEFAULT '',
  bs_BS TEXT NOT NULL DEFAULT '',
  ca_ES TEXT NOT NULL DEFAULT '',
  cs_CZ TEXT NOT NULL DEFAULT '',
  da_DK TEXT NOT NULL DEFAULT '',
  de_DE TEXT NOT NULL DEFAULT '',
  el_GR TEXT NOT NULL DEFAULT '',
  en_CA TEXT NOT NULL DEFAULT '',
  en_gb TEXT NOT NULL DEFAULT '',
  en_US TEXT NOT NULL DEFAULT '',
  es_AR TEXT NOT NULL DEFAULT '',
  es_BO TEXT NOT NULL DEFAULT '',
  es_CL TEXT NOT NULL DEFAULT '',
  es_CO TEXT NOT NULL DEFAULT '',
  es_CR TEXT NOT NULL DEFAULT '',
  es_DO TEXT NOT NULL DEFAULT '',
  es_EC TEXT NOT NULL DEFAULT '',
  es_ES TEXT NOT NULL DEFAULT '',
  es_GT TEXT NOT NULL DEFAULT '',
  es_HN TEXT NOT NULL DEFAULT '',
  es_MX TEXT NOT NULL DEFAULT '',
  es_NI TEXT NOT NULL DEFAULT '',
  es_PA TEXT NOT NULL DEFAULT '',
  es_PE TEXT NOT NULL DEFAULT '',
  es_PR TEXT NOT NULL DEFAULT '',
  es_PY TEXT NOT NULL DEFAULT '',
  es_SV TEXT NOT NULL DEFAULT '',
  es_UY TEXT NOT NULL DEFAULT '',
  es_VE TEXT NOT NULL DEFAULT '',
  et_EE TEXT NOT NULL DEFAULT '',
  fa_IR TEXT NOT NULL DEFAULT '',
  fi_FI TEXT NOT NULL DEFAULT '',
  fr_BE TEXT NOT NULL DEFAULT '',
  fr_CA TEXT NOT NULL DEFAULT '',
  fr_CH TEXT NOT NULL DEFAULT '',
  fr_fr TEXT NOT NULL DEFAULT '',
  gl_ES TEXT NOT NULL DEFAULT '',
  gu_IN TEXT NOT NULL DEFAULT '',
  he_IL TEXT NOT NULL DEFAULT '',
  hi_IN TEXT NOT NULL DEFAULT '',
  hr_HR TEXT NOT NULL DEFAULT '',
  hu_HU TEXT NOT NULL DEFAULT '',
  id_ID TEXT NOT NULL DEFAULT '',
  it_IT TEXT NOT NULL DEFAULT '',
  iu_CA TEXT NOT NULL DEFAULT '',
  ja_JP TEXT NOT NULL DEFAULT '',
  ko_KP TEXT NOT NULL DEFAULT '',
  ko_KR TEXT NOT NULL DEFAULT '',
  lt_LT TEXT NOT NULL DEFAULT '',
  lv_LV TEXT NOT NULL DEFAULT '',
  ml_IN TEXT NOT NULL DEFAULT '',
  mn_MN TEXT NOT NULL DEFAULT '',
  nb_NO TEXT NOT NULL DEFAULT '',
  nl_NL TEXT NOT NULL DEFAULT '',
  nl_BE TEXT NOT NULL DEFAULT '',
  oc_FR TEXT NOT NULL DEFAULT '',
  pl_PL TEXT NOT NULL DEFAULT '',
  pt_BR TEXT NOT NULL DEFAULT '',
  pt_PT TEXT NOT NULL DEFAULT '',
  ro_RO TEXT NOT NULL DEFAULT '',
  ru_RU TEXT NOT NULL DEFAULT '',
  si_LK TEXT NOT NULL DEFAULT '',
  sl_SI TEXT NOT NULL DEFAULT '',
  sk_SK TEXT NOT NULL DEFAULT '',
  sq_AL TEXT NOT NULL DEFAULT '',
  sr_RS TEXT NOT NULL DEFAULT '',
  sr_latin TEXT NOT NULL DEFAULT '',
  sv_SE TEXT NOT NULL DEFAULT '',
  te_IN TEXT NOT NULL DEFAULT '',
  tr_TR TEXT NOT NULL DEFAULT '',
  vi_VN TEXT NOT NULL DEFAULT '',
  uk_UA TEXT NOT NULL DEFAULT '',
  ur_PK TEXT NOT NULL DEFAULT '',
  zh_CN TEXT NOT NULL DEFAULT '',
  zh_HK TEXT NOT NULL DEFAULT '',
  zh_TW TEXT NOT NULL DEFAULT '',
  th_TH TEXT NOT NULL DEFAULT '',
  tlh_TLH TEXT NOT NULL DEFAULT '',
  is_active BOOLEAN NOT NULL DEFAULT TRUE,
  comment TEXT NOT NULL DEFAULT '',
  CONSTRAINT coreTranslation_id_pk PRIMARY KEY(id),
  CONSTRAINT coreTranslation_code_uk UNIQUE(code)
);

CREATE TABLE core_config (
  id SERIAL,
  create_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  k VARCHAR(128) NOT NULL,
  v VARCHAR(128) NOT NULL,
  is_active BOOLEAN NOT NULL DEFAULT TRUE,
  comment TEXT NOT NULL DEFAULT '',
  CONSTRAINT coreConfig_id_pk PRIMARY KEY(id),
  CONSTRAINT coreConfig_k_uk UNIQUE(k)
);


--FIX bug core_feature with core_translation for menu and using models and views
CREATE TABLE core_feature_translation (
  id SERIAL,
  create_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  code VARCHAR(128) NOT NULL,
  source TEXT NOT NULL,
  ab_RU TEXT NOT NULL DEFAULT '',
  am_ET TEXT NOT NULL DEFAULT '',
  ar_SY TEXT NOT NULL DEFAULT '',
  bg_BG TEXT NOT NULL DEFAULT '',
  bs_BS TEXT NOT NULL DEFAULT '',
  ca_ES TEXT NOT NULL DEFAULT '',
  cs_CZ TEXT NOT NULL DEFAULT '',
  da_DK TEXT NOT NULL DEFAULT '',
  de_DE TEXT NOT NULL DEFAULT '',
  el_GR TEXT NOT NULL DEFAULT '',
  en_CA TEXT NOT NULL DEFAULT '',
  en_gb TEXT NOT NULL DEFAULT '',
  en_US TEXT NOT NULL DEFAULT '',
  es_AR TEXT NOT NULL DEFAULT '',
  es_BO TEXT NOT NULL DEFAULT '',
  es_CL TEXT NOT NULL DEFAULT '',
  es_CO TEXT NOT NULL DEFAULT '',
  es_CR TEXT NOT NULL DEFAULT '',
  es_DO TEXT NOT NULL DEFAULT '',
  es_EC TEXT NOT NULL DEFAULT '',
  es_ES TEXT NOT NULL DEFAULT '',
  es_GT TEXT NOT NULL DEFAULT '',
  es_HN TEXT NOT NULL DEFAULT '',
  es_MX TEXT NOT NULL DEFAULT '',
  es_NI TEXT NOT NULL DEFAULT '',
  es_PA TEXT NOT NULL DEFAULT '',
  es_PE TEXT NOT NULL DEFAULT '',
  es_PR TEXT NOT NULL DEFAULT '',
  es_PY TEXT NOT NULL DEFAULT '',
  es_SV TEXT NOT NULL DEFAULT '',
  es_UY TEXT NOT NULL DEFAULT '',
  es_VE TEXT NOT NULL DEFAULT '',
  et_EE TEXT NOT NULL DEFAULT '',
  fa_IR TEXT NOT NULL DEFAULT '',
  fi_FI TEXT NOT NULL DEFAULT '',
  fr_BE TEXT NOT NULL DEFAULT '',
  fr_CA TEXT NOT NULL DEFAULT '',
  fr_CH TEXT NOT NULL DEFAULT '',
  fr_fr TEXT NOT NULL DEFAULT '',
  gl_ES TEXT NOT NULL DEFAULT '',
  gu_IN TEXT NOT NULL DEFAULT '',
  he_IL TEXT NOT NULL DEFAULT '',
  hi_IN TEXT NOT NULL DEFAULT '',
  hr_HR TEXT NOT NULL DEFAULT '',
  hu_HU TEXT NOT NULL DEFAULT '',
  id_ID TEXT NOT NULL DEFAULT '',
  it_IT TEXT NOT NULL DEFAULT '',
  iu_CA TEXT NOT NULL DEFAULT '',
  ja_JP TEXT NOT NULL DEFAULT '',
  ko_KP TEXT NOT NULL DEFAULT '',
  ko_KR TEXT NOT NULL DEFAULT '',
  lt_LT TEXT NOT NULL DEFAULT '',
  lv_LV TEXT NOT NULL DEFAULT '',
  ml_IN TEXT NOT NULL DEFAULT '',
  mn_MN TEXT NOT NULL DEFAULT '',
  nb_NO TEXT NOT NULL DEFAULT '',
  nl_NL TEXT NOT NULL DEFAULT '',
  nl_BE TEXT NOT NULL DEFAULT '',
  oc_FR TEXT NOT NULL DEFAULT '',
  pl_PL TEXT NOT NULL DEFAULT '',
  pt_BR TEXT NOT NULL DEFAULT '',
  pt_PT TEXT NOT NULL DEFAULT '',
  ro_RO TEXT NOT NULL DEFAULT '',
  ru_RU TEXT NOT NULL DEFAULT '',
  si_LK TEXT NOT NULL DEFAULT '',
  sl_SI TEXT NOT NULL DEFAULT '',
  sk_SK TEXT NOT NULL DEFAULT '',
  sq_AL TEXT NOT NULL DEFAULT '',
  sr_RS TEXT NOT NULL DEFAULT '',
  sr_latin TEXT NOT NULL DEFAULT '',
  sv_SE TEXT NOT NULL DEFAULT '',
  te_IN TEXT NOT NULL DEFAULT '',
  tr_TR TEXT NOT NULL DEFAULT '',
  vi_VN TEXT NOT NULL DEFAULT '',
  uk_UA TEXT NOT NULL DEFAULT '',
  ur_PK TEXT NOT NULL DEFAULT '',
  zh_CN TEXT NOT NULL DEFAULT '',
  zh_HK TEXT NOT NULL DEFAULT '',
  zh_TW TEXT NOT NULL DEFAULT '',
  th_TH TEXT NOT NULL DEFAULT '',
  tlh_TLH TEXT NOT NULL DEFAULT '',
  is_active BOOLEAN NOT NULL DEFAULT TRUE,
  comment TEXT NOT NULL DEFAULT '',
  CONSTRAINT coreFeatureTranslation_id_pk PRIMARY KEY(id),
  CONSTRAINT coreFeatureTranslation_code_uk UNIQUE(code)
);

CREATE TABLE core_feature (
  id SERIAL,
  create_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  is_parent boolean NOT NULL DEFAULT FALSE,
  parent_id INTEGER,
  model VARCHAR(250) NOT NULL,
  code VARCHAR(64) NOT NULL,
  url_feature_translation_id INTEGER,
  label_feature_translation_id INTEGER,
  menu_icon VARCHAR(128),
  is_menu_display BOOLEAN NOT NULL DEFAULT FALSE,
  is_available_for_guest BOOLEAN NOT NULL DEFAULT FALSE,
  is_active BOOLEAN NOT NULL DEFAULT TRUE,
  priority INTEGER NOT NULL DEFAULT 100,
  CONSTRAINT coreFeatures_id_pk PRIMARY KEY(id),
  CONSTRAINT coreFeatures_parentId_fk FOREIGN KEY(parent_id) REFERENCES core_feature(id),
  CONSTRAINT coreFeature_urlFeatureTranslationId_fk FOREIGN KEY(url_feature_translation_id) REFERENCES core_feature_translation(id),
  CONSTRAINT coreFeature_labelFeatureTranslationId_fk FOREIGN KEY(label_feature_translation_id) REFERENCES core_feature_translation(id),
  CONSTRAINT coreFeatures_code_uk UNIQUE(code)
);

/* OFFICIAL DATA */
INSERT INTO core_theme(code, name, is_prod_available) VALUES('materialize', 'Materialize', TRUE);

INSERT INTO core_currency(code, name, symbol, rounding, priority) VALUES ('usd', 'USD', '$', '0.01', 3);
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('vef', 'VEF', 'Bs.F', '0.0001');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('cad', 'CAD', '$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding, priority) VALUES ('chf', 'CHF', 'CHF', '0.01', 1);
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('brl', 'BRL', 'R$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('cny', 'CNY', '¥', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('cop', 'COP', '$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('czk', 'CZK', 'Kč', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('dkk', 'DKK', 'kr', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('huf', 'HUF', 'Ft', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('idr', 'IDR', 'Rp', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('lvl', 'LVL', 'Ls', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('nok', 'NOK', 'kr', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('xpf', 'XPF', 'XPF', '1.00');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('pab', 'PAB', 'B/.', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('pln', 'PLN', 'zł', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('sek', 'SEK', 'kr', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('ars', 'ARS', '$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('inr', 'INR', '₹', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('aud', 'AUD', '$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('uah', 'UAH', '₴', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('vnd', 'VND', '₫', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('hkd', 'HKD', '$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('jpy', 'JPY', '¥', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('bgn', 'BGN', 'лв', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('ltl', 'LTL', 'Lt', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('ron', 'RON', 'lei', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('hrk', 'HRK', 'kn', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('rub', 'RUB', 'руб', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('try', 'TRY', 'TL', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('krw', 'KRW', '₩', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('mxn', 'MXN', '$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('myr', 'MYR', 'RM', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('nzd', 'NZD', '$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('php', 'PHP', 'Php', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('sgd', 'SGD', '$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('zar', 'ZAR', 'R', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('crc', 'CRC', '¢', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('mur', 'MUR', 'Rs', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('xof', 'XOF', 'CFA', '1');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('xaf', 'XAF', 'FCFA', '1');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('ugx', 'UGX', 'USh', '1');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('hnl', 'HNL', 'L', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('clp', 'CLP', '$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('uyu', 'UYU', '$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('afn', 'AFN', 'Afs', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('aoa', 'AOA', 'Kz', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('xcd', 'XCD', '$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('amd', 'AMD', 'դր..', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('awg', 'AWG', 'Afl.', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('azn', 'AZN', 'm', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('bsd', 'BSD', 'B$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('bhd', 'BHD', 'BD', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('bdt', 'BDT', '৳', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('bbd', 'BBD', 'Bds$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('byr', 'BYR', 'BR', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('bzd', 'BZD', 'BZ$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('bmd', 'BMD', 'BD$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('btn', 'BTN', 'Nu.', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('bob', 'BOB', 'Bs.', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('bam', 'BAM', 'KM', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('bwp', 'BWP', 'P', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('bif', 'BIF', 'FBu', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('khr', 'KHR', '៛', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('kyd', 'KYD', '$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('kmf', 'KMF', 'CF', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('cdf', 'CDF', 'Fr', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('cup', 'CUP', '$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('ang', 'ANG', 'ƒ', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('cyp', 'CYP', '£', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('djf', 'DJF', 'Fdj', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('dop', 'DOP', 'RD$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('tpe', 'TPE', 'RD$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('ecs', 'ECS', 'S/.', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('egp', 'EGP', 'E£', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('svc', 'SVC', '¢', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('ern', 'ERN', 'Nfk', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('eek', 'EEK', 'kr', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('etb', 'ETB', 'Br', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('fkp', 'FKP', '£', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('fjd', 'FJD', 'FJ$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('gel', 'GEL', 'ლ', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('gip', 'GIP', '£', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('qtq', 'QTQ', 'Q', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('gnf', 'GNF', 'FG', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('gwp', 'GWP', 'FG', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('gyd', 'GYD', '$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('htg', 'HTG', 'G', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('isk', 'ISK', 'kr', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('irr', 'IRR', '﷼', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('iqd', 'IQD', 'ع.د', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('ils', 'ILS', '₪', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('jmd', 'JMD', '$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('jod', 'JOD', ' د.ا ', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('kzt', 'KZT', 'лв', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('kes', 'KES', 'KSh', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('kwd', 'KWD', ' د.ك ', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('kgs', 'KGS', 'лв', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('lak', 'LAK', '₭', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('lbp', 'LBP', 'ل.ل', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('lsl', 'LSL', 'L', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('lrd', 'LRD', 'L$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('lyd', 'LYD', ' ل.د ', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('mop', 'MOP', 'MOP$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('mkd', 'MKD', 'ден', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('mga', 'MGA', 'Ar', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('mwk', 'MWK', 'MK', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('mvr', 'MVR', '.ރ', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('mro', 'MRO', 'UM', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('mdl', 'MDL', 'L', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('mnt', 'MNT', '₮', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('mad', 'MAD', ' د.م. ', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('bnd', 'BND', '$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('dzd', 'DZD', 'DZ', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('ghs', 'GHS', 'GHÂ¢', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('gmd', 'GMD', 'D', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('zrz', 'ZRZ', 'Ƶ', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('mzn', 'MZN', 'MT', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('mmk', 'MMK', 'K', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('nad', 'NAD', '$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('npr', 'NPR', '₨', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('all', 'ALL', 'L', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('nio', 'NIO', 'C$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('ngn', 'NGN', '₦', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('kpw', 'KPW', '₩', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('zwd', 'ZWD', 'Z$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('zmk', 'ZMK', 'ZK', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('yer', 'YER', '﷼', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('vub', 'VUB', 'Bs', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding, priority) VALUES ('eur', 'EUR', '€', '0.01', 2);
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('vuv', 'VUV', 'VT', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('uzs', 'UZS', 'лв', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('uyp', 'UYP', '$U', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('aed', 'AED', 'د.إ', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('uag', 'UAG', '₴', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('tmm', 'TMM', 'm', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('trl', 'TRL', 'TL', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('tnd', 'TND', 'DT', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('ttd', 'TTD', '$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('top', 'TOP', 'T$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('thb', 'THB', '฿', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('tzs', 'TZS', 'x/y', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('tjr', 'TJR', 'x/y', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('twd', 'TWD', 'NT$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('syp', 'SYP', '£', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('szl', 'SZL', 'E', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('srg', 'SRG', '$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('sdd', 'SDD', '£Sd', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('lkr', 'LKR', 'Rs', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('ssp', 'SSP', '£', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('gbp', 'GBP', '£', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('sod', 'SOD', 'Sh.', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('sbd', 'SBD', 'SI$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('sll', 'SLL', 'Le', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('scr', 'SCR', 'SR', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('rsd', 'RSD', 'din.', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('sar', 'SAR', 'SR', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('std', 'STD', 'Db', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('itl', 'ITL', '₤', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('wst', 'WST', 'WS$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('shp', 'SHP', '£', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('rwf', 'RWF', 'RF', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('rur', 'RUR', 'R', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('rol', 'ROL', 'L', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('qar', 'QAR', 'QR', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('plz', 'PLZ', 'zł', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('pen', 'PEN', 'S/.', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('pyg', 'PYG', '₲', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('pgk', 'PGK', 'K', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('pkr', 'PKR', 'Rs.', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('omr', 'OMR', 'ر.ع.', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('cve', 'CVE', '$', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('skk', 'SKK', 'Sk', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('sit', 'SIT', 'Sk', '0.01');
INSERT INTO core_currency(code, name, symbol, rounding) VALUES ('yum', 'YUM', 'дин.', '0.01');
UPDATE core_currency SET decimal_precision=4 WHERE rounding=0.0001;
UPDATE core_currency SET decimal_precision=0 WHERE rounding=1.0;


INSERT INTO core_lang(code, name) VALUES ('ab_ru', 'Abkhazian / аҧсуа');
INSERT INTO core_lang(code, name) VALUES ('am_et', 'Amharic / አምሃርኛ');
INSERT INTO core_lang(code, name) VALUES ('ar_sy', 'Arabic / الْعَرَبيّة');
INSERT INTO core_lang(code, name) VALUES ('bg_bg', 'Bulgarian / български език');
INSERT INTO core_lang(code, name) VALUES ('bs_bs', 'Bosnian / bosanski jezik');
INSERT INTO core_lang(code, name) VALUES ('ca_es', 'Catalan / Català');
INSERT INTO core_lang(code, name) VALUES ('cs_cz', 'Czech / Čeština');
INSERT INTO core_lang(code, name) VALUES ('da_dk', 'Danish / Dansk');
INSERT INTO core_lang(code, name) VALUES ('de_de', 'German / Deutsch');
INSERT INTO core_lang(code, name) VALUES ('el_gr', 'Greek / Ελληνικά');
INSERT INTO core_lang(code, name) VALUES ('en_ca', 'English (CA)');
INSERT INTO core_lang(code, name, is_active) VALUES ('en_gb', 'English (UK)', TRUE);
INSERT INTO core_lang(code, name) VALUES ('en_us', 'English (US)');
INSERT INTO core_lang(code, name) VALUES ('es_ar', 'Spanish (AR) / Español (AR)');
INSERT INTO core_lang(code, name) VALUES ('es_bo', 'Spanish (BO) / Español (BO)');
INSERT INTO core_lang(code, name) VALUES ('es_cl', 'Spanish (CL) / Español (CL)');
INSERT INTO core_lang(code, name) VALUES ('es_co', 'Spanish (CO) / Español (CO)');
INSERT INTO core_lang(code, name) VALUES ('es_cr', 'Spanish (CR) / Español (CR)');
INSERT INTO core_lang(code, name) VALUES ('es_do', 'Spanish (DO) / Español (DO)');
INSERT INTO core_lang(code, name) VALUES ('es_ec', 'Spanish (EC) / Español (EC)');
INSERT INTO core_lang(code, name) VALUES ('es_es', 'Español');
INSERT INTO core_lang(code, name) VALUES ('es_gt', 'Spanish (GT) / Español (GT)');
INSERT INTO core_lang(code, name) VALUES ('es_hn', 'Spanish (HN) / Español (HN)');
INSERT INTO core_lang(code, name) VALUES ('es_mx', 'Spanish (MX) / Español (MX)');
INSERT INTO core_lang(code, name) VALUES ('es_ni', 'Spanish (NI) / Español (NI)');
INSERT INTO core_lang(code, name) VALUES ('es_pa', 'Spanish (PA) / Español (PA)');
INSERT INTO core_lang(code, name) VALUES ('es_pe', 'Spanish (PE) / Español (PE)');
INSERT INTO core_lang(code, name) VALUES ('es_pr', 'Spanish (PR) / Español (PR)');
INSERT INTO core_lang(code, name) VALUES ('es_py', 'Spanish (PY) / Español (PY)');
INSERT INTO core_lang(code, name) VALUES ('es_sv', 'Spanish (SV) / Español (SV)');
INSERT INTO core_lang(code, name) VALUES ('es_uy', 'Spanish (UY) / Español (UY)');
INSERT INTO core_lang(code, name) VALUES ('es_ve', 'Spanish (VE) / Español (VE)');
INSERT INTO core_lang(code, name) VALUES ('et_ee', 'Estonian / Eesti keel');
INSERT INTO core_lang(code, name) VALUES ('fa_ir', 'Persian / افارس');
INSERT INTO core_lang(code, name) VALUES ('fi_fi', 'Finnish / Suomi');
INSERT INTO core_lang(code, name) VALUES ('fr_be', 'French (BE) / Français (BE)');
INSERT INTO core_lang(code, name) VALUES ('fr_ca', 'French (CA) / Français (CA)');
INSERT INTO core_lang(code, name) VALUES ('fr_ch', 'French (CH) / Français (CH)');
INSERT INTO core_lang(code, name, is_active) VALUES ('fr_fr', 'Français', TRUE);
INSERT INTO core_lang(code, name) VALUES ('gl_es', 'Galician / Galego');
INSERT INTO core_lang(code, name) VALUES ('gu_in', 'Gujarati / ગુજરાતી');
INSERT INTO core_lang(code, name) VALUES ('he_il', 'Hebrew / עִבְרִי');
INSERT INTO core_lang(code, name) VALUES ('hi_in', 'Hindi / हिंदी');
INSERT INTO core_lang(code, name) VALUES ('hr_hr', 'Croatian / hrvatski jezik');
INSERT INTO core_lang(code, name) VALUES ('hu_hu', 'Hungarian / Magyar');
INSERT INTO core_lang(code, name) VALUES ('id_id', 'Indonesian / Bahasa Indonesia');
INSERT INTO core_lang(code, name) VALUES ('it_it', 'Italian / Italiano');
INSERT INTO core_lang(code, name) VALUES ('iu_ca', 'Inuktitut / ᐃᓄᒃᑎᑐᑦ');
INSERT INTO core_lang(code, name) VALUES ('ja_jp', 'Japanese / 日本語');
INSERT INTO core_lang(code, name) VALUES ('ko_kp', 'Korean (KP) / 한국어 (KP)');
INSERT INTO core_lang(code, name) VALUES ('ko_kr', '한국어 (KR)');
INSERT INTO core_lang(code, name) VALUES ('lt_lt', 'Lithuanian / Lietuvių kalba');
INSERT INTO core_lang(code, name) VALUES ('lv_lv', 'Latvian / latviešu valoda');
INSERT INTO core_lang(code, name) VALUES ('ml_in', 'Malayalam / മലയാളം');
INSERT INTO core_lang(code, name) VALUES ('mn_mn', 'Mongolian / монгол');
INSERT INTO core_lang(code, name) VALUES ('nb_no', 'Norwegian Bokmål / Norsk bokmål');
INSERT INTO core_lang(code, name) VALUES ('nl_nl', 'Dutch / Nederlands');
INSERT INTO core_lang(code, name) VALUES ('nl_be', 'Flemish (BE) / Vlaams (BE)');
INSERT INTO core_lang(code, name) VALUES ('oc_fr', 'Occitan (FR, post 1500) / Occitan');
INSERT INTO core_lang(code, name) VALUES ('pl_pl', 'Polish / Język polski');
INSERT INTO core_lang(code, name) VALUES ('pt_br', 'Portuguese (BR) / Português (BR)');
INSERT INTO core_lang(code, name) VALUES ('pt_pt', 'Portuguese / Português');
INSERT INTO core_lang(code, name) VALUES ('ro_ro', 'Romanian / română');
INSERT INTO core_lang(code, name) VALUES ('ru_ru', 'Russian / русский язык');
INSERT INTO core_lang(code, name) VALUES ('si_lk', 'Sinhalese / සිංහල');
INSERT INTO core_lang(code, name) VALUES ('sl_si', 'Slovenian / slovenščina');
INSERT INTO core_lang(code, name) VALUES ('sk_sk', 'Slovak / Slovenský jazyk');
INSERT INTO core_lang(code, name) VALUES ('sq_al', 'Albanian / Shqip');
INSERT INTO core_lang(code, name) VALUES ('sr_rs', 'Serbian (Cyrillic) / српски');
INSERT INTO core_lang(code, name) VALUES ('sr_latin', 'Serbian (Latin) / srpski');
INSERT INTO core_lang(code, name) VALUES ('sv_se', 'Swedish / svenska');
INSERT INTO core_lang(code, name) VALUES ('te_in', 'Telugu / తెలుగు');
INSERT INTO core_lang(code, name) VALUES ('tr_tr', 'Turkish / Türkçe');
INSERT INTO core_lang(code, name) VALUES ('vi_vn', 'Vietnamese / Tiếng Việt');
INSERT INTO core_lang(code, name) VALUES ('uk_ua', 'Ukrainian / українська');
INSERT INTO core_lang(code, name) VALUES ('ur_pk', 'Urdu / اردو');
INSERT INTO core_lang(code, name) VALUES ('zh_cn', 'Chinese (CN) / 简体中文');
INSERT INTO core_lang(code, name) VALUES ('zh_hk', 'Chinese (HK)');
INSERT INTO core_lang(code, name) VALUES ('zh_tw', 'Chinese (TW) / 正體字');
INSERT INTO core_lang(code, name) VALUES ('th_th', 'Thai / ภาษาไทย');
INSERT INTO core_lang(code, name) VALUES ('tlh_tlh', 'Klingon');

INSERT INTO core_country(code, name, core_currency_id) VALUES ('ad', 'Andorra, Principality of', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ae', 'United Arab Emirates', (SELECT id FROM core_currency WHERE code='aed' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('af', 'Afghanistan, Islamic State of', (SELECT id FROM core_currency WHERE code='afn' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ag', 'Antigua and Barbuda', (SELECT id FROM core_currency WHERE code='xcd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ai', 'Anguilla', (SELECT id FROM core_currency WHERE code='xcd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('al', 'Albania', (SELECT id FROM core_currency WHERE code='all' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('am', 'Armenia', (SELECT id FROM core_currency WHERE code='amd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('an', 'Netherlands Antilles', (SELECT id FROM core_currency WHERE code='nok' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ao', 'Angola', (SELECT id FROM core_currency WHERE code='aoa' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('aq', 'Antarctica', (SELECT id FROM core_currency WHERE code='xcd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ar', 'Argentina', (SELECT id FROM core_currency WHERE code='ars' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('as', 'American Samoa', (SELECT id FROM core_currency WHERE code='usd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('at', 'Austria', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('au', 'Australia', (SELECT id FROM core_currency WHERE code='aud' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('aw', 'Aruba', (SELECT id FROM core_currency WHERE code='awg' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ax', 'Åland Islands', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('az', 'Azerbaijan', (SELECT id FROM core_currency WHERE code='azn' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ba', 'Bosnia-Herzegovina', (SELECT id FROM core_currency WHERE code='bam' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('bb', 'Barbados', (SELECT id FROM core_currency WHERE code='bbd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('bd', 'Bangladesh', (SELECT id FROM core_currency WHERE code='bdt' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('be', 'Belgium', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('bf', 'Burkina Faso', (SELECT id FROM core_currency WHERE code='xof' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('bg', 'Bulgaria', (SELECT id FROM core_currency WHERE code='bgn' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('bh', 'Bahrain', (SELECT id FROM core_currency WHERE code='bhd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('bi', 'Burundi', (SELECT id FROM core_currency WHERE code='bif' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('bj', 'Benin', (SELECT id FROM core_currency WHERE code='xof' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('bl', 'Saint Barthélémy', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('bm', 'Bermuda', (SELECT id FROM core_currency WHERE code='bmd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('bn', 'Brunei Darussalam', (SELECT id FROM core_currency WHERE code='bnd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('bo', 'Bolivia', (SELECT id FROM core_currency WHERE code='bob' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('bq', 'Bonaire, Sint Eustatius and Saba', (SELECT id FROM core_currency WHERE code='usd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('br', 'Brazil', (SELECT id FROM core_currency WHERE code='brl' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('bs', 'Bahamas', (SELECT id FROM core_currency WHERE code='bsd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('bt', 'Bhutan', (SELECT id FROM core_currency WHERE code='btn' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('bv', 'Bouvet Island', (SELECT id FROM core_currency WHERE code='nok' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('bw', 'Botswana', (SELECT id FROM core_currency WHERE code='bwp' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('by', 'Belarus', (SELECT id FROM core_currency WHERE code='byr' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('bz', 'Belize', (SELECT id FROM core_currency WHERE code='bzd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ca', 'Canada', (SELECT id FROM core_currency WHERE code='cad' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('cc', 'Cocos (Keeling) Islands', (SELECT id FROM core_currency WHERE code='aud' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('cf', 'Central African Republic', (SELECT id FROM core_currency WHERE code='xaf' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('cd', 'Congo, Democratic Republic of the', (SELECT id FROM core_currency WHERE code='cdf' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('cg', 'Congo', (SELECT id FROM core_currency WHERE code='xaf' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id, priority) VALUES ('ch', 'Switzerland', (SELECT id FROM core_currency WHERE code='chf' LIMIT 1), 1);
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ci', 'Ivory Coast (Cote D''Ivoire)', (SELECT id FROM core_currency WHERE code='xof' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ck', 'Cook Islands', (SELECT id FROM core_currency WHERE code='nzd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('cl', 'Chile', (SELECT id FROM core_currency WHERE code='aud' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('cm', 'Cameroon', (SELECT id FROM core_currency WHERE code='xaf' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('cn', 'China', (SELECT id FROM core_currency WHERE code='cny' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('co', 'Colombia', (SELECT id FROM core_currency WHERE code='cop' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('cr', 'Costa Rica', (SELECT id FROM core_currency WHERE code='crc' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('cu', 'Cuba', (SELECT id FROM core_currency WHERE code='cup' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('cv', 'Cape Verde', (SELECT id FROM core_currency WHERE code='cve' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('cw', 'Curaçao', (SELECT id FROM core_currency WHERE code='ang' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('cx', 'Christmas Island', (SELECT id FROM core_currency WHERE code='aud' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('cy', 'Cyprus', (SELECT id FROM core_currency WHERE code='cyp' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('cz', 'Czech Republic', (SELECT id FROM core_currency WHERE code='czk' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id, priority) VALUES ('de', 'Germany', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1), 3);
INSERT INTO core_country(code, name, core_currency_id) VALUES ('dj', 'Djibouti', (SELECT id FROM core_currency WHERE code='djf' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('dk', 'Denmark', (SELECT id FROM core_currency WHERE code='dkk' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('dm', 'Dominica', (SELECT id FROM core_currency WHERE code='xcd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('do', 'Dominican Republic', (SELECT id FROM core_currency WHERE code='dop' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('dz', 'Algeria', (SELECT id FROM core_currency WHERE code='dzd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ec', 'Ecuador', (SELECT id FROM core_currency WHERE code='ecs' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ee', 'Estonia', (SELECT id FROM core_currency WHERE code='eek' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('eg', 'Egypt', (SELECT id FROM core_currency WHERE code='egp' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('eh', 'Western Sahara', (SELECT id FROM core_currency WHERE code='mad' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('er', 'Eritrea', (SELECT id FROM core_currency WHERE code='ern' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('es', 'Spain', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('et', 'Ethiopia', (SELECT id FROM core_currency WHERE code='etb' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('fi', 'Finland', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('fj', 'Fiji', (SELECT id FROM core_currency WHERE code='fjd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('fk', 'Falkland Islands', (SELECT id FROM core_currency WHERE code='fkp' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('fm', 'Micronesia', (SELECT id FROM core_currency WHERE code='usd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('fo', 'Faroe Islands', (SELECT id FROM core_currency WHERE code='dkk' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id, priority) VALUES ('fr', 'France', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1), 2);
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ga', 'Gabon', (SELECT id FROM core_currency WHERE code='xaf' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('gd', 'Grenada', (SELECT id FROM core_currency WHERE code='xcd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ge', 'Georgia', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('gf', 'French Guyana', (SELECT id FROM core_currency WHERE code='gel' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('gh', 'Ghana', (SELECT id FROM core_currency WHERE code='ghs' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('gi', 'Gibraltar', (SELECT id FROM core_currency WHERE code='gip' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('gg', 'Guernsey', (SELECT id FROM core_currency WHERE code='gbp' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('gl', 'Greenland', (SELECT id FROM core_currency WHERE code='dkk' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('gm', 'Gambia', (SELECT id FROM core_currency WHERE code='gmd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('gn', 'Guinea', (SELECT id FROM core_currency WHERE code='gnf' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('gp', 'Guadeloupe (French)', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('gq', 'Equatorial Guinea', (SELECT id FROM core_currency WHERE code='xaf' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('gr', 'Greece', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('gs', 'South Georgia and the South Sandwich Islands', (SELECT id FROM core_currency WHERE code='gbp' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('gt', 'Guatemala', (SELECT id FROM core_currency WHERE code='qtq' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('gu', 'Guam (USA)', (SELECT id FROM core_currency WHERE code='usd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('gw', 'Guinea Bissau', (SELECT id FROM core_currency WHERE code='gwp' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('gy', 'Guyana', (SELECT id FROM core_currency WHERE code='gyd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('hk', 'Hong Kong', (SELECT id FROM core_currency WHERE code='hkd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('hm', 'Heard and McDonald Islands', (SELECT id FROM core_currency WHERE code='aud' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('hn', 'Honduras', (SELECT id FROM core_currency WHERE code='hnl' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('hr', 'Croatia', (SELECT id FROM core_currency WHERE code='hrk' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ht', 'Haiti', (SELECT id FROM core_currency WHERE code='htg' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('hu', 'Hungary', (SELECT id FROM core_currency WHERE code='huf' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('id', 'Indonesia', (SELECT id FROM core_currency WHERE code='idr' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ie', 'Ireland', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('il', 'Israel', (SELECT id FROM core_currency WHERE code='ils' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('im', 'Isle of Man', (SELECT id FROM core_currency WHERE code='gbp' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('in', 'India', (SELECT id FROM core_currency WHERE code='inr' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('io', 'British Indian Ocean Territory', (SELECT id FROM core_currency WHERE code='usd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('iq', 'Iraq', (SELECT id FROM core_currency WHERE code='iqd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ir', 'Iran', (SELECT id FROM core_currency WHERE code='irr' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('is', 'Iceland', (SELECT id FROM core_currency WHERE code='isk' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('it', 'Italy', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('je', 'Jersey', (SELECT id FROM core_currency WHERE code='gbp' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('jm', 'Jamaica', (SELECT id FROM core_currency WHERE code='jmd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('jo', 'Jordan', (SELECT id FROM core_currency WHERE code='jod' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('jp', 'Japan', (SELECT id FROM core_currency WHERE code='jpy' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ke', 'Kenya', (SELECT id FROM core_currency WHERE code='kes' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('kg', 'Kyrgyz Republic (Kyrgyzstan)', (SELECT id FROM core_currency WHERE code='kgs' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('kh', 'Cambodia, Kingdom of', (SELECT id FROM core_currency WHERE code='khr' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ki', 'Kiribati', (SELECT id FROM core_currency WHERE code='aud' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('km', 'Comoros', (SELECT id FROM core_currency WHERE code='kmf' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('kn', 'Saint Kitts & Nevis Anguilla', (SELECT id FROM core_currency WHERE code='xcd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('kp', 'North Korea', (SELECT id FROM core_currency WHERE code='kpw' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('kr', 'South Korea', (SELECT id FROM core_currency WHERE code='krw' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('kw', 'Kuwait', (SELECT id FROM core_currency WHERE code='kwd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ky', 'Cayman Islands', (SELECT id FROM core_currency WHERE code='kyd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('kz', 'Kazakhstan', (SELECT id FROM core_currency WHERE code='kzt' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('la', 'Laos', (SELECT id FROM core_currency WHERE code='lak' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('lb', 'Lebanon', (SELECT id FROM core_currency WHERE code='lbp' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('lc', 'Saint Lucia', (SELECT id FROM core_currency WHERE code='xcd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('li', 'Liechtenstein', (SELECT id FROM core_currency WHERE code='chf' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('lk', 'Sri Lanka', (SELECT id FROM core_currency WHERE code='lkr' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('lr', 'Liberia', (SELECT id FROM core_currency WHERE code='lrd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ls', 'Lesotho', (SELECT id FROM core_currency WHERE code='lsl' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('lt', 'Lithuania', (SELECT id FROM core_currency WHERE code='ltl' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('lu', 'Luxembourg', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('lv', 'Latvia', (SELECT id FROM core_currency WHERE code='lvl' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ly', 'Libya', (SELECT id FROM core_currency WHERE code='lyd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ma', 'Morocco', (SELECT id FROM core_currency WHERE code='mad' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('mc', 'Monaco', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('md', 'Moldavia', (SELECT id FROM core_currency WHERE code='mdl' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('me', 'Montenegro', (SELECT id FROM core_currency WHERE code='lyd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('mf', 'Saint Martin (French part)', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('mg', 'Madagascar', (SELECT id FROM core_currency WHERE code='mga' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('mh', 'Marshall Islands', (SELECT id FROM core_currency WHERE code='usd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('mk', 'Macedonia, the former Yugoslav Republic of', (SELECT id FROM core_currency WHERE code='mkd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ml', 'Mali', (SELECT id FROM core_currency WHERE code='xof' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('mm', 'Myanmar', (SELECT id FROM core_currency WHERE code='mmk' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('mn', 'Mongolia', (SELECT id FROM core_currency WHERE code='mnt' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('mo', 'Macau', (SELECT id FROM core_currency WHERE code='mop' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('mp', 'Northern Mariana Islands', (SELECT id FROM core_currency WHERE code='usd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('mq', 'Martinique (French)', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('mr', 'Mauritania', (SELECT id FROM core_currency WHERE code='mro' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ms', 'Montserrat', (SELECT id FROM core_currency WHERE code='xcd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('mt', 'Malta', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('mu', 'Mauritius', (SELECT id FROM core_currency WHERE code='mur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('mv', 'Maldives', (SELECT id FROM core_currency WHERE code='mvr' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('mw', 'Malawi', (SELECT id FROM core_currency WHERE code='mwk' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('mx', 'Mexico', (SELECT id FROM core_currency WHERE code='mxn' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('my', 'Malaysia', (SELECT id FROM core_currency WHERE code='mxn' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('mz', 'Mozambique', (SELECT id FROM core_currency WHERE code='mzn' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('na', 'Namibia', (SELECT id FROM core_currency WHERE code='nad' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('nc', 'New Caledonia (French)', (SELECT id FROM core_currency WHERE code='xpf' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ne', 'Niger', (SELECT id FROM core_currency WHERE code='xof' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('nf', 'Norfolk Island', (SELECT id FROM core_currency WHERE code='aud' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ng', 'Nigeria', (SELECT id FROM core_currency WHERE code='ngn' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ni', 'Nicaragua', (SELECT id FROM core_currency WHERE code='nio' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('nl', 'Netherlands', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('no', 'Norway', (SELECT id FROM core_currency WHERE code='nok' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('np', 'Nepal', (SELECT id FROM core_currency WHERE code='npr' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('nr', 'Nauru', (SELECT id FROM core_currency WHERE code='aud' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('nt', 'Neutral Zone', (SELECT id FROM core_currency WHERE code='iqd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('nu', 'Niue', (SELECT id FROM core_currency WHERE code='nzd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('nz', 'New Zealand', (SELECT id FROM core_currency WHERE code='nzd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('om', 'Oman', (SELECT id FROM core_currency WHERE code='omr' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('pa', 'Panama', (SELECT id FROM core_currency WHERE code='pab' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('pe', 'Peru', (SELECT id FROM core_currency WHERE code='pen' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('pf', 'Polynesia (French)', (SELECT id FROM core_currency WHERE code='xpf' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('pg', 'Papua New Guinea', (SELECT id FROM core_currency WHERE code='pgk' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ph', 'Philippines', (SELECT id FROM core_currency WHERE code='php' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('pk', 'Pakistan', (SELECT id FROM core_currency WHERE code='pkr' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('pl', 'Poland', (SELECT id FROM core_currency WHERE code='plz' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('pm', 'Saint Pierre and Miquelon', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('pn', 'Pitcairn Island', (SELECT id FROM core_currency WHERE code='nzd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('pr', 'Puerto Rico', (SELECT id FROM core_currency WHERE code='usd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ps', 'Palestinian Territory, Occupied', (SELECT id FROM core_currency WHERE code='ils' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('pt', 'Portugal', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('pw', 'Palau', (SELECT id FROM core_currency WHERE code='usd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('py', 'Paraguay', (SELECT id FROM core_currency WHERE code='pyg' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('qa', 'Qatar', (SELECT id FROM core_currency WHERE code='qar' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('re', 'Reunion (French)', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ro', 'Romania', (SELECT id FROM core_currency WHERE code='rol' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('rs', 'Serbia', (SELECT id FROM core_currency WHERE code='rsd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id, priority) VALUES ('ru', 'Russian Federation', (SELECT id FROM core_currency WHERE code='rub' LIMIT 1), 100);
INSERT INTO core_country(code, name, core_currency_id) VALUES ('rw', 'Rwanda', (SELECT id FROM core_currency WHERE code='rwf' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('sa', 'Saudi Arabia', (SELECT id FROM core_currency WHERE code='sar' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('sb', 'Solomon Islands', (SELECT id FROM core_currency WHERE code='sbd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('sc', 'Seychelles', (SELECT id FROM core_currency WHERE code='scr' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('sd', 'Sudan', (SELECT id FROM core_currency WHERE code='sdd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('se', 'Sweden', (SELECT id FROM core_currency WHERE code='sek' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('sg', 'Singapore', (SELECT id FROM core_currency WHERE code='sgd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('sh', 'Saint Helena', (SELECT id FROM core_currency WHERE code='shp' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('si', 'Slovenia', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('sj', 'Svalbard and Jan Mayen Islands', (SELECT id FROM core_currency WHERE code='nok' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('sk', 'Slovakia', (SELECT id FROM core_currency WHERE code='skk' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('sl', 'Sierra Leone', (SELECT id FROM core_currency WHERE code='sll' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('sm', 'San Marino', (SELECT id FROM core_currency WHERE code='itl' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('sn', 'Senegal', (SELECT id FROM core_currency WHERE code='xof' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('so', 'Somalia', (SELECT id FROM core_currency WHERE code='sod' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('sr', 'Suriname', (SELECT id FROM core_currency WHERE code='srg' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ss', 'South Sudan', (SELECT id FROM core_currency WHERE code='ssp' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('st', 'Saint Tome (Sao Tome) and Principe', (SELECT id FROM core_currency WHERE code='std' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('sv', 'El Salvador', (SELECT id FROM core_currency WHERE code='svc' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('sx', 'Sint Maarten (Dutch part)', (SELECT id FROM core_currency WHERE code='ang' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('sy', 'Syria', (SELECT id FROM core_currency WHERE code='syp' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('sz', 'Swaziland', (SELECT id FROM core_currency WHERE code='szl' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('tc', 'Turks and Caicos Islands', (SELECT id FROM core_currency WHERE code='usd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('td', 'Chad', (SELECT id FROM core_currency WHERE code='xaf' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('tf', 'French Southern Territories', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('tg', 'Togo', (SELECT id FROM core_currency WHERE code='xof' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('th', 'Thailand', (SELECT id FROM core_currency WHERE code='thb' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('tj', 'Tajikistan', (SELECT id FROM core_currency WHERE code='tjr' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('tk', 'Tokelau', (SELECT id FROM core_currency WHERE code='nzd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('tm', 'Turkmenistan', (SELECT id FROM core_currency WHERE code='tmm' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('tn', 'Tunisia', (SELECT id FROM core_currency WHERE code='tnd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('to', 'Tonga', (SELECT id FROM core_currency WHERE code='top' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('tp', 'East Timor', (SELECT id FROM core_currency WHERE code='tpe' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('tr', 'Turkey', (SELECT id FROM core_currency WHERE code='trl' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('tt', 'Trinidad and Tobago', (SELECT id FROM core_currency WHERE code='ttd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('tv', 'Tuvalu', (SELECT id FROM core_currency WHERE code='aud' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('tw', 'Taiwan', (SELECT id FROM core_currency WHERE code='twd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('tz', 'Tanzania', (SELECT id FROM core_currency WHERE code='tzs' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ua', 'Ukraine', (SELECT id FROM core_currency WHERE code='uag' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ug', 'Uganda', (SELECT id FROM core_currency WHERE code='ugx' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id, priority) VALUES ('gb', 'United Kingdom', (SELECT id FROM core_currency WHERE code='gbp' LIMIT 1), 4);
INSERT INTO core_country(code, name, core_currency_id) VALUES ('um', 'USA Minor Outlying Islands', (SELECT id FROM core_currency WHERE code='usd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('us', 'United States', (SELECT id FROM core_currency WHERE code='usd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('uy', 'Uruguay', (SELECT id FROM core_currency WHERE code='uyp' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('uz', 'Uzbekistan', (SELECT id FROM core_currency WHERE code='uzs' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('va', 'Holy See (Vatican City State)', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('vc', 'Saint Vincent & Grenadines', (SELECT id FROM core_currency WHERE code='xcd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ve', 'Venezuela', (SELECT id FROM core_currency WHERE code='vub' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('vg', 'Virgin Islands (British)', (SELECT id FROM core_currency WHERE code='usd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('vi', 'Virgin Islands (USA)', (SELECT id FROM core_currency WHERE code='usd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('vn', 'Vietnam', (SELECT id FROM core_currency WHERE code='vnd' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('vu', 'Vanuatu', (SELECT id FROM core_currency WHERE code='vuv' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('wf', 'Wallis and Futuna Islands', (SELECT id FROM core_currency WHERE code='xpf' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ws', 'Samoa', (SELECT id FROM core_currency WHERE code='wst' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('ye', 'Yemen', (SELECT id FROM core_currency WHERE code='yer' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('yt', 'Mayotte', (SELECT id FROM core_currency WHERE code='eur' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('yu', 'Yugoslavia', (SELECT id FROM core_currency WHERE code='yum' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('za', 'South Africa', (SELECT id FROM core_currency WHERE code='zar' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('zm', 'Zambia', (SELECT id FROM core_currency WHERE code='zmk' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('zr', 'Zaire', (SELECT id FROM core_currency WHERE code='zrz' LIMIT 1) );
INSERT INTO core_country(code, name, core_currency_id) VALUES ('zw', 'Zimbabwe', (SELECT id FROM core_currency WHERE code='zwd' LIMIT 1) );

---- general translations
--INSERT INTO core_translation(code, source, en_gb, fr_fr, en_us) VALUES('dateFormat', 'd/m/Y', 'd/m/Y', 'd/m/Y', 'm/d/Y');


/* config constants in database */
INSERT INTO core_config(k, v) VALUES('framework_environment', 'prod');
INSERT INTO core_config(k, v) VALUES('email_active', 'false');
INSERT INTO core_config(k, v) VALUES('theme', 'materialize');
INSERT INTO core_config(k, v) VALUES('default_lang_code', (SELECT code FROM core_lang WHERE code='en_gb' LIMIT 1));
INSERT INTO core_config(k, v) VALUES('default_country_code', (SELECT code FROM core_country WHERE code='ch' LIMIT 1));
INSERT INTO core_config(k, v) VALUES('default_currency_code', (SELECT code FROM core_currency WHERE code='chf' LIMIT 1));
INSERT INTO core_config(k, v) VALUES('email_info', 'info@localhost');
INSERT INTO core_config(k, v) VALUES('email_noreply', 'no-reply@localhost');

CREATE TABLE user_user (
    id SERIAL,
    create_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    email VARCHAR(128) NOT NULL,
    password VARCHAR(128) NOT NULL,
    firstname VARCHAR(128) NOT NULL DEFAULT '',
    lastname VARCHAR(128) NOT NULL DEFAULT '',
    phone VARCHAR(32) NOT NULL DEFAULT '',
    postcode VARCHAR(32) NOT NULL DEFAULT '',
    city VARCHAR(128) NOT NULL DEFAULT '',
    core_lang_id INTEGER,
    core_country_id INTEGER,
    core_currency_id INTEGER,
    core_theme_id INTEGER,
    is_active BOOLEAN NOT NULL DEFAULT FALSE,
    comment TEXT NOT NULL DEFAULT '',
    activation_code VARCHAR(128) NOT NULL,
    CONSTRAINT userUser_id_pk PRIMARY KEY(id),
    CONSTRAINT userUser_email_uk UNIQUE(email),
    CONSTRAINT userUser_coreLangId_fk FOREIGN KEY(core_lang_id) REFERENCES core_lang(id),
    CONSTRAINT userUser_coreCountryId_fk FOREIGN KEY(core_country_id) REFERENCES core_country(id),
    CONSTRAINT userUser_coreCurrencyId_fk FOREIGN KEY(core_currency_id) REFERENCES core_currency(id),
    CONSTRAINT userUser_coreThemeId_fk FOREIGN KEY(core_theme_id) REFERENCES core_theme(id)
);
CREATE TABLE user_detail (
    id SERIAL,
    user_id INTEGER NOT NULL,
    ext_id INTEGER NOT NULL,
    CONSTRAINT coreUserDetail_id_pk PRIMARY KEY(id),
    CONSTRAINT coreUserDetail_coreUserId_fk FOREIGN KEY(user_id) REFERENCES user_user(id)
);

CREATE TABLE user_confirm (
    id SERIAL,
    user_id VARCHAR(128) NOT NULL DEFAULT '',
    key_confirmation VARCHAR(128) NOT NULL DEFAULT '',
    email VARCHAR(250) DEFAULT NULL,
    CONSTRAINT coreUserConfirm_pk PRIMARY KEY(id)
);

CREATE TABLE useruser_corefeature_rel (
    user_id INTEGER,
    core_feature_id INTEGER,
    CONSTRAINT userUserCoreFeatureRel_coreUserId_fk FOREIGN KEY(user_id) REFERENCES user_user(id),
    CONSTRAINT userUserCoreFeatureRel_coreMenuId_fk FOREIGN KEY(core_feature_id) REFERENCES core_feature(id),
    CONSTRAINT userUserCoreFeatureRel_userId_menuId_uk UNIQUE(user_id, core_feature_id)
);

-- core_feature: home
INSERT INTO core_feature_translation (code, source, en_gb, fr_fr) VALUES('menu_home_url', 'home', 'home', 'accueil');
INSERT INTO core_feature_translation (code, source, en_gb, fr_fr) VALUES('menu_home_label', 'Home', 'Home', 'Accueil');
INSERT INTO core_feature(model, code, url_feature_translation_id, label_feature_translation_id,
												 is_menu_display, is_available_for_guest
) VALUES('home', 'home',
    (SELECT id FROM core_feature_translation WHERE code='menu_home_url' LIMIT 1),
    (SELECT id FROM core_feature_translation WHERE code='menu_home_label' LIMIT 1),
    TRUE, TRUE
);

INSERT INTO core_feature_translation (code, source, en_gb, fr_fr) VALUES('menu_login_url', 'login', 'login', 'connexion');
INSERT INTO core_feature_translation (code, source, en_gb, fr_fr) VALUES('menu_login_label', 'Login', 'Login', 'Connexion');
INSERT INTO core_feature (model, code, url_feature_translation_id, label_feature_translation_id,
													is_menu_display, is_available_for_guest
) VALUES ('login', 'login',
    (SELECT id FROM core_feature_translation WHERE code='menu_login_url' LIMIT 1),
    (SELECT id FROM core_feature_translation WHERE code='menu_login_label' LIMIT 1),
    TRUE, TRUE
);

-- logout: translations for url/label menu
INSERT INTO core_feature_translation (code, source, en_gb, fr_fr, ko_kr) VALUES ('menu_logout_url', 'logout', 'logout', 'logout', '');
INSERT INTO core_feature_translation (code, source, en_gb, fr_fr, ko_kr) VALUES ('menu_logout_label', 'Logout', 'Logout', 'Déconnexion', '');
-- logout: menu
INSERT INTO core_feature (model, code, url_feature_translation_id, label_feature_translation_id,
													is_menu_display, is_available_for_guest
) VALUES('logout', 'logout',
    (SELECT id FROM core_feature_translation WHERE code='menu_logout_url' LIMIT 1),
    (SELECT id FROM core_feature_translation WHERE code='menu_logout_label' LIMIT 1),
    TRUE, FALSE
);

-- my-profile: translations for url/label menu
INSERT INTO core_feature_translation (code, source, en_gb, fr_fr) VALUES('menu_myProfile_url', 'my-profile', 'my-profile', 'mon-compte');
INSERT INTO core_feature_translation (code, source, en_gb, fr_fr) VALUES('menu_myProfile_label', 'My Profile', 'My Profile', 'Mon Compte');
INSERT INTO core_feature (model, code, url_feature_translation_id, label_feature_translation_id,
													is_menu_display, is_available_for_guest
) VALUES ('my-profile', 'my-profile',
    (SELECT id FROM core_feature_translation WHERE code='menu_myProfile_url' LIMIT 1),
    (SELECT id FROM core_feature_translation WHERE code='menu_myProfile_label' LIMIT 1),
    TRUE, FALSE
);

CREATE TABLE erp_config(
  id SERIAL,
  create_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  k VARCHAR(128) NOT NULL,
  v VARCHAR(128) NOT NULL,
  is_active BOOLEAN NOT NULL DEFAULT TRUE,
  comment TEXT NOT NULL DEFAULT '',
  CONSTRAINT erpConfig_id_pk PRIMARY KEY(id),
  CONSTRAINT erpConfig_k_uk UNIQUE(k)
);
INSERT INTO erp_config(k, v)
VALUES('url', 'http://localhost:8069/'),
  ('db', 'odoo_wefra'),
  ('admin_user', 'admin'),
  ('admin_password', 'admin');


--reorganise the priority of the menu tags
UPDATE core_feature SET priority=10 WHERE code='home';
UPDATE core_feature SET priority=900 WHERE code='my-profile';
UPDATE core_feature SET priority=1000 WHERE code='login';
UPDATE core_feature SET priority=1000 WHERE code='logout';

