down() {
this.table('inbox_messages', table => {
// reverse alternations
table.dropForeign('created_by')
table.dropColumn('created_by')
})
}
class LessonQuestionsLessonIdForeignSchema extends Schema {
up() {
this.alter('lesson_questions', (table) => {
// drop existing foreign relationship on column 'lession_id'
table.dropForeign('lesson_id')
// alter table
table
.integer('lesson_id')
.unsigned()
.notNullable()
.references('id')
.inTable('lessons')
.onUpdate('CASCADE')
.onDelete('SET NULL')
.alter()
})
}
}
Tip
Regex g flag create global state that returns true and false between exec and test calls.
queryReports
.with('meterSerial', builder => {
builder.where('serial_number', meterSerialNumber)
})
.whereHas('meterSerial', builder => {
builder.where('serial_number', meterSerialNumber)
})
return await noteItem
.meterSerials()
.with('tableReports', builder => {
builder.where('fiscal_note_item_id', params.noteItemId).withPivot(['approved'])
})
.fetch()
builder.setVisible(['id', 'approved', 'meter_serial_id', 'table_report_id'])