diff --git a/github_to_sqlite/utils.py b/github_to_sqlite/utils.py index cde1726..d1bd76a 100644 --- a/github_to_sqlite/utils.py +++ b/github_to_sqlite/utils.py @@ -468,14 +468,14 @@ def save_contributors(db, contributors, repo_id): def save_tags(db, tags, repo_id): if not db["tags"].exists(): db["tags"].create( - {"repo_id": int, "name": str, "sha": str,}, - pk=("repo_id", "name"), - foreign_keys=[("repo_id", "repos", "id")], + {"repo": int, "name": str, "sha": str,}, + pk=("repo", "name"), + foreign_keys=[("repo", "repos", "id")], ) db["tags"].insert_all( ( - {"repo_id": repo_id, "name": tag["name"], "sha": tag["commit"]["sha"],} + {"repo": repo_id, "name": tag["name"], "sha": tag["commit"]["sha"],} for tag in tags ), replace=True, diff --git a/tests/test_tags.py b/tests/test_tags.py index 3386a4d..4d1580c 100644 --- a/tests/test_tags.py +++ b/tests/test_tags.py @@ -27,9 +27,7 @@ def db(tags, repo): def test_tables(db): assert {"users", "tags", "licenses", "repos"} == set(db.table_names()) assert { - ForeignKey( - table="tags", column="repo_id", other_table="repos", other_column="id" - ) + ForeignKey(table="tags", column="repo", other_table="repos", other_column="id") } == set(db["tags"].foreign_keys) @@ -37,12 +35,12 @@ def test_tags(db): tags_rows = list(db["tags"].rows) assert [ { - "repo_id": 207052882, + "repo": 207052882, "name": "2.3", "sha": "7090e43d804724ef3b31ae5ca9efd6ac05f76cbc", }, { - "repo_id": 207052882, + "repo": 207052882, "name": "2.2", "sha": "4fe69783b55465e7692a807d3a02a710f69c9c42", },