From 1339bfdc5244f286a7bff797d1d7718c95f22d1a Mon Sep 17 00:00:00 2001 From: Michael Taylor Date: Mon, 16 May 2022 14:12:40 -0400 Subject: [PATCH] fix: only migrate fts if on sqlite --- package.json | 2 +- ...25335-add-description-field-to-projects.js | 31 ++++++++++--------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index fe8b46d4..ffd6406f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "climate-warehouse", - "version": "0.0.32", + "version": "0.0.33", "private": true, "bin": "build/server.js", "type": "module", diff --git a/src/database/migrations/20220509125335-add-description-field-to-projects.js b/src/database/migrations/20220509125335-add-description-field-to-projects.js index bb9a5ef7..bea0e8b1 100644 --- a/src/database/migrations/20220509125335-add-description-field-to-projects.js +++ b/src/database/migrations/20220509125335-add-description-field-to-projects.js @@ -2,15 +2,16 @@ export default { async up(queryInterface, Sequelize) { - await Promise.all([ - queryInterface.addColumn('projects', 'description', { - type: Sequelize.STRING, - allowNull: true, - }), + await queryInterface.addColumn('projects', 'description', { + type: Sequelize.STRING, + allowNull: true, + }); - queryInterface.sequelize.query(`drop table projects_fts;`), + if (queryInterface.sequelize.getDialect() === 'sqlite') { + await Promise.all([ + queryInterface.sequelize.query(`drop table projects_fts;`), - queryInterface.sequelize.query(` + queryInterface.sequelize.query(` CREATE VIRTUAL TABLE projects_fts USING fts5( warehouseProjectId, orgUid, @@ -37,16 +38,17 @@ export default { description ); `), - ]); + ]); + } }, async down(queryInterface) { - await Promise.all([ - queryInterface.removeColumn('projects', 'description'), + await queryInterface.removeColumn('projects', 'description'); + if (queryInterface.sequelize.getDialect() === 'sqlite') { + await Promise.all([ + queryInterface.sequelize.query(`drop table projects_fts;`), - queryInterface.sequelize.query(`drop table projects_fts;`), - - queryInterface.sequelize.query(` + queryInterface.sequelize.query(` CREATE VIRTUAL TABLE projects_fts USING fts5( warehouseProjectId, orgUid, @@ -72,6 +74,7 @@ export default { timeStaged ); `), - ]); + ]); + } }, };