Skip to content

Commit 71613af

Browse files
committed
Fix reverting deletes.
1 parent b0ea8ac commit 71613af

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

packages/powersync/lib/src/schema_logic.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@ FOR EACH ROW
5353
BEGIN
5454
DELETE FROM $internalNameE WHERE id = OLD.id;
5555
INSERT INTO ps_crud(tx_id, data) SELECT current_tx, json_object('op', 'DELETE', 'type', ${quoteString(type)}, 'id', OLD.id) FROM ps_tx WHERE id = 1;
56+
INSERT INTO ps_oplog(bucket, op_id, op, row_type, row_id, hash, superseded)
57+
SELECT '\$local',
58+
1,
59+
'REMOVE',
60+
${quoteString(type)},
61+
OLD.id,
62+
0,
63+
0;
64+
INSERT OR REPLACE INTO ps_buckets(name, pending_delete, last_op, target_op) VALUES('\$local', 1, 0, $maxOpId);
5665
END""",
5766
"""
5867
CREATE TRIGGER ${quoteIdentifier('ps_view_insert_$viewName')}

0 commit comments

Comments
 (0)