Skip to content

Commit

Permalink
Foreign keys for milestones table, refs #31
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Apr 21, 2020
1 parent 7757a41 commit 02e38b3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion github_to_sqlite/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,14 @@ class GitHubRepositoryEmpty(GitHubError):

def save_issues(db, issues, repo):
if "milestones" not in db.table_names():
db["milestones"].create({"id": int, "title": str, "description": str}, pk="id")
if "users" not in db.table_names():
# So we can define the foreign key from milestones:
db["users"].create({"id": int}, pk="id")
db["milestones"].create(
{"id": int, "title": str, "description": str, "repo": int},
pk="id",
foreign_keys=(("repo", "repos", "id"), ("creator", "users", "id")),
)
for original in issues:
# Ignore all of the _url fields
issue = {
Expand Down

0 comments on commit 02e38b3

Please sign in to comment.