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
x
5
1
migration file "20191104160706_migrate-appsflyer_customers.js" failed
2
migration failed with error: The query is empty
3
at createQueryBuilder (/home/circleci/backend/node_modules/knex/lib/knex-builder/make-knex.js:313:26)
4
5
but the migration file contains the query’s
JavaScript
1
22
22
1
async function up (knex) {
2
// language=Postgres
3
const { rows } = await knex.raw(`
4
SELECT * FROM appsflyer_customer;
5
`)
6
const mappedRows = rows.map(row => ({
7
user_id: row.user_id,
8
advertising_id_type: 'appsflyer',
9
advertising_id: row.appsflyer_device_id
10
}))
11
await knex('device_advertising_association')
12
.insert(mappedRows)
13
}
14
async function down (knex) {
15
await knex.raw(`
16
DELETE FROM device_advertising_association WHERE user_id NOTNULL;
17
`)
18
}
19
module.exports = {
20
up, down
21
}
22
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