mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-09-12 19:44:13 +02:00
feat: recreate fts triggers after table transform
https://github.com/simonw/sqlite-utils/pull/498
This commit is contained in:
parent
d792dad1cf
commit
a25e83841f
1 changed files with 5 additions and 0 deletions
|
|
@ -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
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue