I tried to use every single logic in my mind to resolve this problem, but this is the only solution that it worked.
knex.schema.createTable('documents', (table) => {
table.integer('id').unsigned().notNullable().unique()
table.string('path')
table.enum('type', ['CPF', 'RG'])
table.integer('user_id').unsigned().notNullable()
table.foreign('user_id').references('id').inTable('users')
table.primary(['id', 'user_id'])
table.timestamps(true, true)
})
knex.schema.alterTable(this.tableName, (table) => {
table.increments('id', { primaryKey: false }).alter()
})
}