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

Support servers with more than 1 IP #26

Closed nauar closed 3 months ago

nauar commented 3 months ago

Some servers have dual stack (IPv4 + IPv6). Also, some servers may have more than one IP. Redesign the model and adapt the code to support multiple IPs per server.

At this moment, we have only detected the first case (dual stack). So adding a new column for IPv6 addresses is enough.

nauar commented 3 months ago

Getting a first look into this issue, made me wonder if there is any way to handle adequately database modifications using Peewee.

For instance, on this case we have the Servers table:

class Servers(Model):
    serverName = CharField(unique=True)
    serverIp = CharField(unique=True)

    class Meta:
        database = db

And I was thinking to have this final result:

class Servers(Model):
    serverName = CharField(unique=True)
    serverIPv4 = CharField(unique=True, null=True)
    serverIPv6 = CharField(unique=True, null=True)

    class Meta:
        database = db

We need to handle the migration of one version into another without losing data. I think we need a sort of Database migration tool such as yoyo and detect DB drifts in the application startup. The current /setupdb.py is only able to initialize the DB from scratch and in the future, it could be very complicated to handle multiple and more complex migrations. Yoyo may provide a better solution.

nauar commented 3 months ago

Depends on issue #32