Skip to content

Commit

Permalink
Merge branch 'post-release-fixes'
Browse files Browse the repository at this point in the history
  • Loading branch information
DMcP89 committed Aug 24, 2024
2 parents f801f6f + 9d2267f commit 1e09d45
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 16 deletions.
42 changes: 27 additions & 15 deletions harambot/database/migrations.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import logging

from playhouse.migrate import SqliteMigrator, MySQLMigrator, PostgresqlMigrator
from playhouse.migrate import migrate
from playhouse.dataset import DataSet
Expand All @@ -9,6 +11,10 @@

from harambot.config import settings

logger = logging.getLogger("discord")
logger.setLevel(settings.LOGLEVEL)


if "DATABASE_URL" in settings:
database = connect(settings.database_url)
else:
Expand Down Expand Up @@ -43,22 +49,28 @@ def beta040_migrations():
dataSet = DataSet(":memory:")
guilds = dataSet["guild"]
for guild in guilds.all():
print(guild["id"])
dataSet.query(
sql="UPDATE guild SET access_token = ? WHERE id = ?",
params=[
f.encrypt(guild["access_token"].encode()).decode(),
guild["id"],
],
logger.info(
"Encrypted token: "
+ "'{}'".format(f.encrypt(guild["access_token"].encode()).decode())
)
dataSet.query(
sql="UPDATE guild SET refresh_token = ? WHERE id = ?",
params=[
f.encrypt(guild["refresh_token"].encode()).decode(),
guild["id"],
],
)

logger.info("Guild ID:")
logger.info(guild["id"])
with dataSet.transaction() as txn:
guilds.update(
id=guild["id"],
access_token=f.encrypt(
guild["access_token"].encode()
).decode(),
columns=["id"],
)
guilds.update(
id=guild["id"],
refresh_token=f.encrypt(
guild["refresh_token"].encode()
).decode(),
columns=["id"],
)
txn.commit()
# Add new fields for transaction polling
transaction_polling_service_enabled = IntegerField(default=0)
transaction_polling_webhook = TextField(null=True)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "harambot"
version = "0.4.0"
version = "0.4.0.post1"
description = "A Yahoo Fantasy Sports bot for Discord"
authors = ["DMcP89 <[email protected]>"]
license = "MIT"
Expand Down

0 comments on commit 1e09d45

Please sign in to comment.