""" Schema + data migration: 1. Add `cautions` JSONField (list, default=[]) to TarotCard. 2. Seed The Schizo (Earthman MAJOR #1) with 4 rival-interaction cautions. All other cards default to [] — the UI shows a placeholder when empty. """ from django.db import migrations, models SCHIZO_CAUTIONS = [ 'This card will reverse into The Pervert when it' ' comes under dominion of The Occultist, which in turn' ' reverses into Pestilence.', 'This card will reverse into The Paranoiac when it' ' comes under dominion of The Despot, which in turn' ' reverses into War.', 'This card will reverse into The Neurotic when it' ' comes under dominion of The Capitalist, which in turn' ' reverses into Famine.', 'This card will reverse into The Suicidal when it' ' comes under dominion of The Fascist, which in turn' ' reverses into Death.', ] def seed_schizo_cautions(apps, schema_editor): TarotCard = apps.get_model("epic", "TarotCard") DeckVariant = apps.get_model("epic", "DeckVariant") try: earthman = DeckVariant.objects.get(slug="earthman") except DeckVariant.DoesNotExist: return TarotCard.objects.filter( deck_variant=earthman, arcana="MAJOR", number=1 ).update(cautions=SCHIZO_CAUTIONS) def clear_schizo_cautions(apps, schema_editor): TarotCard = apps.get_model("epic", "TarotCard") DeckVariant = apps.get_model("epic", "DeckVariant") try: earthman = DeckVariant.objects.get(slug="earthman") except DeckVariant.DoesNotExist: return TarotCard.objects.filter( deck_variant=earthman, arcana="MAJOR", number=1 ).update(cautions=[]) class Migration(migrations.Migration): dependencies = [ ("epic", "0026_earthman_suit_renames_and_keywords"), ] operations = [ migrations.AddField( model_name="tarotcard", name="cautions", field=models.JSONField(default=list), ), migrations.RunPython(seed_schizo_cautions, reverse_code=clear_schizo_cautions), ]