我想为以下查询创建一个迁移文件
`insert into table1(column1)
select o.name from original_table as o`
`update original_table as o
set new_column = (select t1.id from table1 as t1
where t.column1 = o.old_column)`
到目前为止,我想出了这个。第一部分有效,但我坚持第二部分
`exports.up = function (knex, Promise) {
return Promise.resolve()
.then(() => knex('original_table').select('old_column'))
.then((rows) => knex('table1').insert(rows))
.then(() => knex('table1 as t').select(['t.column1',
'column2']).join('original_table
as o', 'o.old_column', 't.column2'))
.then((rows) => knex('original_tableas
o').whereIn('original_table.old_column', rows.column2).update('column2',
rows.column1))
};
exports.down = function (knex) {
return Promise.resolve()
.then(() => console.log("Deletes updated records"));
};`
先感谢您。