internal/postgres: add exp to getDocIDsForPath

ExperimentDoNotInsertNewDocumentation is added to getDocIDsForPath, so
that we can deprecate new_documentation in a future CL.

Change-Id: I53b35d4e629974c70aec43ed0b4f124d46085dd6
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/310312
Trust: Julie Qiu <julie@golang.org>
Run-TryBot: Julie Qiu <julie@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
diff --git a/internal/postgres/insert_module.go b/internal/postgres/insert_module.go
index ce2edcb..8ad806d 100644
--- a/internal/postgres/insert_module.go
+++ b/internal/postgres/insert_module.go
@@ -582,9 +582,13 @@
 		unitIDToPath[pathToUnitID[path]] = path
 		unitIDs = append(unitIDs, pathToUnitID[path])
 	}
-	if err := db.RunQuery(ctx,
-		`SELECT id, unit_id, goos, goarch FROM new_documentation WHERE unit_id = ANY($1)`,
-		collect, pq.Array(unitIDs)); err != nil {
+
+	doctable := "new_documentation"
+	if experiment.IsActive(ctx, internal.ExperimentDoNotInsertNewDocumentation) {
+		doctable = "documentation"
+	}
+	q := fmt.Sprintf(`SELECT id, unit_id, goos, goarch FROM %s WHERE unit_id = ANY($1)`, doctable)
+	if err := db.RunQuery(ctx, q, collect, pq.Array(unitIDs)); err != nil {
 		return nil, err
 	}
 	return pathToDocIDToDoc, nil