CREATE TABLE IF NOT EXISTS `apw_DCountry` (
  `id` char(2) NOT NULL,
  `isoAlpha3` char(3) NOT NULL,
  `name` varchar(255) NOT NULL,
  `title` varchar(255) NOT NULL,
  `sorter` int(11) NOT NULL,
  `enabled` enum('n','y') NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


INSERT INTO `apw_DCountry` (`id`, `isoAlpha3`, `name`, `title`, `sorter`, `enabled`) VALUES
('AF', 'AFG', 'AFGHANISTAN', 'Afghanistan', 2, 'y'),
('AL', 'ALB', 'ALBANIA', 'Albania', 3, 'y'),
('DZ', 'DZA', 'ALGERIA', 'Algeria', 4, 'y'),
('AD', 'AND', 'ANDORRA', 'Andorra', 5, 'y'),
('AO', 'AGO', 'ANGOLA', 'Angola', 6, 'y'),
('AQ', 'ATA', 'ANTARCTICA', 'Antarctica', 7, 'y'),
('AG', 'ATG', 'ANTIGUA AND BARBUDA', 'Antigua and Barbuda', 8, 'y'),
('AR', 'ARG', 'ARGENTINA', 'Argentina', 9, 'y'),
('AM', 'ARM', 'ARMENIA', 'Armenia', 10, 'y'),
('AW', 'ABW', 'ARUBA', 'Aruba', 11, 'y'),
('AU', 'AUS', 'AUSTRALIA', 'Australia', 12, 'y'),
('AT', 'AUT', 'AUSTRIA', 'Austria', 13, 'y'),
('AZ', 'AZE', 'AZERBAIJAN', 'Azerbaijan', 14, 'y'),
('BS', 'BHS', 'BAHAMAS', 'Bahamas', 15, 'y'),
('BH', 'BHR', 'BAHRAIN', 'Bahrain', 16, 'y'),
('BD', 'BGD', 'BANGLADESH', 'Bangladesh', 17, 'y'),
('BB', 'BRB', 'BARBADOS', 'Barbados', 18, 'y'),
('BY', 'BLR', 'BELARUS', 'Belarus', 19, 'y'),
('BE', 'BEL', 'BELGIUM', 'Belgium', 20, 'y'),
('BZ', 'BLZ', 'BELIZE', 'Belize', 21, 'y'),
('BJ', 'BEN', 'BENIN', 'Benin', 22, 'y'),
('BM', 'BMU', 'BERMUDA', 'Bermuda', 23, 'y'),
('BT', 'BTN', 'BHUTAN', 'Bhutan', 24, 'y'),
('BO', 'BOL', 'BOLIVIA', 'Bolivia', 25, 'y'),
('BA', 'BIH', 'BOSNIA AND HERZEGOVINA', 'Bosnia and Herzegovina', 26, 'y'),
('BW', 'BWA', 'BOTSWANA', 'Botswana', 27, 'y'),
('BR', 'BRA', 'BRAZIL', 'Brazil', 28, 'y'),
('IO', 'IOT', 'BRITISH INDIAN OCEAN TERRITORY', 'British Indian Ocean Territory', 29, 'y'),
('BN', 'BRN', 'BRUNEI DARUSSALAM', 'Brunei Darussalam', 30, 'y'),
('BG', 'BGR', 'BULGARIA', 'Bulgaria', 31, 'y'),
('BF', 'BFA', 'BURKINA FASO', 'Burkina Faso', 32, 'y'),
('BI', 'BDI', 'BURUNDI', 'Burundi', 33, 'y'),
('KH', 'KHM', 'CAMBODIA', 'Cambodia', 34, 'y'),
('CM', 'CMR', 'CAMEROON', 'Cameroon', 35, 'y'),
('CA', 'CAN', 'CANADA', 'Canada', 36, 'y'),
('CV', 'CPV', 'CAPE VERDE', 'Cape Verde', 37, 'y'),
('CF', 'CAF', 'CENTRAL AFRICAN REPUBLIC', 'Central African Republic', 38, 'y'),
('TD', 'TCD', 'CHAD', 'Chad', 39, 'y'),
('CL', 'CHL', 'CHILE', 'Chile', 40, 'y'),
('CN', 'CHN', 'CHINA', 'China', 41, 'y'),
('CO', 'COL', 'COLOMBIA', 'Colombia', 42, 'y'),
('KM', 'COM', 'COMOROS', 'Comoros', 43, 'y'),
('CG', 'COG', 'CONGO', 'Congo', 44, 'y'),
('CD', 'COD', 'CONGO, DEMOCRATIC REPUBLIC OF THE CONGO', 'Congo, Democratic Republic of the Congo', 45, 'y'),
('CR', 'CRI', 'COSTA RICA', 'Costa Rica', 46, 'y'),
('CI', 'CIV', 'COTE D''IVOIRE', 'Cote D''ivoire', 47, 'y'),
('HR', 'HRV', 'CROATIA', 'Croatia', 48, 'y'),
('CU', 'CUB', 'CUBA', 'Cuba', 49, 'y'),
('CY', 'CYP', 'CYPRUS', 'Cyprus', 50, 'y'),
('CZ', 'CZE', 'CZECH REPUBLIC', 'Czech Republic', 51, 'y'),
('DK', 'DNK', 'DENMARK', 'Denmark', 52, 'y'),
('DJ', 'DJI', 'DJIBOUTI', 'Djibouti', 53, 'y'),
('DM', 'DMA', 'DOMINICA', 'Dominica', 54, 'y'),
('DO', 'DOM', 'DOMINICAN REPUBLIC', 'Dominican Republic', 55, 'y'),
('EC', 'ECU', 'ECUADOR', 'Ecuador', 56, 'y'),
('EG', 'EGY', 'EGYPT', 'Egypt', 57, 'y'),
('SV', 'SLV', 'EL SALVADOR', 'El Salvador', 58, 'y'),
('GQ', 'GNQ', 'EQUATORIAL GUINEA', 'Equatorial Guinea', 59, 'y'),
('ER', 'ERI', 'ERITREA', 'Eritrea', 60, 'y'),
('EE', 'EST', 'ESTONIA', 'Estonia', 61, 'y'),
('ET', 'ETH', 'ETHIOPIA', 'Ethiopia', 62, 'y'),
('FO', 'FRO', 'FAROE ISLANDS', 'Faroe Islands', 63, 'y'),
('FJ', 'FJI', 'FIJI', 'Fiji', 64, 'y'),
('FI', 'FIN', 'FINLAND', 'Finland', 65, 'y'),
('FR', 'FRA', 'FRANCE', 'France', 66, 'y'),
('GF', 'GUF', 'FRENCH GUIANA', 'French Guiana', 67, 'y'),
('TF', 'ATF', 'FRENCH SOUTHERN TERRITORIES', 'French Southern Territories', 68, 'y'),
('GA', 'GAB', 'GABON', 'Gabon', 69, 'y'),
('GM', 'GMB', 'GAMBIA', 'Gambia', 70, 'y'),
('GE', 'GEO', 'GEORGIA', 'Georgia', 71, 'y'),
('DE', 'DEU', 'GERMANY', 'Germany', 72, 'y'),
('GH', 'GHA', 'GHANA', 'Ghana', 73, 'y'),
('GR', 'GRC', 'GREECE', 'Greece', 74, 'y'),
('GD', 'GRD', 'GRENADA', 'Grenada', 75, 'y'),
('GP', 'GLP', 'GUADELOUPE', 'Guadeloupe', 76, 'y'),
('GT', 'GTM', 'GUATEMALA', 'Guatemala', 77, 'y'),
('GN', 'GIN', 'GUINEA', 'Guinea', 78, 'y'),
('GW', 'GNB', 'GUINEA-BISSAU', 'Guinea-Bissau', 79, 'y'),
('GY', 'GUY', 'GUYANA', 'Guyana', 80, 'y'),
('HT', 'HTI', 'HAITI', 'Haiti', 81, 'y'),
('HK', 'HKG', 'HONG KONG', 'Hong Kong', 83, 'y'),
('HN', 'HND', 'HONDURAS', 'Honduras', 82, 'y'),
('HU', 'HUN', 'HUNGARY', 'Hungary', 84, 'y'),
('IS', 'ISL', 'ICELAND', 'Iceland', 85, 'y'),
('IN', 'IND', 'INDIA', 'India', 86, 'y'),
('ID', 'IDN', 'INDONESIA', 'Indonesia', 87, 'y'),
('IR', 'IRN', 'IRAN, ISLAMIC REPUBLIC OF', 'Iran, Islamic Republic of', 88, 'y'),
('IQ', 'IRQ', 'IRAQ', 'Iraq', 89, 'y'),
('IE', 'IRL', 'IRELAND', 'Ireland', 90, 'y'),
('IL', 'ISR', 'ISRAEL', 'Israel', 91, 'y'),
('IT', 'ITA', 'ITALY', 'Italy', 92, 'y'),
('JM', 'JAM', 'JAMAICA', 'Jamaica', 93, 'y'),
('JP', 'JPN', 'JAPAN', 'Japan', 94, 'y'),
('JE', 'JEY', 'JERSEY', 'Jersey', 95, 'y'),
('JO', 'JOR', 'JORDAN', 'Jordan', 96, 'y'),
('KZ', 'KAZ', 'KAZAKHSTAN', 'Kazakhstan', 97, 'y'),
('KE', 'KEN', 'KENYA', 'Kenya', 98, 'y'),
('KI', 'KIR', 'KIRIBATI', 'Kiribati', 99, 'y'),
('KP', 'PRK', 'KOREA, DEMOCRATIC PEOPLE''S REPUBLIC OF', 'Korea, Democratic People''s Republic of', 100, 'y'),
('KR', 'KOR', 'KOREA, REPUBLIC OF', 'Korea, Republic of', 101, 'y'),
('KW', 'KWT', 'KUWAIT', 'Kuwait', 102, 'y'),
('KG', 'KGZ', 'KYRGYZSTAN', 'Kyrgyzstan', 103, 'y'),
('LA', 'LAO', 'LAO PEOPLE''S DEMOCRATIC REPUBLIC', 'Lao People''s Democratic Republic', 104, 'y'),
('LV', 'LVA', 'LATVIA', 'Latvia', 105, 'y'),
('LB', 'LBN', 'LEBANON', 'Lebanon', 106, 'y'),
('LS', 'LSO', 'LESOTHO', 'Lesotho', 107, 'y'),
('LR', 'LBR', 'LIBERIA', 'Liberia', 108, 'y'),
('LY', 'LBY', 'LIBYAN ARAB JAMAHIRIYA', 'Libyan Arab Jamahiriya', 109, 'y'),
('LI', 'LIE', 'LIECHTENSTEIN', 'Liechtenstein', 110, 'y'),
('LT', 'LTU', 'LITHUANIA', 'Lithuania', 111, 'y'),
('LU', 'LUX', 'LUXEMBOURG', 'Luxembourg', 112, 'y'),
('MO', 'MAC', 'MACAU', 'Macau', 113, 'y'),
('MK', 'MKD', 'MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF', 'Macedonia, the Former Yugoslav Republic of', 114, 'y'),
('MG', 'MDG', 'MADAGASCAR', 'Madagascar', 115, 'y'),
('MW', 'MWI', 'MALAWI', 'Malawi', 116, 'y'),
('MY', 'MYS', 'MALAYSIA', 'Malaysia', 117, 'y'),
('MV', 'MDV', 'MALDIVES', 'Maldives', 118, 'y'),
('ML', 'MLI', 'MALI', 'Mali', 119, 'y'),
('MQ', 'MTQ', 'MARTINIQUE', 'Martinique', 120, 'y'),
('MR', 'MRT', 'MAURITANIA', 'Mauritania', 121, 'y'),
('MU', 'MUS', 'MAURITIUS', 'Mauritius', 122, 'y'),
('MX', 'MEX', 'MEXICO', 'Mexico', 123, 'y'),
('FM', 'FSM', 'MICRONESIA, FEDERATED STATES OF', 'Micronesia, Federated States of', 124, 'y'),
('MD', 'MDA', 'MOLDOVA', 'Moldova', 125, 'y'),
('MC', 'MCO', 'MONACO', 'Monaco', 126, 'y'),
('MN', 'MNG', 'MONGOLIA', 'Mongolia', 127, 'y'),
('ME', 'MNE', 'MONTENEGRO', 'Montenegro', 128, 'y'),
('MS', 'MSR', 'MONTSERRAT', 'Montserrat', 129, 'y'),
('MA', 'MAR', 'MOROCCO', 'Morocco', 130, 'y'),
('MZ', 'MOZ', 'MOZAMBIQUE', 'Mozambique', 131, 'y'),
('MM', 'MMR', 'MYANMAR', 'Myanmar', 132, 'y'),
('NA', 'NAM', 'NAMIBIA', 'Namibia', 133, 'y'),
('NP', 'NPL', 'NEPAL', 'Nepal', 134, 'y'),
('NL', 'NLD', 'NETHERLANDS', 'Netherlands', 135, 'y'),
('NZ', 'NZL', 'NEW ZEALAND', 'New Zealand', 136, 'y'),
('NI', 'NIC', 'NICARAGUA', 'Nicaragua', 137, 'y'),
('NE', 'NER', 'NIGER', 'Niger', 138, 'y'),
('NG', 'NGA', 'NIGERIA', 'Nigeria', 139, 'y'),
('NO', 'NOR', 'NORWAY', 'Norway', 140, 'y'),
('OM', 'OMN', 'OMAN', 'Oman', 141, 'y'),
('PK', 'PAK', 'PAKISTAN', 'Pakistan', 142, 'y'),
('PW', 'PLW', 'PALAU', 'Palau', 143, 'y'),
('PS', 'PSE', 'PALESTINIAN TERRITORY', 'Palestinian Territory', 144, 'y'),
('PA', 'PAN', 'PANAMA', 'Panama', 145, 'y'),
('PG', 'PNG', 'PAPUA NEW GUINEA', 'Papua New Guinea', 146, 'y'),
('PY', 'PRY', 'PARAGUAY', 'Paraguay', 147, 'y'),
('PE', 'PER', 'PERU', 'Peru', 148, 'y'),
('PH', 'PHL', 'PHILIPPINES', 'Philippines', 149, 'y'),
('PL', 'POL', 'POLAND', 'Poland', 150, 'y'),
('PT', 'PRT', 'PORTUGAL', 'Portugal', 151, 'y'),
('QA', 'QAT', 'QATAR', 'Qatar', 152, 'y'),
('RE', 'REU', 'REUNION', 'Reunion', 153, 'y'),
('RO', 'ROU', 'ROMANIA', 'Romania', 154, 'y'),
('RU', 'RUS', 'RUSSIAN FEDERATION', 'Russian Federation', 155, 'y'),
('RW', 'RWA', 'RWANDA', 'Rwanda', 156, 'y'),
('SH', 'SHN', 'SAINT HELENA', 'Saint Helena', 157, 'y'),
('KN', 'KNA', 'SAINT KITTS AND NEVIS', 'Saint Kitts and Nevis', 158, 'y'),
('LC', 'LCA', 'SAINT LUCIA', 'Saint Lucia', 159, 'y'),
('VC', 'VCT', 'SAINT VINCENT AND THE GRENADINES', 'Saint Vincent and The Grenadines', 160, 'y'),
('SM', 'SMR', 'SAN MARINO', 'San Marino', 161, 'y'),
('ST', 'STP', 'SAO TOME AND PRINCIPE', 'Sao Tome and Principe', 162, 'y'),
('SA', 'SAU', 'SAUDI ARABIA', 'Saudi Arabia', 163, 'y'),
('SN', 'SEN', 'SENEGAL', 'Senegal', 164, 'y'),
('RS', 'SRB', 'SERBIA', 'Serbia', 165, 'y'),
('SC', 'SYC', 'SEYCHELLES', 'Seychelles', 166, 'y'),
('SL', 'SLE', 'SIERRA LEONE', 'Sierra Leone', 167, 'y'),
('SG', 'SGP', 'SINGAPORE', 'Singapore', 168, 'y'),
('SX', 'SXM', 'SINT MAARTEN', 'Sint Maarten', 169, 'y'),
('SK', 'SVK', 'SLOVAKIA', 'Slovakia', 170, 'y'),
('SI', 'SVN', 'SLOVENIA', 'Slovenia', 171, 'y'),
('SB', 'SLB', 'SOLOMON ISLANDS', 'Solomon Islands', 172, 'y'),
('SO', 'SOM', 'SOMALIA', 'Somalia', 173, 'y'),
('ZA', 'ZAF', 'SOUTH AFRICA', 'South Africa', 174, 'y'),
('ES', 'ESP', 'SPAIN', 'Spain', 175, 'y'),
('LK', 'LKA', 'SRI LANKA', 'Sri Lanka', 176, 'y'),
('SD', 'SDN', 'SUDAN', 'Sudan', 177, 'y'),
('SR', 'SUR', 'SURINAME', 'Suriname', 178, 'y'),
('SZ', 'SWZ', 'SWAZILAND', 'Swaziland', 179, 'y'),
('SE', 'SWE', 'SWEDEN', 'Sweden', 180, 'y'),
('CH', 'CHE', 'SWITZERLAND', 'Switzerland', 181, 'y'),
('SY', 'SYR', 'SYRIAN ARAB REPUBLIC', 'Syrian Arab Republic', 182, 'y'),
('TW', 'TWN', 'TAIWAN, PROVINCE OF CHINA', 'Taiwan, Province of China', 183, 'y'),
('TJ', 'TJK', 'TAJIKISTAN', 'Tajikistan', 184, 'y'),
('TZ', 'TZA', 'TANZANIA, UNITED REPUBLIC OF', 'Tanzania, United Republic of', 185, 'y'),
('TH', 'THA', 'THAILAND', 'Thailand', 186, 'y'),
('TL', 'TLS', 'TIMOR-LESTE (EAST TIMOR)', 'Timor-Leste (East Timor)', 187, 'y'),
('TG', 'TGO', 'TOGO', 'Togo', 188, 'y'),
('TT', 'TTO', 'TRINIDAD AND TOBAGO', 'Trinidad and Tobago', 189, 'y'),
('TN', 'TUN', 'TUNISIA', 'Tunisia', 190, 'y'),
('TR', 'TUR', 'TURKEY', 'Turkey', 191, 'y'),
('TM', 'TKM', 'TURKMENISTAN', 'Turkmenistan', 192, 'y'),
('UG', 'UGA', 'UGANDA', 'Uganda', 193, 'y'),
('UA', 'UKR', 'UKRAINE', 'Ukraine', 194, 'y'),
('AE', 'ARE', 'UNITED ARAB EMIRATES', 'United Arab Emirates', 195, 'y'),
('GB', 'GBR', 'UNITED KINGDOM', 'United Kingdom', 196, 'y'),
('US', 'USA', 'UNITED STATES', 'United States', 0, 'y'),
('UY', 'URY', 'URUGUAY', 'Uruguay', 198, 'y'),
('UZ', 'UZB', 'UZBEKISTAN', 'Uzbekistan', 199, 'y'),
('VU', 'VUT', 'VANUATU', 'Vanuatu', 200, 'y'),
('VE', 'VEN', 'VENEZUELA', 'Venezuela', 201, 'y'),
('VN', 'VNM', 'VIETNAM', 'Vietnam', 202, 'y'),
('EH', 'ESH', 'WESTERN SAHARA', 'Western Sahara', 203, 'y'),
('YE', 'YEM', 'YEMEN', 'Yemen', 204, 'y'),
('ZM', 'ZMB', 'ZAMBIA', 'Zambia', 205, 'y'),
('ZW', 'ZWE', 'ZIMBABWE', 'Zimbabwe', 206, 'y');

--
-- Indexes for table `apw_DCountry`
--
ALTER TABLE `apw_DCountry`
 ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `isoAlpha3` (`isoAlpha3`);


-- -----

ALTER TABLE `apw_Transaction` ADD `billingCountryId` VARCHAR(255) NOT NULL AFTER `billingState`;
UPDATE `apw_Transaction` SET `billingCountryId` = 'US';

ALTER TABLE `apw_User` ADD `countryId` VARCHAR(2) NOT NULL AFTER `state`;
UPDATE `apw_User` SET `countryId` = 'US';
