Delete default value before removing column


Hi everyone,

First api, dozen of migration files, playing up and down with “adonis migration:run” and “adonis migration:reset”.

I have a problem when I do “adonis migration:reset”, down() method is executed on each migration file and there are some of them which were made in order to add new columns.

This operation fails because I have a column with associated default value:

{ number: 4922,
state: 9,
class: 16,
message: ‘ALTER TABLE DROP COLUMN active failed because one or more objects access this column.’,
procName: ‘’,
lineNumber: 1,
name: ‘ERROR’,
event: ‘errorMessage’ } },
name: ‘RequestError’,
[ { RequestError: The object ‘DF__hosts__active__795DFB40’ is dependent on column ‘active’.

I’ve seen there would be a method removing first this values, and then dropping each column but alterTable() function is not recognized in Schema:

How can I drop columns with default value enabled?


try adjustment your foreign key add .references(‘id’).inTable(‘your_table’).onDelete(‘CASCADE’);
if not work`s maybe try .onDelete(‘SET NULL’);

look`s this my example: