Today I will be discussing How to Apply Schema Patch in Magento 2.

Schema patch is a class in Magento 2 that contains schema modification instructions so you can add, update, or delete columns in any custom table or EAV table.

Here, we are adding a new column in the existing table (“custom_table”) using schema patch.

Steps to Apply Schema Patch in Magento 2:

Step 1:  We need to create an “AddColumn.php” file inside our extension at the following path.

app\code\Vendor\Extension\Setup\Patch\Schema\

Then add the code as follows

Step 2: After adding this file run the Magento upgrade command

Conclusion:

This way you can Apply Schema PAtch in Magento 2. Alternatively, learn How to Use Data Patch in Magento 2. In case you have any doubt let me know through the comment section. Stay in touch with us for more.

Happy Coding!

Click to rate this post!
[Total: 3 Average: 5]