feat: recreate fts triggers after table transform

https://github.com/simonw/sqlite-utils/pull/498
This commit is contained in:
Jacob Chapman 2022-10-11 15:35:03 -05:00 committed by GitHub
commit a25e83841f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1622,6 +1622,7 @@ class Table(Queryable):
to use when creating the table.
"""
assert self.exists(), "Cannot transform a table that doesn't exist yet"
fts_table = self.detect_fts()
sqls = self.transform_sql(
types=types,
rename=rename,
@ -1632,6 +1633,10 @@ class Table(Queryable):
drop_foreign_keys=drop_foreign_keys,
column_order=column_order,
)
if fts_table:
fts_columns = [c.name for c in self.db[fts_table].columns if c.name not in drop]
fts_columns_renamed = [renamed[c] if c in renamed else c for c in fts_columns]
self.enable_fts(fts_columns_renamed, replace=True)
pragma_foreign_keys_was_on = self.db.execute("PRAGMA foreign_keys").fetchone()[
0
]