How to upgrade database table in magento 2?

When You need to add a new field in the existing table, you need to create UpgradeSchema.php file in Setup folder of your module.

We add new address field in our existing table by below way, We have just create a database table in the previous post, Create Database table in Magento 2

Run php bin/magento setup:upgrade

Now you can check your new address field is display in your create_form table.

How to create database table in magento 2?

In Magento 2, You need to create InstallSchema.php file in Setup folder under your module. In my case, Module name is Rbj_Training,

Below code snippets is create database table name of create_form.

Above script create create_form table with 4 fields, entity_id,name,phone_no,image

entity_id is an auto-increment field, a name is for name display, phone_no used for phone and image is for image name store.

How to create a simple Hello World module in Magento 2?

Create a Simple Hello World Module using Magento 2 is the Entry point for Learning a Magento 2.

Simple Module to display, Hello World in the browser is used for Beginner of Magento Developer who wants to explore Magento 2 in depth. Continue reading “How to create a simple Hello World module in Magento 2?”