我正在使用adonis js制作网站。我需要通过迁移将某些列添加到现有表中,并在运行“adonis migration:rollback”时删除这些列。如何编写迁移 down() 函数?
我在下面提到的代码adonis make:migration medicines --action=select
'use strict'
/** @type {import('@adonisjs/lucid/src/Schema')} */
const Schema = use('Schema')
class MedicinesSchema extends Schema {
up () {
this.alter('medicines', (table) => {
// alter table
table.boolean('front_page');
table.integer( 'brand_id' ).nullable();
table.integer('offer_id').nullable();
})
}
down () {
this.table('medicines', (table) => {
// reverse alternations
// HOW DO I WRITE THE REVERSALS HERE ?
})
}
}
module.exports = MedicinesSchema
提前致谢