We have a custom boolean customer attribute created from installSchema script like below:
$eavSetup->addAttribute(
\Magento\Customer\Model\Customer::ENTITY,
'test_attribute',
[
'label' => 'Test Attribute',
'input' => 'select',
'source' => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean',
'default' => 0,
'required' => false,
'visible' => true,
'system' => false,
'filterable' => false,
'is_used_in_grid' => false,
'is_filterable_in_grid' => false,
'is_searchable_in_grid' => false,
]
);
I need to change the default value to "1" for this attribute through upgradeSchema. Tried below code for the same in upgrade schema:
if (version_compare($context->getVersion(), '1.1.0', '<')) {
$this->eavSetupFactory->create()->updateAttribute(\Magento\Customer\Model\Customer::ENTITY, 'test_attribute', 'default', 1);
}
But, it didn't worked. The default value is still No, also verified in eav_attribute table in database. I can also confirm that the upgrade schema is working and the if condition for version compare is also working. The version in setup_module table is also getting updated. Are there any changes needed to the updateAttribute method call? Please assist.