【发布时间】:2020-03-07 04:08:23
【问题描述】:
我有这门课:
class BookUnitQuestionSchema extends Schema {
up () {
this.create('book_unit_question', (table) => {
table.increments()
table.integer('book_unit_id').references('id').inTable('book_unit')
table.string('correct_answer_description')
table.boolean('status').defaultTo(false)
table.integer('user_id').references('id').inTable('users')
table.timestamps()
})
}
down () {
this.drop('book_unit_question')
}
}
我需要将correct_answer_description 列的数据类型更改为text。
如果我将我的实际 up() 方法更改为:
table.text('correct_answer_description')
并制作一个:adonis migration:refresh
重新创建所有表,我丢失了该表中的数据。
我怎样才能只更改数据类型而不丢失数据?
我尝试类似:
this.alter('book_unit_question', (table) => {
table.text('correct_answer_description')
})
然后做一个:
adonis migration:run
但我明白了:
没有什么要迁移的
【问题讨论】: