Skip to content

Commit

Permalink
Fix migration of foreign keys
Browse files Browse the repository at this point in the history
The tests currently fail, due to migration m008_reply_to_id_foreign_key
failing. I suspect this is related to a recent change in squlite-utils
[0].

This PR avoids that by explictly dropping the foreign key before
renaming the table, then adding the foreign key back. See the related
GitHub issue for more info [1].

[0] simonw/sqlite-utils#577
[1] simonw#162
  • Loading branch information
kevinschaul committed Aug 18, 2023
1 parent d31d97e commit 45e1a9c
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions llm/migrations.py
Expand Up @@ -130,8 +130,10 @@ def m007_finish_logs_table(db):
drop={"debug"},
rename={"timestamp_utc": "datetime_utc"},
)
db["log"].transform(drop_foreign_keys=("chat_id",))
with db.conn:
db.execute("alter table log rename to logs")
db["logs"].add_foreign_key("chat_id", "logs", "id")


@migration
Expand Down

0 comments on commit 45e1a9c

Please sign in to comment.