Knex migration failed with error: The query is empty
Knex migration failed with error: The query is empty
我按照他们的迁移指南将 knex 从 0.21 更新到 0.95,现在我在 CI 运行 npx knex migrate:latest
时收到此错误
migration file "20191104160706_migrate-appsflyer_customers.js" failed
migration failed with error: The query is empty
at createQueryBuilder (/home/circleci/backend/node_modules/knex/lib/knex-builder/make-knex.js:313:26)
但迁移文件包含查询的
async function up (knex) {
// language=Postgres
const { rows } = await knex.raw(`
SELECT * FROM appsflyer_customer;
`)
const mappedRows = rows.map(row => ({
user_id: row.user_id,
advertising_id_type: 'appsflyer',
advertising_id: row.appsflyer_device_id
}))
await knex('device_advertising_association')
.insert(mappedRows)
}
async function down (knex) {
await knex.raw(`
DELETE FROM device_advertising_association WHERE user_id NOTNULL;
`)
}
module.exports = {
up, down
}
任何帮助将不胜感激,因为我对错误消息一无所知
所以我收到这个错误是因为 Knex 0.95 引入了一个新功能 https://github.com/knex/knex/pull/4289 因此如果将空数组传递给 insert 它将抛出一个之前不存在的错误
因为我们没有使用 table 它是空的,上面的迁移试图插入一个空数组,它在 CI 上抛出错误所以我基本上处理了异常使用 try-catch 块并得到解决
所以请仔细查看更改日志
我按照他们的迁移指南将 knex 从 0.21 更新到 0.95,现在我在 CI 运行 npx knex migrate:latest
migration file "20191104160706_migrate-appsflyer_customers.js" failed
migration failed with error: The query is empty
at createQueryBuilder (/home/circleci/backend/node_modules/knex/lib/knex-builder/make-knex.js:313:26)
但迁移文件包含查询的
async function up (knex) {
// language=Postgres
const { rows } = await knex.raw(`
SELECT * FROM appsflyer_customer;
`)
const mappedRows = rows.map(row => ({
user_id: row.user_id,
advertising_id_type: 'appsflyer',
advertising_id: row.appsflyer_device_id
}))
await knex('device_advertising_association')
.insert(mappedRows)
}
async function down (knex) {
await knex.raw(`
DELETE FROM device_advertising_association WHERE user_id NOTNULL;
`)
}
module.exports = {
up, down
}
任何帮助将不胜感激,因为我对错误消息一无所知
所以我收到这个错误是因为 Knex 0.95 引入了一个新功能 https://github.com/knex/knex/pull/4289 因此如果将空数组传递给 insert 它将抛出一个之前不存在的错误
因为我们没有使用 table 它是空的,上面的迁移试图插入一个空数组,它在 CI 上抛出错误所以我基本上处理了异常使用 try-catch 块并得到解决
所以请仔细查看更改日志