You use a patch to achieve that. the patch will run automatically when you run setup:upgrade.
Create a file in your module in Setup\Patch\Data
<?php
namespace Your\Module\Setup\Patch\Data;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Framework\Setup\Patch\PatchVersionInterface;
/**
* Class UpdateCustomValue
* @package Your\Module\Setup\Patch\Data
*/
class UpdateCustomValue implements DataPatchInterface, PatchVersionInterface
{
/**
* @var ModuleDataSetupInterface
*/
private $moduleDataSetup;
/**
* @var \Magento\Directory\Helper\DataFactory
*/
private $directoryDataFactory;
/**
* InitializeDirectoryData constructor.
* @param ModuleDataSetupInterface $moduleDataSetup
* @param \Magento\Directory\Helper\DataFactory $directoryDataFactory
*/
public function __construct(
ModuleDataSetupInterface $moduleDataSetup,
\Magento\Directory\Helper\DataFactory $directoryDataFactory
) {
$this->moduleDataSetup = $moduleDataSetup;
$this->directoryDataFactory = $directoryDataFactory;
}
/**
* @inheritdoc
*
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function apply()
{
// Here replace your table name and set the
$table = $this->moduleDataSetup->getTable('your_table_name');
$this->moduleDataSetup->getConnection()->update(
$table,
['your_column_name' => 'null'],
['entity_id= ?' => 1]
);
}
/**
* @inheritdoc
*/
public static function getDependencies()
{
return [];
}
/**
* @inheritdoc
*/
public static function getVersion()
{
return '2.0.0';
}
/**
* @inheritdoc
*/
public function getAliases()
{
return [];
}
}
Note: if you want to rerun the patch in your local development environment you need to delete your patch entry from patch_list
table.