From 000c247f00dc1787d3a465183015564aa615da89 Mon Sep 17 00:00:00 2001 From: David Arranz Date: Thu, 12 Sep 2024 20:01:02 +0200 Subject: [PATCH] . --- server/src/infrastructure/sequelize/initStructure.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/src/infrastructure/sequelize/initStructure.ts b/server/src/infrastructure/sequelize/initStructure.ts index 4ac68f7..10a8c47 100644 --- a/server/src/infrastructure/sequelize/initStructure.ts +++ b/server/src/infrastructure/sequelize/initStructure.ts @@ -14,7 +14,7 @@ const createCatalogTableIfNotExists = async (sequelize: Sequelize) => { AND table_name = 'catalog';`; const [result]: any = await sequelize.query(checkTableQuery); - const tableExists = result[0]["COUNT(*)"] > 0; + const tableExists = result.length > 0 && result[0].count > 0; if (!tableExists) { // Consulta para crear la tabla si no existe @@ -63,7 +63,7 @@ const createCatalogTranslationsTableIfNotExists = async (sequelize: Sequelize) = `; const [result]: any = await sequelize.query(checkTableQuery); - const tableExists = result[0]["COUNT(*)"] > 0; + const tableExists = result.length > 0 && result[0].count > 0; if (!tableExists) { // Consulta para crear la tabla si no existe @@ -111,7 +111,7 @@ const createVCatalogViewIfNotExists = async (sequelize: Sequelize) => { `; const [result]: any = await sequelize.query(checkViewQuery); - const viewExists = result[0]["COUNT(*)"] > 0; + const viewExists = result.length > 0 && result[0].count > 0; if (!viewExists) { // Consulta para crear la tabla si no existe