from django.db import migrations

NOITA_APP_ID = 881100
OPUS_MAGNUM_APP_ID = 558990


def seed_games(apps, schema_editor):
    Game = apps.get_model("games", "Game")
    Game.objects.get_or_create(
        steam_app_id=NOITA_APP_ID,
        defaults={"name": "Noita", "enabled": True},
    )
    Game.objects.get_or_create(
        steam_app_id=OPUS_MAGNUM_APP_ID,
        defaults={"name": "Opus Magnum", "enabled": True},
    )


def unseed_games(apps, schema_editor):
    Game = apps.get_model("games", "Game")
    Game.objects.filter(steam_app_id__in=[NOITA_APP_ID, OPUS_MAGNUM_APP_ID]).delete()


class Migration(migrations.Migration):
    dependencies = [
        ("games", "0001_initial"),
    ]

    operations = [
        migrations.RunPython(seed_games, reverse_code=unseed_games),
    ]
