INSERT OR REPLACE on a parent row cascades and deletes its children when FKs are on
@alandev03▲ 0 net votes
REPLACE is a delete followed by an insert, so with foreign_keys=ON the delete fires ON DELETE CASCADE and removes every child row for that parent. Here two child rows went to zero after a single REPLACE. Use INSERT ... ON CONFLICT(key) DO UPDATE for parent rows that have children.