# -*- encoding : utf-8 -*-
class CreateInitialSchema < ActiveRecord::Migration
  def self.up
    create_table :accounts, :force => true do |t|
      t.boolean :enabled, :default => true
      t.string :login, :email, :null => false
      t.string :crypted_password, :salt, :limit => 40, :null => false
      t.string :remember_token
      t.string :password_reset_code, :activation_code, :limit => 40
      t.datetime :remember_token_expires_at, :activated_at
      t.timestamps
    end
    
    add_index :accounts, :login, :unique => true
    add_index :accounts, :email, :unique => true
    
    create_table :personas do |t|
      t.integer :account_id, :null => false
      t.string :title, :null => false
      t.string :nickname, :email, :fullname, :postcode, :country, :language, :timezone
      t.string :gender, :limit => 1
      t.date :dob
      t.boolean :deletable, :null => false, :default => true
      t.timestamps
    end
    
    add_index :personas, [:account_id, :title], :unique => true
    
    create_table :sites do |t|
      t.integer :account_id, :persona_id, :null => false
      t.string :url, :null => false
      t.timestamps
    end
    
    add_index :sites, [:account_id, :url], :unique => true
    
    create_table :release_policies do |t|
      t.integer :site_id, :null => false
      t.string :property, :null => false
    end
    
    add_index :release_policies, [:site_id, :property], :unique => true
    
    create_table :open_id_associations, :force => true do |t|
      t.binary :server_url, :secret
      t.string :handle, :assoc_type
      t.integer :issued, :lifetime
    end

    create_table :open_id_nonces, :force => true do |t|
      t.string :server_url, :salt, :null => false
      t.integer :timestamp, :null => false
    end
    
    create_table :open_id_requests, :force => true do |t|
      t.string :token, :limit => 40
      t.text :parameters
      t.timestamps
    end
    
    add_index :open_id_requests, :token, :unique => true
    
    create_table :countries, :force => true do |t|
      t.string :name, :null => false, :limit => 60
      t.string :code, :null => false, :limit => 5
    end
    
    add_index :countries, :code, :unique => true
    
    Country.create([
      { :name => 'Afghanistan', :code => 'AF' },
      { :name => 'Albania', :code => 'AL' },
      { :name => 'Algeria', :code => 'DZ' },
      { :name => 'American Samoa', :code => 'AS' },
      { :name => 'Andorra', :code => 'AD' },
      { :name => 'Angola', :code => 'AO' },
      { :name => 'Anguilla', :code => 'AI' },
      { :name => 'Antarctica', :code => 'AQ' },
      { :name => 'Antigua and Barbuda', :code => 'AG' },
      { :name => 'Argentina', :code => 'AR' },
      { :name => 'Armenia', :code => 'AM' },
      { :name => 'Aruba', :code => 'AW' },
      { :name => 'Australia', :code => 'AU' },
      { :name => 'Austria', :code => 'AT' },
      { :name => 'Azerbaijan', :code => 'AZ' },
      { :name => 'Bahamas', :code => 'BS' },
      { :name => 'Bahrain', :code => 'BH' },
      { :name => 'Bangladesh', :code => 'BD' },
      { :name => 'Barbados', :code => 'BB' },
      { :name => 'Belarus', :code => 'BY' },
      { :name => 'Belgium', :code => 'BE' },
      { :name => 'Belize', :code => 'BZ' },
      { :name => 'Benin', :code => 'BJ' },
      { :name => 'Bermuda', :code => 'BM' },
      { :name => 'Bhutan', :code => 'BT' },
      { :name => 'Bolivia', :code => 'BO' },
      { :name => 'Bosnia and Herzegovina', :code => 'BA' },
      { :name => 'Botswana', :code => 'BW' },
      { :name => 'Bouvet Island', :code => 'BV' },
      { :name => 'Brazil', :code => 'BR' },
      { :name => 'British Indian Ocean Territory', :code => 'IO' },
      { :name => 'Brunei Darussalam', :code => 'BN' },
      { :name => 'Bulgaria', :code => 'BG' },
      { :name => 'Burkina Faso', :code => 'BF' },
      { :name => 'Burundi', :code => 'BI' },
      { :name => 'Cambodia', :code => 'KH' },
      { :name => 'Cameroon', :code => 'CM' },
      { :name => 'Canada', :code => 'CA' },
      { :name => 'Cape Verde', :code => 'CV' },
      { :name => 'Cayman Islands', :code => 'KY' },
      { :name => 'Central African Republic', :code => 'CF' },
      { :name => 'Chad', :code => 'TD' },
      { :name => 'Chile', :code => 'CL' },
      { :name => 'China', :code => 'CN' },
      { :name => 'Christmas Island', :code => 'CX' },
      { :name => 'Cocos (Keeling) Islands', :code => 'CC' },
      { :name => 'Colombia', :code => 'CO' },
      { :name => 'Comoros', :code => 'KM' },
      { :name => 'Congo', :code => 'CG' },
      { :name => 'Congo, the Democratic Republic of the', :code => 'CD' },
      { :name => 'Cook Islands', :code => 'CK' },
      { :name => 'Costa Rica', :code => 'CR' },
      { :name => 'Cote D\'Ivoire', :code => 'CI' },
      { :name => 'Croatia', :code => 'HR' },
      { :name => 'Cuba', :code => 'CU' },
      { :name => 'Cyprus', :code => 'CY' },
      { :name => 'Czech Republic', :code => 'CZ' },
      { :name => 'Denmark', :code => 'DK' },
      { :name => 'Djibouti', :code => 'DJ' },
      { :name => 'Dominica', :code => 'DM' },
      { :name => 'Dominican Republic', :code => 'DO' },
      { :name => 'Ecuador', :code => 'EC' },
      { :name => 'Egypt', :code => 'EG' },
      { :name => 'El Salvador', :code => 'SV' },
      { :name => 'Equatorial Guinea', :code => 'GQ' },
      { :name => 'Eritrea', :code => 'ER' },
      { :name => 'Estonia', :code => 'EE' },
      { :name => 'Ethiopia', :code => 'ET' },
      { :name => 'Falkland Islands (Malvinas)', :code => 'FK' },
      { :name => 'Faroe Islands', :code => 'FO' },
      { :name => 'Fiji', :code => 'FJ' },
      { :name => 'Finland', :code => 'FI' },
      { :name => 'France', :code => 'FR' },
      { :name => 'French Guiana', :code => 'GF' },
      { :name => 'French Polynesia', :code => 'PF' },
      { :name => 'French Southern Territories', :code => 'TF' },
      { :name => 'Gabon', :code => 'GA' },
      { :name => 'Gambia', :code => 'GM' },
      { :name => 'Georgia', :code => 'GE' },
      { :name => 'Germany', :code => 'DE' },
      { :name => 'Ghana', :code => 'GH' },
      { :name => 'Gibraltar', :code => 'GI' },
      { :name => 'Greece', :code => 'GR' },
      { :name => 'Greenland', :code => 'GL' },
      { :name => 'Grenada', :code => 'GD' },
      { :name => 'Guadeloupe', :code => 'GP' },
      { :name => 'Guam', :code => 'GU' },
      { :name => 'Guatemala', :code => 'GT' },
      { :name => 'Guinea', :code => 'GN' },
      { :name => 'Guinea-Bissau', :code => 'GW' },
      { :name => 'Guyana', :code => 'GY' },
      { :name => 'Haiti', :code => 'HT' },
      { :name => 'Heard Island and Mcdonald Islands', :code => 'HM' },
      { :name => 'Holy See (Vatican City State)', :code => 'VA' },
      { :name => 'Honduras', :code => 'HN' },
      { :name => 'Hong Kong', :code => 'HK' },
      { :name => 'Hungary', :code => 'HU' },
      { :name => 'Iceland', :code => 'IS' },
      { :name => 'India', :code => 'IN' },
      { :name => 'Indonesia', :code => 'ID' },
      { :name => 'Iran, Islamic Republic of', :code => 'IR' },
      { :name => 'Iraq', :code => 'IQ' },
      { :name => 'Ireland', :code => 'IE' },
      { :name => 'Israel', :code => 'IL' },
      { :name => 'Italy', :code => 'IT' },
      { :name => 'Jamaica', :code => 'JM' },
      { :name => 'Japan', :code => 'JP' },
      { :name => 'Jordan', :code => 'JO' },
      { :name => 'Kazakhstan', :code => 'KZ' },
      { :name => 'Kenya', :code => 'KE' },
      { :name => 'Kiribati', :code => 'KI' },
      { :name => 'Korea, Democratic People\'s Republic of', :code => 'KP' },
      { :name => 'Korea, Republic of', :code => 'KR' },
      { :name => 'Kuwait', :code => 'KW' },
      { :name => 'Kyrgyzstan', :code => 'KG' },
      { :name => 'Lao People\'s Democratic Republic', :code => 'LA' },
      { :name => 'Latvia', :code => 'LV' },
      { :name => 'Lebanon', :code => 'LB' },
      { :name => 'Lesotho', :code => 'LS' },
      { :name => 'Liberia', :code => 'LR' },
      { :name => 'Libyan Arab Jamahiriya', :code => 'LY' },
      { :name => 'Liechtenstein', :code => 'LI' },
      { :name => 'Lithuania', :code => 'LT' },
      { :name => 'Luxembourg', :code => 'LU' },
      { :name => 'Macao', :code => 'MO' },
      { :name => 'Macedonia, the Former Yugoslav Republic of', :code => 'MK' },
      { :name => 'Madagascar', :code => 'MG' },
      { :name => 'Malawi', :code => 'MW' },
      { :name => 'Malaysia', :code => 'MY' },
      { :name => 'Maldives', :code => 'MV' },
      { :name => 'Mali', :code => 'ML' },
      { :name => 'Malta', :code => 'MT' },
      { :name => 'Marshall Islands', :code => 'MH' },
      { :name => 'Martinique', :code => 'MQ' },
      { :name => 'Mauritania', :code => 'MR' },
      { :name => 'Mauritius', :code => 'MU' },
      { :name => 'Mayotte', :code => 'YT' },
      { :name => 'Mexico', :code => 'MX' },
      { :name => 'Micronesia, Federated States of', :code => 'FM' },
      { :name => 'Moldova, Republic of', :code => 'MD' },
      { :name => 'Monaco', :code => 'MC' },
      { :name => 'Mongolia', :code => 'MN' },
      { :name => 'Montserrat', :code => 'MS' },
      { :name => 'Morocco', :code => 'MA' },
      { :name => 'Mozambique', :code => 'MZ' },
      { :name => 'Myanmar', :code => 'MM' },
      { :name => 'Namibia', :code => 'NA' },
      { :name => 'Nauru', :code => 'NR' },
      { :name => 'Nepal', :code => 'NP' },
      { :name => 'Netherlands', :code => 'NL' },
      { :name => 'Netherlands Antilles', :code => 'AN' },
      { :name => 'New Caledonia', :code => 'NC' },
      { :name => 'New Zealand', :code => 'NZ' },
      { :name => 'Nicaragua', :code => 'NI' },
      { :name => 'Niger', :code => 'NE' },
      { :name => 'Nigeria', :code => 'NG' },
      { :name => 'Niue', :code => 'NU' },
      { :name => 'Norfolk Island', :code => 'NF' },
      { :name => 'Northern Mariana Islands', :code => 'MP' },
      { :name => 'Norway', :code => 'NO' },
      { :name => 'Oman', :code => 'OM' },
      { :name => 'Pakistan', :code => 'PK' },
      { :name => 'Palau', :code => 'PW' },
      { :name => 'Palestinian Territory, Occupied', :code => 'PS' },
      { :name => 'Panama', :code => 'PA' },
      { :name => 'Papua New Guinea', :code => 'PG' },
      { :name => 'Paraguay', :code => 'PY' },
      { :name => 'Peru', :code => 'PE' },
      { :name => 'Philippines', :code => 'PH' },
      { :name => 'Pitcairn', :code => 'PN' },
      { :name => 'Poland', :code => 'PL' },
      { :name => 'Portugal', :code => 'PT' },
      { :name => 'Puerto Rico', :code => 'PR' },
      { :name => 'Qatar', :code => 'QA' },
      { :name => 'Reunion', :code => 'RE' },
      { :name => 'Romania', :code => 'RO' },
      { :name => 'Russian Federation', :code => 'RU' },
      { :name => 'Rwanda', :code => 'RW' },
      { :name => 'Saint Helena', :code => 'SH' },
      { :name => 'Saint Kitts and Nevis', :code => 'KN' },
      { :name => 'Saint Lucia', :code => 'LC' },
      { :name => 'Saint Pierre and Miquelon', :code => 'PM' },
      { :name => 'Saint Vincent and the Grenadines', :code => 'VC' },
      { :name => 'Samoa', :code => 'WS' },
      { :name => 'San Marino', :code => 'SM' },
      { :name => 'Sao Tome and Principe', :code => 'ST' },
      { :name => 'Saudi Arabia', :code => 'SA' },
      { :name => 'Senegal', :code => 'SN' },
      { :name => 'Serbia and Montenegro', :code => 'CS' },
      { :name => 'Seychelles', :code => 'SC' },
      { :name => 'Sierra Leone', :code => 'SL' },
      { :name => 'Singapore', :code => 'SG' },
      { :name => 'Slovakia', :code => 'SK' },
      { :name => 'Slovenia', :code => 'SI' },
      { :name => 'Solomon Islands', :code => 'SB' },
      { :name => 'Somalia', :code => 'SO' },
      { :name => 'South Africa', :code => 'ZA' },
      { :name => 'South Georgia and the South Sandwich Islands', :code => 'GS' },
      { :name => 'Spain', :code => 'ES' },
      { :name => 'Sri Lanka', :code => 'LK' },
      { :name => 'Sudan', :code => 'SD' },
      { :name => 'Suriname', :code => 'SR' },
      { :name => 'Svalbard and Jan Mayen', :code => 'SJ' },
      { :name => 'Swaziland', :code => 'SZ' },
      { :name => 'Sweden', :code => 'SE' },
      { :name => 'Switzerland', :code => 'CH' },
      { :name => 'Syrian Arab Republic', :code => 'SY' },
      { :name => 'Taiwan, Province of China', :code => 'TW' },
      { :name => 'Tajikistan', :code => 'TJ' },
      { :name => 'Tanzania, United Republic of', :code => 'TZ' },
      { :name => 'Thailand', :code => 'TH' },
      { :name => 'Timor-Leste', :code => 'TL' },
      { :name => 'Togo', :code => 'TG' },
      { :name => 'Tokelau', :code => 'TK' },
      { :name => 'Tonga', :code => 'TO' },
      { :name => 'Trinidad and Tobago', :code => 'TT' },
      { :name => 'Tunisia', :code => 'TN' },
      { :name => 'Turkey', :code => 'TR' },
      { :name => 'Turkmenistan', :code => 'TM' },
      { :name => 'Turks and Caicos Islands', :code => 'TC' },
      { :name => 'Tuvalu', :code => 'TV' },
      { :name => 'Uganda', :code => 'UG' },
      { :name => 'Ukraine', :code => 'UA' },
      { :name => 'United Arab Emirates', :code => 'AE' },
      { :name => 'United Kingdom', :code => 'GB' },
      { :name => 'United States', :code => 'US' },
      { :name => 'United States Minor Outlying Islands', :code => 'UM' },
      { :name => 'Uruguay', :code => 'UY' },
      { :name => 'Uzbekistan', :code => 'UZ' },
      { :name => 'Vanuatu', :code => 'VU' },
      { :name => 'Venezuela', :code => 'VE' },
      { :name => 'Viet Nam', :code => 'VN' },
      { :name => 'Virgin Islands, British', :code => 'VG' },
      { :name => 'Virgin Islands, U.S.', :code => 'VI' },
      { :name => 'Wallis and Futuna', :code => 'WF' },
      { :name => 'Western Sahara', :code => 'EH' },
      { :name => 'Yemen', :code => 'YE' },
      { :name => 'Zambia', :code => 'ZM' },
      { :name => 'Zimbabwe', :code => 'ZW' }])
    
    create_table :timezones do |t|
      t.string :name, :null => false, :limit => 60
    end
    
    add_index :timezones, :name, :unique => true
    
    Timezone.create([
      { :name => 'Africa/Abidjan' },
      { :name => 'Africa/Accra' },
      { :name => 'Africa/Addis_Ababa' },
      { :name => 'Africa/Algiers' },
      { :name => 'Africa/Asmera' },
      { :name => 'Africa/Bamako' },
      { :name => 'Africa/Bangui' },
      { :name => 'Africa/Banjul' },
      { :name => 'Africa/Bissau' },
      { :name => 'Africa/Blantyre' },
      { :name => 'Africa/Brazzaville' },
      { :name => 'Africa/Bujumbura' },
      { :name => 'Africa/Cairo' },
      { :name => 'Africa/Casablanca' },
      { :name => 'Africa/Ceuta' },
      { :name => 'Africa/Conakry' },
      { :name => 'Africa/Dakar' },
      { :name => 'Africa/Dar_es_Salaam' },
      { :name => 'Africa/Djibouti' },
      { :name => 'Africa/Douala' },
      { :name => 'Africa/El_Aaiun' },
      { :name => 'Africa/Freetown' },
      { :name => 'Africa/Gaborone' },
      { :name => 'Africa/Harare' },
      { :name => 'Africa/Johannesburg' },
      { :name => 'Africa/Kampala' },
      { :name => 'Africa/Khartoum' },
      { :name => 'Africa/Kigali' },
      { :name => 'Africa/Kinshasa' },
      { :name => 'Africa/Lagos' },
      { :name => 'Africa/Libreville' },
      { :name => 'Africa/Lome' },
      { :name => 'Africa/Luanda' },
      { :name => 'Africa/Lubumbashi' },
      { :name => 'Africa/Lusaka' },
      { :name => 'Africa/Malabo' },
      { :name => 'Africa/Maputo' },
      { :name => 'Africa/Maseru' },
      { :name => 'Africa/Mbabane' },
      { :name => 'Africa/Mogadishu' },
      { :name => 'Africa/Monrovia' },
      { :name => 'Africa/Nairobi' },
      { :name => 'Africa/Ndjamena' },
      { :name => 'Africa/Niamey' },
      { :name => 'Africa/Nouakchott' },
      { :name => 'Africa/Ouagadougou' },
      { :name => 'Africa/Porto' },
      { :name => 'Africa/Sao_Tome' },
      { :name => 'Africa/Tripoli' },
      { :name => 'Africa/Tunis' },
      { :name => 'Africa/Windhoek' },
      { :name => 'America/Adak' },
      { :name => 'America/Anchorage' },
      { :name => 'America/Anguilla' },
      { :name => 'America/Antigua' },
      { :name => 'America/Araguaina' },
      { :name => 'America/Argentina/Buenos_Aires' },
      { :name => 'America/Argentina/Catamarca' },
      { :name => 'America/Argentina/Cordoba' },
      { :name => 'America/Argentina/Jujuy' },
      { :name => 'America/Argentina/La_Rioja' },
      { :name => 'America/Argentina/Mendoza' },
      { :name => 'America/Argentina/Rio_Gallegos' },
      { :name => 'America/Argentina/San_Juan' },
      { :name => 'America/Argentina/Tucuman' },
      { :name => 'America/Argentina/Ushuaia' },
      { :name => 'America/Aruba' },
      { :name => 'America/Asuncion' },
      { :name => 'America/Bahia' },
      { :name => 'America/Barbados' },
      { :name => 'America/Belem' },
      { :name => 'America/Belize' },
      { :name => 'America/Boa_Vista' },
      { :name => 'America/Bogota' },
      { :name => 'America/Boise' },
      { :name => 'America/Cambridge_Bay' },
      { :name => 'America/Campo_Grande' },
      { :name => 'America/Cancun' },
      { :name => 'America/Caracas' },
      { :name => 'America/Cayenne' },
      { :name => 'America/Cayman' },
      { :name => 'America/Chicago' },
      { :name => 'America/Chihuahua' },
      { :name => 'America/Coral_Harbour' },
      { :name => 'America/Costa_Rica' },
      { :name => 'America/Cuiaba' },
      { :name => 'America/Curacao' },
      { :name => 'America/Danmarkshavn' },
      { :name => 'America/Dawson' },
      { :name => 'America/Dawson_Creek' },
      { :name => 'America/Denver' },
      { :name => 'America/Detroit' },
      { :name => 'America/Dominica' },
      { :name => 'America/Edmonton' },
      { :name => 'America/Eirunepe' },
      { :name => 'America/El_Salvador' },
      { :name => 'America/Fortaleza' },
      { :name => 'America/Glace_Bay' },
      { :name => 'America/Godthab' },
      { :name => 'America/Goose_Bay' },
      { :name => 'America/Grand_Turk' },
      { :name => 'America/Grenada' },
      { :name => 'America/Guadeloupe' },
      { :name => 'America/Guatemala' },
      { :name => 'America/Guayaquil' },
      { :name => 'America/Guyana' },
      { :name => 'America/Halifax' },
      { :name => 'America/Havana' },
      { :name => 'America/Hermosillo' },
      { :name => 'America/Indiana/Indianapolis' },
      { :name => 'America/Indiana/Knox' },
      { :name => 'America/Indiana/Marengo' },
      { :name => 'America/Indiana/Petersburg' },
      { :name => 'America/Indiana/Vevay' },
      { :name => 'America/Indiana/Vincennes' },
      { :name => 'America/Inuvik' },
      { :name => 'America/Iqaluit' },
      { :name => 'America/Jamaica' },
      { :name => 'America/Juneau' },
      { :name => 'America/Kentucky/Louisville' },
      { :name => 'America/Kentucky/Monticello' },
      { :name => 'America/La_Paz' },
      { :name => 'America/Lima' },
      { :name => 'America/Los_Angeles' },
      { :name => 'America/Maceio' },
      { :name => 'America/Managua' },
      { :name => 'America/Manaus' },
      { :name => 'America/Martinique' },
      { :name => 'America/Mazatlan' },
      { :name => 'America/Menominee' },
      { :name => 'America/Merida' },
      { :name => 'America/Mexico_City' },
      { :name => 'America/Miquelon' },
      { :name => 'America/Moncton' },
      { :name => 'America/Monterrey' },
      { :name => 'America/Montevideo' },
      { :name => 'America/Montreal' },
      { :name => 'America/Montserrat' },
      { :name => 'America/Nassau' },
      { :name => 'America/New_York' },
      { :name => 'America/Nipigon' },
      { :name => 'America/Nome' },
      { :name => 'America/Noronha' },
      { :name => 'America/North_Dakota/Center' },
      { :name => 'America/Panama' },
      { :name => 'America/Pangnirtung' },
      { :name => 'America/Paramaribo' },
      { :name => 'America/Phoenix' },
      { :name => 'America/Port' },
      { :name => 'America/Port_of_Spain' },
      { :name => 'America/Porto_Velho' },
      { :name => 'America/Puerto_Rico' },
      { :name => 'America/Rainy_River' },
      { :name => 'America/Rankin_Inlet' },
      { :name => 'America/Recife' },
      { :name => 'America/Regina' },
      { :name => 'America/Rio_Branco' },
      { :name => 'America/Santiago' },
      { :name => 'America/Santo_Domingo' },
      { :name => 'America/Sao_Paulo' },
      { :name => 'America/Scoresbysund' },
      { :name => 'America/Shiprock' },
      { :name => 'America/St_Johns' },
      { :name => 'America/St_Kitts' },
      { :name => 'America/St_Lucia' },
      { :name => 'America/St_Thomas' },
      { :name => 'America/St_Vincent' },
      { :name => 'America/Swift_Current' },
      { :name => 'America/Tegucigalpa' },
      { :name => 'America/Thule' },
      { :name => 'America/Thunder_Bay' },
      { :name => 'America/Tijuana' },
      { :name => 'America/Toronto' },
      { :name => 'America/Tortola' },
      { :name => 'America/Vancouver' },
      { :name => 'America/Whitehorse' },
      { :name => 'America/Winnipeg' },
      { :name => 'America/Yakutat' },
      { :name => 'America/Yellowknife' },
      { :name => 'Antarctica/Casey' },
      { :name => 'Antarctica/Davis' },
      { :name => 'Antarctica/DumontDUrville' },
      { :name => 'Antarctica/Mawson' },
      { :name => 'Antarctica/McMurdo' },
      { :name => 'Antarctica/Palmer' },
      { :name => 'Antarctica/Rothera' },
      { :name => 'Antarctica/South_Pole' },
      { :name => 'Antarctica/Syowa' },
      { :name => 'Antarctica/Vostok' },
      { :name => 'Arctic/Longyearbyen' },
      { :name => 'Asia/Aden' },
      { :name => 'Asia/Almaty' },
      { :name => 'Asia/Amman' },
      { :name => 'Asia/Anadyr' },
      { :name => 'Asia/Aqtau' },
      { :name => 'Asia/Aqtobe' },
      { :name => 'Asia/Ashgabat' },
      { :name => 'Asia/Baghdad' },
      { :name => 'Asia/Bahrain' },
      { :name => 'Asia/Baku' },
      { :name => 'Asia/Bangkok' },
      { :name => 'Asia/Beirut' },
      { :name => 'Asia/Bishkek' },
      { :name => 'Asia/Brunei' },
      { :name => 'Asia/Calcutta' },
      { :name => 'Asia/Choibalsan' },
      { :name => 'Asia/Chongqing' },
      { :name => 'Asia/Colombo' },
      { :name => 'Asia/Damascus' },
      { :name => 'Asia/Dhaka' },
      { :name => 'Asia/Dili' },
      { :name => 'Asia/Dubai' },
      { :name => 'Asia/Dushanbe' },
      { :name => 'Asia/Gaza' },
      { :name => 'Asia/Harbin' },
      { :name => 'Asia/Hong_Kong' },
      { :name => 'Asia/Hovd' },
      { :name => 'Asia/Irkutsk' },
      { :name => 'Asia/Jakarta' },
      { :name => 'Asia/Jayapura' },
      { :name => 'Asia/Jerusalem' },
      { :name => 'Asia/Kabul' },
      { :name => 'Asia/Kamchatka' },
      { :name => 'Asia/Karachi' },
      { :name => 'Asia/Kashgar' },
      { :name => 'Asia/Katmandu' },
      { :name => 'Asia/Krasnoyarsk' },
      { :name => 'Asia/Kuala_Lumpur' },
      { :name => 'Asia/Kuching' },
      { :name => 'Asia/Kuwait' },
      { :name => 'Asia/Macau' },
      { :name => 'Asia/Magadan' },
      { :name => 'Asia/Makassar' },
      { :name => 'Asia/Manila' },
      { :name => 'Asia/Muscat' },
      { :name => 'Asia/Nicosia' },
      { :name => 'Asia/Novosibirsk' },
      { :name => 'Asia/Omsk' },
      { :name => 'Asia/Oral' },
      { :name => 'Asia/Phnom_Penh' },
      { :name => 'Asia/Pontianak' },
      { :name => 'Asia/Pyongyang' },
      { :name => 'Asia/Qatar' },
      { :name => 'Asia/Qyzylorda' },
      { :name => 'Asia/Rangoon' },
      { :name => 'Asia/Riyadh' },
      { :name => 'Asia/Saigon' },
      { :name => 'Asia/Sakhalin' },
      { :name => 'Asia/Samarkand' },
      { :name => 'Asia/Seoul' },
      { :name => 'Asia/Shanghai' },
      { :name => 'Asia/Singapore' },
      { :name => 'Asia/Taipei' },
      { :name => 'Asia/Tashkent' },
      { :name => 'Asia/Tbilisi' },
      { :name => 'Asia/Tehran' },
      { :name => 'Asia/Thimphu' },
      { :name => 'Asia/Tokyo' },
      { :name => 'Asia/Ulaanbaatar' },
      { :name => 'Asia/Urumqi' },
      { :name => 'Asia/Vientiane' },
      { :name => 'Asia/Vladivostok' },
      { :name => 'Asia/Yakutsk' },
      { :name => 'Asia/Yekaterinburg' },
      { :name => 'Asia/Yerevan' },
      { :name => 'Atlantic/Azores' },
      { :name => 'Atlantic/Bermuda' },
      { :name => 'Atlantic/Canary' },
      { :name => 'Atlantic/Cape_Verde' },
      { :name => 'Atlantic/Faeroe' },
      { :name => 'Atlantic/Jan_Mayen' },
      { :name => 'Atlantic/Madeira' },
      { :name => 'Atlantic/Reykjavik' },
      { :name => 'Atlantic/South_Georgia' },
      { :name => 'Atlantic/St_Helena' },
      { :name => 'Atlantic/Stanley' },
      { :name => 'Australia/Adelaide' },
      { :name => 'Australia/Brisbane' },
      { :name => 'Australia/Broken_Hill' },
      { :name => 'Australia/Currie' },
      { :name => 'Australia/Darwin' },
      { :name => 'Australia/Hobart' },
      { :name => 'Australia/Lindeman' },
      { :name => 'Australia/Lord_Howe' },
      { :name => 'Australia/Melbourne' },
      { :name => 'Australia/Perth' },
      { :name => 'Australia/Sydney' },
      { :name => 'Europe/Amsterdam' },
      { :name => 'Europe/Andorra' },
      { :name => 'Europe/Athens' },
      { :name => 'Europe/Belgrade' },
      { :name => 'Europe/Berlin' },
      { :name => 'Europe/Bratislava' },
      { :name => 'Europe/Brussels' },
      { :name => 'Europe/Bucharest' },
      { :name => 'Europe/Budapest' },
      { :name => 'Europe/Chisinau' },
      { :name => 'Europe/Copenhagen' },
      { :name => 'Europe/Dublin' },
      { :name => 'Europe/Gibraltar' },
      { :name => 'Europe/Helsinki' },
      { :name => 'Europe/Istanbul' },
      { :name => 'Europe/Kaliningrad' },
      { :name => 'Europe/Kiev' },
      { :name => 'Europe/Lisbon' },
      { :name => 'Europe/Ljubljana' },
      { :name => 'Europe/London' },
      { :name => 'Europe/Luxembourg' },
      { :name => 'Europe/Madrid' },
      { :name => 'Europe/Malta' },
      { :name => 'Europe/Mariehamn' },
      { :name => 'Europe/Minsk' },
      { :name => 'Europe/Monaco' },
      { :name => 'Europe/Moscow' },
      { :name => 'Europe/Oslo' },
      { :name => 'Europe/Paris' },
      { :name => 'Europe/Prague' },
      { :name => 'Europe/Riga' },
      { :name => 'Europe/Rome' },
      { :name => 'Europe/Samara' },
      { :name => 'Europe/San_Marino' },
      { :name => 'Europe/Sarajevo' },
      { :name => 'Europe/Simferopol' },
      { :name => 'Europe/Skopje' },
      { :name => 'Europe/Sofia' },
      { :name => 'Europe/Stockholm' },
      { :name => 'Europe/Tallinn' },
      { :name => 'Europe/Tirane' },
      { :name => 'Europe/Uzhgorod' },
      { :name => 'Europe/Vaduz' },
      { :name => 'Europe/Vatican' },
      { :name => 'Europe/Vienna' },
      { :name => 'Europe/Vilnius' },
      { :name => 'Europe/Warsaw' },
      { :name => 'Europe/Zagreb' },
      { :name => 'Europe/Zaporozhye' },
      { :name => 'Europe/Zurich' },
      { :name => 'Indian/Antananarivo' },
      { :name => 'Indian/Chagos' },
      { :name => 'Indian/Christmas' },
      { :name => 'Indian/Cocos' },
      { :name => 'Indian/Comoro' },
      { :name => 'Indian/Kerguelen' },
      { :name => 'Indian/Mahe' },
      { :name => 'Indian/Maldives' },
      { :name => 'Indian/Mauritius' },
      { :name => 'Indian/Mayotte' },
      { :name => 'Indian/Reunion' },
      { :name => 'Pacific/Apia' },
      { :name => 'Pacific/Auckland' },
      { :name => 'Pacific/Chatham' },
      { :name => 'Pacific/Easter' },
      { :name => 'Pacific/Efate' },
      { :name => 'Pacific/Enderbury' },
      { :name => 'Pacific/Fakaofo' },
      { :name => 'Pacific/Fiji' },
      { :name => 'Pacific/Funafuti' },
      { :name => 'Pacific/Galapagos' },
      { :name => 'Pacific/Gambier' },
      { :name => 'Pacific/Guadalcanal' },
      { :name => 'Pacific/Guam' },
      { :name => 'Pacific/Honolulu' },
      { :name => 'Pacific/Johnston' },
      { :name => 'Pacific/Kiritimati' },
      { :name => 'Pacific/Kosrae' },
      { :name => 'Pacific/Kwajalein' },
      { :name => 'Pacific/Majuro' },
      { :name => 'Pacific/Marquesas' },
      { :name => 'Pacific/Midway' },
      { :name => 'Pacific/Nauru' },
      { :name => 'Pacific/Niue' },
      { :name => 'Pacific/Norfolk' },
      { :name => 'Pacific/Noumea' },
      { :name => 'Pacific/Pago_Pago' },
      { :name => 'Pacific/Palau' },
      { :name => 'Pacific/Pitcairn' },
      { :name => 'Pacific/Ponape' },
      { :name => 'Pacific/Port_Moresby' },
      { :name => 'Pacific/Rarotonga' },
      { :name => 'Pacific/Saipan' },
      { :name => 'Pacific/Tahiti' },
      { :name => 'Pacific/Tarawa' },
      { :name => 'Pacific/Tongatapu' },
      { :name => 'Pacific/Truk' },
      { :name => 'Pacific/Wake' },
      { :name => 'Pacific/Wallis' }])
      
    create_table :languages do |t|
      t.string :name, :null => false, :limit => 60
      t.string :code, :null => false, :limit => 5
    end

    Language.create([
      { :name => 'Abkhazian', :code => 'AB' },
      { :name => 'Afar', :code => 'AA' },
      { :name => 'Afrikaans', :code => 'AF' },
      { :name => 'Albanian', :code => 'SQ' },
      { :name => 'Amharic', :code => 'AM' },
      { :name => 'Arabic', :code => 'AR' },
      { :name => 'Armenian', :code => 'HY' },
      { :name => 'Assamese', :code => 'AS' },
      { :name => 'Aymara', :code => 'AY' },
      { :name => 'Azerbaijani', :code => 'AZ' },
      { :name => 'Bashkir', :code => 'BA' },
      { :name => 'Basque', :code => 'EU' },
      { :name => 'Bengali', :code => 'BN' },
      { :name => 'Bhutani', :code => 'DZ' },
      { :name => 'Bihari', :code => 'BH' },
      { :name => 'Bislama', :code => 'BI' },
      { :name => 'Breton', :code => 'BR' },
      { :name => 'Bulgarian', :code => 'BG' },
      { :name => 'Burmese', :code => 'MY' },
      { :name => 'Byelorussian', :code => 'BE' },
      { :name => 'Cambodian', :code => 'KM' },
      { :name => 'Catalan', :code => 'CA' },
      { :name => 'Chinese (traditional)', :code => 'ZH_TW' },
      { :name => 'Chinese (simplified)', :code => 'ZH_CN' },
      { :name => 'Corsican', :code => 'CO' },
      { :name => 'Croatian', :code => 'HR' },
      { :name => 'Czech', :code => 'CS' },
      { :name => 'Danish', :code => 'DA' },
      { :name => 'Dutch', :code => 'NL' },
      { :name => 'English', :code => 'EN' },
      { :name => 'Esperanto', :code => 'EO' },
      { :name => 'Estonian', :code => 'ET' },
      { :name => 'Faeroese', :code => 'FO' },
      { :name => 'Fiji', :code => 'FJ' },
      { :name => 'Finnish', :code => 'FI' },
      { :name => 'French', :code => 'FR' },
      { :name => 'Frisian', :code => 'FY' },
      { :name => 'Gaelic', :code => 'GD' },
      { :name => 'Galician', :code => 'GL' },
      { :name => 'Georgian', :code => 'KA' },
      { :name => 'German', :code => 'DE' },
      { :name => 'Greek', :code => 'EL' },
      { :name => 'Greenlandic', :code => 'KL' },
      { :name => 'Guarani', :code => 'GN' },
      { :name => 'Gujarati', :code => 'GU' },
      { :name => 'Hausa', :code => 'HA' },
      { :name => 'Hebrew', :code => 'IW' },
      { :name => 'Hindi', :code => 'HI' },
      { :name => 'Hungarian', :code => 'HU' },
      { :name => 'Icelandic', :code => 'IS' },
      { :name => 'Indonesian', :code => 'IN' },
      { :name => 'Interlingua', :code => 'IA' },
      { :name => 'Interlingue', :code => 'IE' },
      { :name => 'Inupiak', :code => 'IK' },
      { :name => 'Irish', :code => 'GA' },
      { :name => 'Italian', :code => 'IT' },
      { :name => 'Japanese', :code => 'JA' },
      { :name => 'Javanese', :code => 'JW' },
      { :name => 'Kannada', :code => 'KN' },
      { :name => 'Kashmiri', :code => 'KS' },
      { :name => 'Kazakh', :code => 'KK' },
      { :name => 'Kinyarwanda', :code => 'RW' },
      { :name => 'Kirghiz', :code => 'KY' },
      { :name => 'Kirundi', :code => 'RN' },
      { :name => 'Korean', :code => 'KO' },
      { :name => 'Kurdish', :code => 'KU' },
      { :name => 'Laothian', :code => 'LO' },
      { :name => 'Latin', :code => 'LA' },
      { :name => 'Latvian', :code => 'LV' },
      { :name => 'Lingala', :code => 'LN' },
      { :name => 'Lithuanian', :code => 'LT' },
      { :name => 'Macedonian', :code => 'MK' },
      { :name => 'Malagasy', :code => 'MG' },
      { :name => 'Malay', :code => 'MS' },
      { :name => 'Malayalam', :code => 'ML' },
      { :name => 'Maltese', :code => 'MT' },
      { :name => 'Maori', :code => 'MI' },
      { :name => 'Marathi', :code => 'MR' },
      { :name => 'Moldavian', :code => 'MO' },
      { :name => 'Mongolian', :code => 'MN' },
      { :name => 'Nauru', :code => 'NA' },
      { :name => 'Nepali', :code => 'NE' },
      { :name => 'Norwegian', :code => 'NO' },
      { :name => 'Occitan', :code => 'OC' },
      { :name => 'Oriya', :code => 'OR' },
      { :name => 'Oromo', :code => 'OM' },
      { :name => 'Pashto', :code => 'PS' },
      { :name => 'Persian', :code => 'FA' },
      { :name => 'Polish', :code => 'PL' },
      { :name => 'Portuguese', :code => 'PT' },
      { :name => 'Português (Brasil)', :code => 'PT_BR' },
      { :name => 'Punjabi', :code => 'PA' },
      { :name => 'Quechua', :code => 'QU' },
      { :name => 'Rhaeto-Romance', :code => 'RM' },
      { :name => 'Romanian', :code => 'RO' },
      { :name => 'Russian', :code => 'RU' },
      { :name => 'Samoan', :code => 'SM' },
      { :name => 'Sangro', :code => 'SG' },
      { :name => 'Sanskrit', :code => 'SA' },
      { :name => 'Serbian', :code => 'SR' },
      { :name => 'Serbo-Croatian', :code => 'SH' },
      { :name => 'Sesotho', :code => 'ST' },
      { :name => 'Setswana', :code => 'TN' },
      { :name => 'Shona', :code => 'SN' },
      { :name => 'Sindhi', :code => 'SD' },
      { :name => 'Singhalese', :code => 'SI' },
      { :name => 'Siswati', :code => 'SS' },
      { :name => 'Slovak', :code => 'SK' },
      { :name => 'Slovenian', :code => 'SL' },
      { :name => 'Somali', :code => 'SO' },
      { :name => 'Spanish', :code => 'ES' },
      { :name => 'Sudanese', :code => 'SU' },
      { :name => 'Swahili', :code => 'SW' },
      { :name => 'Swedish', :code => 'SV' },
      { :name => 'Tagalog', :code => 'TL' },
      { :name => 'Tajik', :code => 'TG' },
      { :name => 'Tamil', :code => 'TA' },
      { :name => 'Tatar', :code => 'TT' },
      { :name => 'Telugu', :code => 'TE' },
      { :name => 'Thai', :code => 'TH' },
      { :name => 'Tibetan', :code => 'BO' },
      { :name => 'Tigrinya', :code => 'TI' },
      { :name => 'Tonga', :code => 'TO' },
      { :name => 'Tsonga', :code => 'TS' },
      { :name => 'Turkish', :code => 'TR' },
      { :name => 'Turkmen', :code => 'TK' },
      { :name => 'Twi', :code => 'TW' },
      { :name => 'Ukrainian', :code => 'UK' },
      { :name => 'Urdu', :code => 'UR' },
      { :name => 'Uzbek', :code => 'UZ' },
      { :name => 'Vietnamese', :code => 'VI' },
      { :name => 'Volapuk', :code => 'VO' },
      { :name => 'Welsh', :code => 'CY' },
      { :name => 'Wolof', :code => 'WO' },
      { :name => 'Xhosa', :code => 'XH' },
      { :name => 'Yiddish', :code => 'JI' },
      { :name => 'Yoruba', :code => 'YO' },
      { :name => 'Zulu', :code => 'ZU' }])
  end
  
  def self.down
    drop_table :accounts
    drop_table :countries
    drop_table :languages
    drop_table :open_id_associations
    drop_table :open_id_nonces
    drop_table :open_id_requests
    drop_table :personas
    drop_table :release_policies
    drop_table :sites
    drop_table :timezones
  end
end
