Menu Close
    Start a Project Request quote Reading list Switch to dark mode
    magento-hyperlocal-marketplace-guide

    Setup script files in Magento2

    As the name defines: Setup script files used to perform some action on your data or table while installing or upgrading up your module.

    All the setup scripts files are created under Setup folder which is at path:

    app/code/Webkul/Test/Setup

    Setup folder contains following files:

    1) InstallSchema.php: This file is created when we want to do changes in our table structure or create a new table.
    This file is executed on installation of module.


    2) UpgradeSchema.php : This file is used to update table structure or to create a new table.
    This file is get executed whenever your module is installing or upgrading.

    There is no version restriction in the file as in magento1, so it will get execute on each version upgradation.
    This file executed after Install Schema file.


    3) InstallData.php: Used to add data in tables which are already created in your magento.
    For example all the product attributes are created by Install Data.
    This file gets executed when your module’s Install Schema.


    4) UpgradeData.php: Used to add data or update data in tables which are already created in your magento.
    For example you can update any existing product’s name or you can create a new product, or can update product’s attribute data.
    This gets executed when your module is installing or upgrading.
    This file executed after Install Data.


    5) Recurring.php: This file is used when you want to add some functionality after each module installation.
    Lets take an example:
    we have three modules Test1, Test2 and Test3.
    And we have Recurring.php file in Test1 module.
    So, Test1/Setup/Recurring.php get executed after completion of installation of all the above three modules.
    Recurruing.php file get executed on each time either module’s version updated or not.


    6) Uninstall.php : This file is executed when magento module:uninstall get executed.
    By this file All the tables and table’s data and files are deleted related to the specific module.
    This Uninstall works only on those modules which are composer dependent.


    You can check install schema in detail in blog:
    Install Schema In setup script Magento2
    You can check install data in detail in blog:
    Install Data In setup script Magento2
    Another example of Install Data In setup script to create product Magento2

    Hope this blog will help in setting up your magento.

    . . .

    Comment

    Add Your Comment

    Be the first to comment.

    Back to Top
    css.php
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just recieved your project brief and our expert will contact you shortly.
    Send Again
    Close