{"html_url": "https://github.com/simonw/sqlite-utils/issues/335#issuecomment-968380387", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/335", "id": 968380387, "node_id": "IC_kwDOCGYnMM45uE_j", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-11-14T22:55:56Z", "updated_at": "2021-11-14T22:55:56Z", "author_association": "OWNER", "body": "OK, this should fix it.", "reactions": "{\"total_count\": 1, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 1, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1042569687, "label": "sqlite-utils index-foreign-keys fails due to pre-existing index"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/335#issuecomment-968371112", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/335", "id": 968371112, "node_id": "IC_kwDOCGYnMM45uCuo", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-11-14T21:57:43Z", "updated_at": "2021-11-14T22:21:31Z", "author_association": "OWNER", "body": "`create_index(..., find_unique_name=)` is good. Default to false. `index_foreign_keys` can set it to true.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1042569687, "label": "sqlite-utils index-foreign-keys fails due to pre-existing index"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/335#issuecomment-968361671", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/335", "id": 968361671, "node_id": "IC_kwDOCGYnMM45uAbH", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-11-14T20:54:53Z", "updated_at": "2021-11-14T21:01:14Z", "author_association": "OWNER", "body": "I'm leaning towards `table.create_index(columns, ignore_existing_name=True)` now.\r\n\r\nOr `resolve_existing_name` - or `skip_existing_name`?\r\n\r\n\"ignore\" sounds like it might not create the index if the name exists, but we want to still create the index but pick a new name.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1042569687, "label": "sqlite-utils index-foreign-keys fails due to pre-existing index"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/335#issuecomment-968362285", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/335", "id": 968362285, "node_id": "IC_kwDOCGYnMM45uAkt", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-11-14T20:59:44Z", "updated_at": "2021-11-14T20:59:44Z", "author_association": "OWNER", "body": "I think I'll attempt to create the index and re-try if it fails with that error.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1042569687, "label": "sqlite-utils index-foreign-keys fails due to pre-existing index"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/335#issuecomment-968362214", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/335", "id": 968362214, "node_id": "IC_kwDOCGYnMM45uAjm", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-11-14T20:59:15Z", "updated_at": "2021-11-14T20:59:15Z", "author_association": "OWNER", "body": "How to figure out if an index name is already in use? `PRAGMA index_list(t)` requires a table name. This does it:\r\n\r\n```sql\r\nSELECT name \r\nFROM sqlite_master \r\nWHERE type = 'index';\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1042569687, "label": "sqlite-utils index-foreign-keys fails due to pre-existing index"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/335#issuecomment-968361409", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/335", "id": 968361409, "node_id": "IC_kwDOCGYnMM45uAXB", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-11-14T20:52:55Z", "updated_at": "2021-11-14T20:52:55Z", "author_association": "OWNER", "body": "Looking at the method signature: https://github.com/simonw/sqlite-utils/blob/92aa5c9c5d26b0889c8c3d97c76a908d5f8af211/sqlite_utils/db.py#L1518-L1524\r\n\r\n`if_not_exists` just adds a `IF NOT EXISTS` clause here: https://github.com/simonw/sqlite-utils/blob/92aa5c9c5d26b0889c8c3d97c76a908d5f8af211/sqlite_utils/db.py#L1549-L1561", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1042569687, "label": "sqlite-utils index-foreign-keys fails due to pre-existing index"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/335#issuecomment-968361285", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/335", "id": 968361285, "node_id": "IC_kwDOCGYnMM45uAVF", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-11-14T20:51:57Z", "updated_at": "2021-11-14T20:51:57Z", "author_association": "OWNER", "body": "SQLite will happily create multiple identical indexes on a table, using more disk space each time:\r\n```pycon\r\n>>> import sqlite_utils\r\n>>> db = sqlite_utils.Database(\"dupes.db\")\r\n>>> db[\"t\"].insert_all({\"id\": i} for i in range(10000))\r\n