backend: Auto-generate origin visit stats upsert query
This will help us when adding new fields to the table.