Seekfried / greedybot-d2irc

A pickupbot for managing Xonotic pickup games, that also syncs messages between Discord and IRC.
MIT License
2 stars 2 forks source link

Database migrations #32

Closed nauar closed 3 months ago

nauar commented 3 months ago

Implement a system for db migrations to manage releases involving DB changes. A possible option is the usage of yoyo.

nauar commented 3 months ago

Addressing the architectural decision about the DB CI/CD changes raised in issue #26

nauar commented 3 months ago

In the last conversation about this topic, we considered these options:

After discussing the advantages and drawbacks of each option, we agreed that for our use case, the 1st two would be a bit overkill. So we will test peewee-db-evolve. We need to test it because the README states it is only compatible with MySQL and PostgreSQL.

nauar commented 3 months ago

After preparing the tests, we get the following error:

Traceback (most recent call last):
  File "/home/*****/projects/bot/friedybot-d2irc/setupdb_evolve_testv2.py", line 39, in <module>
    main()
  File "/home/*****/projects/bot/friedybot-d2irc/setupdb_evolve_testv2.py", line 32, in main
    createDatabase()
  File "/home/*****/projects/bot/friedybot-d2irc/setupdb_evolve_testv2.py", line 8, in createDatabase
    db.evolve([Servers])
  File "/home/*****/projects/bot/friedybot-d2irc/venv/lib/python3.12/site-packages/peeweedbevolve.py", line 729, in evolve
    to_run = calc_changes(db, ignore_tables=ignore_tables, schema=schema)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/*****/projects/bot/friedybot-d2irc/venv/lib/python3.12/site-packages/peeweedbevolve.py", line 618, in calc_changes
    existing_columns_by_table = get_columns_by_table(db, schema=schema)
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/*****/projects/bot/friedybot-d2irc/venv/lib/python3.12/site-packages/peeweedbevolve.py", line 444, in get_columns_by_table
    raise Exception("don't know how to get columns for %s" % db)
Exception: don't know how to get columns for <peewee.SqliteDatabase object at 0x7f6df3fb3fe0>

Checking the code of peewee-db-evolve, we see that SQLite databases are not supported:

image

So, we need to check other alternatives:

nauar commented 3 months ago

Solution with peewe_migrate implemented and it works! Review of PR #36 pending.