I have upgraded my Magento version from 2.2.7 to 2.3.2. I am working on a module where I have to create a table and insert some sample data.
As per the new conventions introduced in Magento 2.3.x, I created the table using app/code/[Packagename]/[Modulename]/etc/db_schema.xml. The table has been created successfully.
Now, I am trying to add data to the table using the patch file app/code/[Packagename]/[Modulename]/Setup/Patch/Data/InsertTemplates.php
The apply() function code is as follows:
public function apply()
{
$data = array();
$data[0]['template_name'] = __('Default Template 1');
$data[0]['style_color'] = '#DC8C71';
$data[0]['text_color'] = '#949392';
$data[0]['caption'] = __('Gift Card');
$data[1]['template_name'] = __('Default Template 2');
$data[1]['style_color'] = '#DC8C71';
$data[1]['text_color'] = '#636363';
$data[1]['caption'] = __('Gift Card');
}
When I run the following commands:
php bin/magento setup:db-declaration:generate-whitelist --module-name=[Packagename]_[Modulename]
php bin/magento s:up
Both commands are running successfully, but the data is not being inserted into the table.
Can anyone help me understand, what can be the problem.