From 94e6fcc250f6affe21a15683558182660706efe0 Mon Sep 17 00:00:00 2001 From: clement-duport Date: Thu, 30 May 2024 11:59:23 +0200 Subject: [PATCH] fix phone number migration --- .../1717012051680_validate-all-phone-number-from-past.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/back/src/config/pg/migrations/1717012051680_validate-all-phone-number-from-past.ts b/back/src/config/pg/migrations/1717012051680_validate-all-phone-number-from-past.ts index 8255f60ad8..f9b1dd93b8 100644 --- a/back/src/config/pg/migrations/1717012051680_validate-all-phone-number-from-past.ts +++ b/back/src/config/pg/migrations/1717012051680_validate-all-phone-number-from-past.ts @@ -96,10 +96,10 @@ async function updateTable( { ids: [], phones: [] }, ); - const updateQuery = `UPDATE actors - SET phone = unnested.phone - FROM (SELECT unnest($1::int[]) as id, unnest($2::text[]) as phone) as unnested - WHERE actors.id = unnested.id;`; + const updateQuery = `UPDATE ${tableName} + SET ${columnName} = unnested.phone + FROM (SELECT unnest($1::${tableName === "actors" ? "int[]" : "uuid[]"}) as id, unnest($2::text[]) as phone) as unnested + WHERE ${tableName}.${primaryKey} = unnested.id;`; console.timeEnd("typescript process"); console.time("update query");