I am working on an Adonis JS project. I want to do the equivalent of ALTER TABLE products DROP CONSTRAINT unique_col_id where the unique_col_id is responsible for products.sku to be unique.
I tried this in AdonisJS database/migrations/filename.js:
'use strict'
/** @type {import('@adonisjs/lucid/src/Schema')} */
const Schema = use('Schema')
class ProductsAlterUniqueSkuSchema extends Schema {
up () {
this.alter('products', (table) => {
// alter table
table.integer('sku').unique(false);
})
}
down () {
this.table('products', (table) => {
// reverse alternations
})
}
}
module.exports = ProductsAlterUniqueSkuSchema
But I get the error Error: Duplicate column name 'sku'. How do I tell AdonisJS migration script to alter the table schema to drop the constraint?