Skip to content

Commit f59fce2

Browse files
committed
fix: script
1 parent 23a126b commit f59fce2

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

scripts/migrations/src/copyCache.script.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ export const copyTableData = async (
178178
// Process the fetched batch in smaller chunks for insertion
179179
for (let i = 0; i < batchRows.length; i += insertBatchSize) {
180180
const insertBatch = batchRows.slice(i, i + insertBatchSize);
181-
182181
// Create a parameterized query for this insertion batch
183182
const valueStrings = [];
184183
const valueParams = [];
@@ -188,7 +187,14 @@ export const copyTableData = async (
188187
const rowParams = [];
189188
for (const col of columns) {
190189
rowParams.push(`$${paramIndex++}`);
191-
valueParams.push(row[col]);
190+
//workaround for metadata column
191+
if (col === "metadata") {
192+
valueParams.push(
193+
Array.isArray(row[col]) ? stringify(row[col]) : row[col],
194+
);
195+
} else {
196+
valueParams.push(row[col]);
197+
}
192198
}
193199
valueStrings.push(`(${rowParams.join(", ")})`);
194200
}
@@ -198,6 +204,7 @@ export const copyTableData = async (
198204
VALUES ${valueStrings.join(", ")}
199205
`;
200206

207+
console.log(columns);
201208
await targetPool.query(insertQuery, valueParams);
202209

203210
processedRows += insertBatch.length;
@@ -267,7 +274,7 @@ export const main = async (): Promise<void> => {
267274
const targetDb = sourceColor === "blue" ? GREEN_DB : BLUE_DB;
268275

269276
logger.info(`Copying cache data from ${sourceColor} to ${targetColor}...`);
270-
await copyCacheData(sourceDb, targetDb, connectionDetails);
277+
await copyCacheData("datalayer-postgres-db", "GitcoinDatalayerGreen", connectionDetails);
271278

272279
logger.info(`✅ Cache data copied from ${sourceColor} to ${targetColor} successfully`);
273280

0 commit comments

Comments
 (0)