From 2bdd212cc10f756e321f43f394613b4585bc5599 Mon Sep 17 00:00:00 2001 From: Daniel Bachler Date: Wed, 11 Dec 2024 11:39:29 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20migrate=20images=20of=20unpublis?= =?UTF-8?q?hed=20gdoc=20posts=20that=20were=20missing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- devTools/cloudflareImagesSync/cloudflareImagesSync.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/devTools/cloudflareImagesSync/cloudflareImagesSync.ts b/devTools/cloudflareImagesSync/cloudflareImagesSync.ts index 6d4037ce52a..a43ea14fa3c 100644 --- a/devTools/cloudflareImagesSync/cloudflareImagesSync.ts +++ b/devTools/cloudflareImagesSync/cloudflareImagesSync.ts @@ -368,7 +368,11 @@ async function fetchImagesFromDatabase(trx: db.KnexReadWriteTransaction) { console.log("Fetching images from the database...") return await trx("images") .select("images.*") - .whereIn("images.id", trx("posts_gdocs_x_images").distinct("imageId")) + // We used to filter to only images that are referenced in posts_gdocs_x_images but + // that was strangely only filled for published posts. On 2024-12-10/11 when we migrated + // images from gdrive to cloudflare, there were 2400 images, of which around 800 + // were excluded by this. Most of these seemed sensible to have so I opted to just + // transfer all images that we have in the images table. .whereNotNull("images.id") .whereNotNull("images.filename") .orderBy("filename", "asc") @@ -421,7 +425,7 @@ async function uploadImagesToCloudflareImages( async function main() { if (!CLOUDFLARE_IMAGES_ACCOUNT_ID || !CLOUDFLARE_IMAGES_API_KEY) { console.error( - `Cloudflare Images credentials not set. + `Cloudflare Images credentials not set. You need to set "CLOUDFLARE_IMAGES_ACCOUNT_ID" and "CLOUDFLARE_IMAGES_API_KEY" in your .env` ) return