-
-
Notifications
You must be signed in to change notification settings - Fork 121
Closed
Description
After creating a table with an index, if you add a foreign key constraint to the table it drops existing non-related indexes.
I have attached a minimal repro example screenshot and code.
Repro code
from sqlite_utils import Database
from pathlib import Path
db_fp = './db_repro_index.db'
Path(db_fp).unlink(missing_ok=True), Path(f'{db_fp}-shm').unlink(missing_ok=True),Path(f'{db_fp}-wal').unlink(missing_ok=True);
# db = database(db_fp)
db = Database(db_fp)
db['foo'].create(dict(id=int, name=str), pk='id', not_null=['name'])
db['foo'].create_index(['name'], unique=True)
db['foo'].indexes
db['bar'].create(dict(id=int, name=str, foo_id=int), pk='id', not_null=['name'])
db['bar'].create_index(['name'], unique=True)
db['bar'].indexes
db.add_foreign_keys((('bar','foo_id','foo','id'),))
db['bar'].indexes
Metadata
Metadata
Assignees
Labels
No labels