I have this class:
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')
}
}
I need to change the data type of the column correct_answer_description
to text
.
If i change my actually up()
method to:
table.text('correct_answer_description')
and make a: adonis migration:refresh
All table is recreated and i lose the data in this table.
How i can only change the datatype without lose the data?
I try something like:
this.alter('book_unit_question', (table) => {
table.text('correct_answer_description')
})
And make a:
adonis migration:run
But i get:
Nothing to migrate
enu
then I try to change the value of this column then how do this without losing data? if try above solution then give me error{ error: syntax error at or near "check"
– Kythera