From 54552b2dcd79282878c38210294dc0d31fda4549 Mon Sep 17 00:00:00 2001 From: Tiago Yamamoto Date: Wed, 24 Dec 2025 15:07:25 -0300 Subject: [PATCH] =?UTF-8?q?fix(seeder):=20add=20table=20name=20mapping=20f?= =?UTF-8?q?or=20location=20data=20(regions=E2=86=92continents)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- seeder-api/src/seeders/location-loader.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/seeder-api/src/seeders/location-loader.js b/seeder-api/src/seeders/location-loader.js index dae0793..7346d38 100644 --- a/seeder-api/src/seeders/location-loader.js +++ b/seeder-api/src/seeders/location-loader.js @@ -9,6 +9,14 @@ import { fileURLToPath } from 'url'; const __dirname = dirname(fileURLToPath(import.meta.url)); const SQL_DIR = join(__dirname, '..', '..', 'sql'); +/** + * Table name mapping from SQL dumps to our schema + */ +const TABLE_MAPPING = { + 'public.regions': 'continents', + 'regions': 'continents', +}; + /** * Execute a SQL file directly */ @@ -44,6 +52,12 @@ async function executeSqlFile(filename, tableName) { .replace(/`/g, '"') .replace(/"emojiU"/g, 'emoji_u') .replace(/"wikiDataId"/g, 'wiki_data_id'); + + // Apply table name mapping + for (const [oldName, newName] of Object.entries(TABLE_MAPPING)) { + pgStmt = pgStmt.replace(new RegExp(`INSERT INTO ${oldName}`, 'gi'), `INSERT INTO ${newName}`); + } + await pool.query(pgStmt); }