fixed RemoveProvisionAsync not removing triggers - #18
Conversation
…gh column names instead of table names
RemoveProvisionAsync built its drop list from PRAGMA table_info column
names while triggers are named after the table, so no trigger was ever
dropped. Since __CORE_SYNC_CT *is* dropped, the orphaned triggers left
every tracked table unwritable ("no such table: main.__CORE_SYNC_CT").
Covers the trigger/table teardown, that the database stays writable
afterwards, a de-provision on a never-provisioned database, and a table
dropped outside CoreSync - the case the old Columns.Any() guard was
meant to handle and which DROP TRIGGER IF EXISTS already covers.
|
Thanks @gtrafford — the change is correct, and I dug through the history to answer the "for some reason" in your description. It turns out Where it came from
foreach (var table in Configuration.Tables.Cast<SqliteSyncTable>().Where(_ => _.Columns.Any()))So the PRAGMA loop's only surviving role in the teardown was an existence probe — The Where it broke
- table.Columns.Add(new SqliteColumn(colName, colType, pk));
+ listOfTables.Add(colName);
...
-foreach (var table in Configuration.Tables.Cast<SqliteSyncTable>().Where(_ => _.Columns.Any()))
+foreach (var tableName in listOfTables)Column names into a variable named Why the fix is right
Worth spelling out how bad this was: TestsI pushed
The last one is exactly the case the old One optional follow-upThe method drops |
RemoveProvisionAsync in the SqliteProvider was not actually removing the triggers created by ApplyProvisionAsync. For some reason it was creating a list of column names and adding them to a list called listOfTables, and then looping through this to look for the triggers, which were just created based on table names, not columns.