I am using migration using knex.js on my sql . now there is some wrong foreign key and i want to remove it . I am using below syntax for that but it is not working . It is not showing any error but not removing foreign key also .
exports.up = function(knex, Promise) {
knex.schema.table('page_block_data', function(table) {
table.dropForeign('page_block_data_block_id_foreign');
});
};
exports.down = () => {};
Can anyone help me for this issue ..?
You are missing return from your up method. It may cause that DB connection is actually closed before query was sent to the DB server.
Also name table name prefix and postfix parts of the foreign key name is automatically generated.
try:
exports.up = function(knex, Promise) {
return knex.schema.table('page_block_data', function(table) {
table.dropForeign('block_id');
});
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With