|
| 1 | +from django.db import migrations, models |
| 2 | + |
| 3 | +CURRENCIES = [ |
| 4 | + ("AED", "United Arab Emirates dirham", False), |
| 5 | + ("AFN", "Afghan afghani", False), |
| 6 | + ("ALL", "Albanian lek", False), |
| 7 | + ("AMD", "Armenian dram", False), |
| 8 | + ("ANG", "Netherlands Antillean guilder", False), |
| 9 | + ("AOA", "Angolan kwanza", False), |
| 10 | + ("ARS", "Argentine peso", False), |
| 11 | + ("AUD", "Australian dollar", False), |
| 12 | + ("AWG", "Aruban florin", False), |
| 13 | + ("AZN", "Azerbaijani manat", False), |
| 14 | + ("BAM", "Bosnia and Herzegovina convertible mark", False), |
| 15 | + ("BBD", "Barbados dollar", False), |
| 16 | + ("BDT", "Bangladeshi taka", False), |
| 17 | + ("BGN", "Bulgarian lev", False), |
| 18 | + ("BHD", "Bahraini dinar", False), |
| 19 | + ("BIF", "Burundian franc", False), |
| 20 | + ("BMD", "Bermudian dollar", False), |
| 21 | + ("BND", "Brunei dollar", False), |
| 22 | + ("BOB", "Boliviano", False), |
| 23 | + ("BOV", "Bolivian Mvdol (funds code)", False), |
| 24 | + ("BRL", "Brazilian real", False), |
| 25 | + ("BSD", "Bahamian dollar", False), |
| 26 | + ("BTN", "Bhutanese ngultrum", False), |
| 27 | + ("BWP", "Botswana pula", False), |
| 28 | + ("BYN", "Belarusian ruble", False), |
| 29 | + ("BZD", "Belize dollar", False), |
| 30 | + ("CAD", "Canadian dollar", False), |
| 31 | + ("CDF", "Congolese franc", False), |
| 32 | + ("CHF", "Swiss franc", False), |
| 33 | + ("CLP", "Chilean peso", False), |
| 34 | + ("CNY", "Chinese yuan", False), |
| 35 | + ("COP", "Colombian peso", False), |
| 36 | + ("CRC", "Costa Rican colon", False), |
| 37 | + ("CUC", "Cuban convertible peso", False), |
| 38 | + ("CUP", "Cuban peso", False), |
| 39 | + ("CVE", "Cape Verdean escudo", False), |
| 40 | + ("CZK", "Czech koruna", False), |
| 41 | + ("DJF", "Djiboutian franc", False), |
| 42 | + ("DKK", "Danish krone", False), |
| 43 | + ("DOP", "Dominican peso", False), |
| 44 | + ("DZD", "Algerian dinar", False), |
| 45 | + ("EGP", "Egyptian pound", False), |
| 46 | + ("ERN", "Eritrean nakfa", False), |
| 47 | + ("ETB", "Ethiopian birr", False), |
| 48 | + ("EUR", "Euro", False), |
| 49 | + ("FJD", "Fiji dollar", False), |
| 50 | + ("FKP", "Falkland Islands pound", False), |
| 51 | + ("GBP", "Pound sterling", False), |
| 52 | + ("GEL", "Georgian lari", False), |
| 53 | + ("GHS", "Ghanaian cedi", False), |
| 54 | + ("GIP", "Gibraltar pound", False), |
| 55 | + ("GMD", "Gambian dalasi", False), |
| 56 | + ("GNF", "Guinean franc", False), |
| 57 | + ("GTQ", "Guatemalan quetzal", False), |
| 58 | + ("GYD", "Guyanese dollar", False), |
| 59 | + ("HKD", "Hong Kong dollar", False), |
| 60 | + ("HNL", "Honduran lempira", False), |
| 61 | + ("HRK", "Croatian kuna", False), |
| 62 | + ("HTG", "Haitian gourde", False), |
| 63 | + ("HUF", "Hungarian forint", False), |
| 64 | + ("IDR", "Indonesian rupiah", False), |
| 65 | + ("ILS", "Israeli new shekel", False), |
| 66 | + ("INR", "Indian rupee", False), |
| 67 | + ("IQD", "Iraqi dinar", False), |
| 68 | + ("IRR", "Iranian rial", False), |
| 69 | + ("ISK", "Icelandic króna", False), |
| 70 | + ("JMD", "Jamaican dollar", False), |
| 71 | + ("JOD", "Jordanian dinar", False), |
| 72 | + ("JPY", "Japanese yen", False), |
| 73 | + ("KES", "Kenyan shilling", False), |
| 74 | + ("KGS", "Kyrgyzstani som", False), |
| 75 | + ("KHR", "Cambodian riel", False), |
| 76 | + ("KMF", "Comoro franc", False), |
| 77 | + ("KPW", "North Korean won", False), |
| 78 | + ("KRW", "South Korean won", False), |
| 79 | + ("KWD", "Kuwaiti dinar", False), |
| 80 | + ("KYD", "Cayman Islands dollar", False), |
| 81 | + ("KZT", "Kazakhstani tenge", False), |
| 82 | + ("LAK", "Lao kip", False), |
| 83 | + ("LBP", "Lebanese pound", False), |
| 84 | + ("LKR", "Sri Lankan rupee", False), |
| 85 | + ("LRD", "Liberian dollar", False), |
| 86 | + ("LSL", "Lesotho loti", False), |
| 87 | + ("LYD", "Libyan dinar", False), |
| 88 | + ("MAD", "Moroccan dirham", False), |
| 89 | + ("MDL", "Moldovan leu", False), |
| 90 | + ("MGA", "Malagasy ariary", False), |
| 91 | + ("MKD", "Macedonian denar", False), |
| 92 | + ("MMK", "Myanmar kyat", False), |
| 93 | + ("MNT", "Mongolian tögrög", False), |
| 94 | + ("MOP", "Macanese pataca", False), |
| 95 | + ("MRU", "Mauritanian ouguiya", False), |
| 96 | + ("MUR", "Mauritian rupee", False), |
| 97 | + ("MVR", "Maldivian rufiyaa", False), |
| 98 | + ("MWK", "Malawian kwacha", False), |
| 99 | + ("MXN", "Mexican peso", False), |
| 100 | + ("MYR", "Malaysian ringgit", False), |
| 101 | + ("MZN", "Mozambican metical", False), |
| 102 | + ("NAD", "Namibian dollar", False), |
| 103 | + ("NGN", "Nigerian naira", False), |
| 104 | + ("NIO", "Nicaraguan córdoba", False), |
| 105 | + ("NOK", "Norwegian krone", False), |
| 106 | + ("NPR", "Nepalese rupee", False), |
| 107 | + ("NZD", "New Zealand dollar", False), |
| 108 | + ("OMR", "Omani rial", False), |
| 109 | + ("PAB", "Panamanian balboa", False), |
| 110 | + ("PEN", "Peruvian sol", False), |
| 111 | + ("PGK", "Papua New Guinean kina", False), |
| 112 | + ("PHP", "Philippine peso", False), |
| 113 | + ("PKR", "Pakistani rupee", False), |
| 114 | + ("PLN", "Polish złoty", False), |
| 115 | + ("PYG", "Paraguayan guaraní", False), |
| 116 | + ("QAR", "Qatari riyal", False), |
| 117 | + ("RON", "Romanian leu", False), |
| 118 | + ("RSD", "Serbian dinar", False), |
| 119 | + ("RUB", "Russian ruble", False), |
| 120 | + ("RWF", "Rwandan franc", False), |
| 121 | + ("SAR", "Saudi riyal", False), |
| 122 | + ("SBD", "Solomon Islands dollar", False), |
| 123 | + ("SCR", "Seychelles rupee", False), |
| 124 | + ("SDG", "Sudanese pound", False), |
| 125 | + ("SEK", "Swedish krona/kronor", False), |
| 126 | + ("SGD", "Singapore dollar", False), |
| 127 | + ("SHP", "Saint Helena pound", False), |
| 128 | + ("SLE", "Sierra Leonean leone", False), |
| 129 | + ("SOS", "Somali shilling", False), |
| 130 | + ("SRD", "Surinamese dollar", False), |
| 131 | + ("SSP", "South Sudanese pound", False), |
| 132 | + ("STN", "São Tomé and Príncipe dobra", False), |
| 133 | + ("SVC", "Salvadoran colón", False), |
| 134 | + ("SYP", "Syrian pound Old", False), |
| 135 | + ("SYP01", "Syrian pound", False), |
| 136 | + ("SZL", "Swazi lilangeni", False), |
| 137 | + ("THB", "Thai baht", False), |
| 138 | + ("TJS", "Tajikistani somoni", False), |
| 139 | + ("TMT", "Turkmenistan manat", False), |
| 140 | + ("TND", "Tunisian dinar", False), |
| 141 | + ("TOP", "Tongan paʻanga", False), |
| 142 | + ("TRY", "Turkish lira", False), |
| 143 | + ("TTD", "Trinidad and Tobago dollar", False), |
| 144 | + ("TWD", "New Taiwan dollar", False), |
| 145 | + ("TZS", "Tanzanian shilling", False), |
| 146 | + ("UAH", "Ukrainian hryvnia", False), |
| 147 | + ("UGX", "Ugandan shilling", False), |
| 148 | + ("USD", "United States dollar", False), |
| 149 | + ("USDC", "USD Coin", True), |
| 150 | + ("UYU", "Uruguayan peso", False), |
| 151 | + ("UYW", "Unidad previsional[14]", False), |
| 152 | + ("UZS", "Uzbekistan som", False), |
| 153 | + ("VES", "Venezuelan bolívar soberano", False), |
| 154 | + ("VND", "Vietnamese đồng", False), |
| 155 | + ("VUV", "Vanuatu vatu", False), |
| 156 | + ("WST", "Samoan tala", False), |
| 157 | + ("XAF", "CFA franc BEAC", False), |
| 158 | + ("XAG", "Silver (one troy ounce)", False), |
| 159 | + ("XAU", "Gold (one troy ounce)", False), |
| 160 | + ("XCD", "East Caribbean dollar", False), |
| 161 | + ("XOF", "CFA franc BCEAO", False), |
| 162 | + ("XPF", "CFP franc (franc Pacifique)", False), |
| 163 | + ("YER", "Yemeni rial", False), |
| 164 | + ("ZAR", "South African rand", False), |
| 165 | + ("ZMW", "Zambian kwacha", False), |
| 166 | + ("ZWL", "Zimbabwean dollar", False), |
| 167 | +] |
| 168 | + |
| 169 | + |
| 170 | +def seed_currencies(apps, schema_editor): |
| 171 | + Currency = apps.get_model("core", "Currency") |
| 172 | + currencies = [Currency(code=code, name=name, is_crypto=is_crypto) for code, name, is_crypto in CURRENCIES] |
| 173 | + Currency.objects.bulk_create(currencies) |
| 174 | + |
| 175 | + |
| 176 | +def reverse_seed(apps, schema_editor): |
| 177 | + Currency = apps.get_model("core", "Currency") |
| 178 | + Currency.objects.all().delete() |
| 179 | + |
| 180 | + |
| 181 | +class Migration(migrations.Migration): |
| 182 | + dependencies = [ |
| 183 | + ("core", "0017_migration"), |
| 184 | + ] |
| 185 | + |
| 186 | + operations = [ |
| 187 | + migrations.CreateModel( |
| 188 | + name="Currency", |
| 189 | + fields=[ |
| 190 | + ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")), |
| 191 | + ("code", models.CharField(db_index=True, max_length=5, unique=True)), |
| 192 | + ("name", models.CharField(max_length=255)), |
| 193 | + ( |
| 194 | + "is_crypto", |
| 195 | + models.BooleanField(default=False, help_text="Whether this is a cryptocurrency (e.g. USDC)"), |
| 196 | + ), |
| 197 | + ], |
| 198 | + options={ |
| 199 | + "ordering": ["code"], |
| 200 | + "verbose_name_plural": "currencies", |
| 201 | + }, |
| 202 | + ), |
| 203 | + migrations.RunPython(seed_currencies, reverse_seed), |
| 204 | + ] |
0 commit comments