Skip to content

Commit 6df6aec

Browse files
committed
Add migrator
1 parent eaae338 commit 6df6aec

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

worldtimezone/extensions/world_clock_data.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55

66
import peewee
77
import pytz
8+
from playhouse.migrate import SqliteMigrator, migrate
89

910
FILE_INFO_V2 = ".data/tz_v2.json"
1011
FILE_SQLITE_DB = ".data/tz_v3.db"
1112

1213
db = peewee.SqliteDatabase(FILE_SQLITE_DB)
14+
db_migrator = SqliteMigrator(db)
1315

1416

1517
COMMON_TIMEZONES = [
@@ -66,7 +68,6 @@ class DBGuild(DBBaseModel):
6668
discord_id = peewee.CharField(unique=True)
6769
channel_id = peewee.CharField(default="")
6870
message_id = peewee.CharField(default="")
69-
message_id_others = ArrayField(default=[])
7071

7172

7273
class DBMember(DBBaseModel):
@@ -79,6 +80,10 @@ class WorldClockData:
7980
def __init__(self):
8081
_ = db.connect()
8182
db.create_tables([DBGuild, DBMember])
83+
message_id_others = ArrayField(default=[])
84+
migrate(
85+
db_migrator.add_column(DBGuild._meta.table_name, "message_id_others", message_id_others)
86+
)
8287
# START Transform old format to new
8388
if os.path.isfile(FILE_INFO_V2):
8489
import json

0 commit comments

Comments
 (0)