See the way CMS Upgrade Scripts for Magento 2 extension works.
Simplify the development process and save time on data migration with CMS Upgrade Scripts for Magento. With this extension you can:
How to generate CMS upgrade file:
1. Enter a special prefix for cms upgrade file: Stores → Configuration → Ewave → CMS Upgrade 2. Then navigate to any of the suggested pages: (e.g. Widget)
The widget page should be opened.
3. Select all widgets and in the Actions dropdown select Generate Upgrade Script. Also, Admin can select and generate only one widget. 4. Click Submit button
The message should be displayed about file location with information from which version to which version the file is generated and a new data version 5. Delete any widget or do some changes in any widget. This is necessary in order to see the changes later after applying the file.
6. In the database in the table “ewave_cms_upgrade_installed_files” the admin can see all generated files with entering prefix or without prefix. In the database in the table “ewave_cms_upgarde_data_version” admin can see which data version is installed now.
7. Then to apply the generated file need to navigate to store root folder in the SSH console and run the following command:
php bin/magento ewave:cms_upgrade {data version}
. E.g.:
php bin/magento ewave:cms_upgrade 0.0.6-0.0.7.
8. If the current version does not match the version from which the file was generated, it is necessary to change the current version in the database to the required one.
9. Then navigate to the Widget page and you can see that deleted widget display again or widget data before the change.
10. Example how to generate script for the configuration settings:
Find out how to install the CMS Upgrade Scripts extension for Magento 2 via Composer.