Skip to content

Foreign key already exists for license => licenses.key #85

Description

@kurtmckee

I've cloned this repository and run these commands (I'm assuming that the exact repository doesn't matter):

$ github-to-sqlite issues database.sqlite3 user/repo
$ github-to-sqlite issue-comments database.sqlite3 user/repo
Traceback (most recent call last):
  File ".venv/bin/github-to-sqlite", line 10, in <module>
    sys.exit(cli())
             ~~~^^
  File ".venv/lib/python3.14/site-packages/click/core.py", line 1569, in __call__
    return self.main(*args, **kwargs)
           ~~~~~~~~~^^^^^^^^^^^^^^^^^
  File ".venv/lib/python3.14/site-packages/click/core.py", line 1490, in main
    rv = self.invoke(ctx)
  File ".venv/lib/python3.14/site-packages/click/core.py", line 1970, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File ".venv/lib/python3.14/site-packages/click/core.py", line 1353, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".venv/lib/python3.14/site-packages/click/core.py", line 907, in invoke
    return callback(*args, **kwargs)
  File "github_to_sqlite/cli.py", line 180, in issue_comments
    utils.ensure_db_shape(db)
    ~~~~~~~~~~~~~~~~~~~~~^^^^
  File "github_to_sqlite/utils.py", line 714, in ensure_db_shape
    ensure_foreign_keys(db)
    ~~~~~~~~~~~~~~~~~~~^^^^
  File "github_to_sqlite/utils.py", line 708, in ensure_foreign_keys
    db[table].add_foreign_key(column, table2, column2)
    ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".venv/lib/python3.14/site-packages/sqlite_utils/db.py", line 3330, in add_foreign_key
    raise AlterError(
    ...<3 lines>...
    )
sqlite_utils.db.AlterError: Foreign key already exists for license => licenses.key

I think that I've been able to resolve this issue by wrapping the last call in a try/except block, and can contribute a PR to address this if that seems like the right way to address this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions