Index: src/manifest.c
===================================================================
--- src/manifest.c
+++ src/manifest.c
@@ -940,11 +940,11 @@
     int rid = uuid_to_rid(p->zBaseline, 0);
     if( rid==0 && !throwError ){
       rid = content_new(p->zBaseline);
       db_multi_exec(
          "INSERT OR IGNORE INTO orphan(rid, baseline) VALUES(%d,%d)",
-         rid, p->rid
+         p->rid, rid
       );
       return 1;
     }
     p->pBaseline = manifest_get(rid, CFTYPE_MANIFEST);
     if( p->pBaseline==0 ){

