I was just checking on a few translated exam questions when I realised that all translated cards from all languages seem to have been wiped. Was this intentional? Can it be restored? We (the tranlations projects) did put a lot of effort into making sure the exam questions and all related cards are translated…
Oh, I know what happened. I’ll re-import them from a backup later today.
The re-import is complete. Let me know if anything seems missing or misplaced. So here’s what happened.
We use a library called django-magic-cards to import oracle data from MTGJSON. That library stopped working and is unmaintained, so I took over maintenance and fixed some bugs. Due to changes in the API, I was getting errors while trying to import - some set codes had changed, loyalty isn’t an integer anymore, one card is missing an artist now, and some of the cards from the world championship decks have collector’s numbers that required a longer database field. To allow the new database to import cleanly, I wiped the relevant database tables and ran the import again - the data in those tables is all ephemeral anyway.
The translated card table links to a unique ID in the normal card table, so when the cards get deleted and re-created, the links from the translated cards are no longer valid.
I already had a script to import translated cards from a CSV file, so I loaded up an old database backup, exported the translations to CSV, and re-imported them.
Saving some commands in case I ever need them again:
select T2.name, T1.language, T1.name, T1.typeline, REPLACE(T1.textbox,'\n','£') from exams_translatedcard T1 left join magic_cards_card T2 on T1.card_id = T2.id into outfile '/var/lib/mysql-files/trans.csv' fields terminated by ',' ESCAPED BY '"' enclosed by '"' lines terminated by '\n';
perl -pe 's/\r//g' trans.csv > trans-unix.csv
./manage.py import_card_translations --user=7104 trans-unix.csv
All seems to be back up, thanks a lot!