Skip to content

Commit

Permalink
Add migrator
Browse files Browse the repository at this point in the history
  • Loading branch information
Saverio976 committed Nov 25, 2024
1 parent eaae338 commit 6df6aec
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion worldtimezone/extensions/world_clock_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@

import peewee
import pytz
from playhouse.migrate import SqliteMigrator, migrate

FILE_INFO_V2 = ".data/tz_v2.json"
FILE_SQLITE_DB = ".data/tz_v3.db"

db = peewee.SqliteDatabase(FILE_SQLITE_DB)
db_migrator = SqliteMigrator(db)


COMMON_TIMEZONES = [
Expand Down Expand Up @@ -66,7 +68,6 @@ class DBGuild(DBBaseModel):
discord_id = peewee.CharField(unique=True)
channel_id = peewee.CharField(default="")
message_id = peewee.CharField(default="")
message_id_others = ArrayField(default=[])


class DBMember(DBBaseModel):
Expand All @@ -79,6 +80,10 @@ class WorldClockData:
def __init__(self):
_ = db.connect()
db.create_tables([DBGuild, DBMember])
message_id_others = ArrayField(default=[])
migrate(
db_migrator.add_column(DBGuild._meta.table_name, "message_id_others", message_id_others)
)
# START Transform old format to new
if os.path.isfile(FILE_INFO_V2):
import json
Expand Down

0 comments on commit 6df6aec

Please sign in to comment.