I want to create my custom table in my custom module. how to create it in Magento 2.3. Is there any other way of install schema? I know for magento 1.9.
I want to create my custom table in my custom module. how to create it in Magento 2.3. Is there any other way of install schema? I know for magento 1.9.
2
Answers
From magento 2.3 their is new way of installing schema. You have to create new xml file in etc/db_schema.xml for installing schema.
for more detail please check the file at vendor/magento/module-cms/etc/db_schema.xml
First of all, create
db_schema.xml
file inside/Vendor/Module/etc
and write the following code :<table> .. </table>
= “Use for create and set table name”<column> .. </column>
= “Use for create and set column of the table”<constraint> .. </constraint>
= “Use for set constraint as likeprimary key, foreign key, unique key etc.”
Before running the upgrade command you need to add your schema to
db_whitelist_schema.json
file by running the following command :Now, there are db_whitelist_schema.json file will be create in
/vendor/module/etc
folder.