Skip to content
Advertisement

Knex migration failed with error: The query is empty

I updated knex from 0.21 to 0.95 following their migration guide, Now im geting this Error on CI when its running npx knex migrate:latest

JavaScript

but the migration file contains the query’s

JavaScript

Any help would be greatly appreciated as im getting no where with the error message

Advertisement

Answer

So i was getting this error since Knex 0.95 introduced a new feature https://github.com/knex/knex/pull/4289 so that if an empty array is passed to insert it will throw an error which was not present before

and since we didn’t use that table it was empty and this above migration was trying to insert an empty array which was throwing the error on CI so I just basically handled the Exception with a try-catch block and it got resolved

so as a note look at the change logs carefully

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement