Magento 2.3 : How to implement declarative schema in custom module
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty{ margin-bottom:0;
}
up vote
4
down vote
favorite
I install the magento 2.3 and I'm creating custom module.
But, I don't know how to create custom database in magento 2.3 version.
Anyone please help me.
Thanks in advance.
magento2.3 database-schema
New contributor
add a comment |
up vote
4
down vote
favorite
I install the magento 2.3 and I'm creating custom module.
But, I don't know how to create custom database in magento 2.3 version.
Anyone please help me.
Thanks in advance.
magento2.3 database-schema
New contributor
1
database Or custom table in Magento database?
– Pawan
Nov 30 at 3:30
add a comment |
up vote
4
down vote
favorite
up vote
4
down vote
favorite
I install the magento 2.3 and I'm creating custom module.
But, I don't know how to create custom database in magento 2.3 version.
Anyone please help me.
Thanks in advance.
magento2.3 database-schema
New contributor
I install the magento 2.3 and I'm creating custom module.
But, I don't know how to create custom database in magento 2.3 version.
Anyone please help me.
Thanks in advance.
magento2.3 database-schema
magento2.3 database-schema
New contributor
New contributor
edited Nov 30 at 3:29
Rohan Hapani
5,33321560
5,33321560
New contributor
asked Nov 30 at 3:19
harsh khandhar
233
233
New contributor
New contributor
1
database Or custom table in Magento database?
– Pawan
Nov 30 at 3:30
add a comment |
1
database Or custom table in Magento database?
– Pawan
Nov 30 at 3:30
1
1
database Or custom table in Magento database?
– Pawan
Nov 30 at 3:30
database Or custom table in Magento database?
– Pawan
Nov 30 at 3:30
add a comment |
2 Answers
2
active
oldest
votes
up vote
5
down vote
accepted
First of all, create db_schema.xml
file inside /RH/Helloworld/etc
and write the following code :
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
<table name="rh_helloworld" resource="default" engine="innodb" comment="RH Helloworld">
<column xsi:type="smallint" name="id" padding="6" unsigned="false" nullable="false" identity="true" comment="ID"/>
<column xsi:type="varchar" name="author_name" nullable="false" length="25" comment="Name"/>
<column xsi:type="varchar" name="email" nullable="false" length="25" comment="Email"/>
<column xsi:type="varchar" name="description" nullable="false" length="255" comment="Descrition"/>
<constraint xsi:type="primary" name="PRIMARY">
<column name="id"/>
</constraint>
</table>
</schema>
<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 like
primary 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 :
php bin/magento setup:db-declaration:generate-whitelist --module-name=RH_Helloworld
Now, there are db_whitelist_schema.json
file will be create in /RH/Helloworld/etc
folder.
Now, run php bin/magento s:up
Table will be create inside database.
=> If you want to renaming a column, you need to set below line in your db_schema.xml
at appropriate column :
<column xsi:type="varchar" name="customer_email" onCreate="migrateDataFrom(email)" on_update="false" nullable="false" default="" comment="Customer Email"/>
here, name = "new column name" and onCreate="migrateDataFrom()" = "old column name"
=> If you want to drop table, then you can either remove entire table node from xml file or you can set disabled attribute to true as like below line in your db_schema.xml
:
<table name="rh_helloworld" resource="default" engine="innodb" comment="RH Helloworld" disabled="true">
..
</table>
Hope, It will helpful for you.
1
Good one @Rohan
– Ramkishan Suthar
Nov 30 at 4:36
Nice explanation..... Thank you so much.... It is really helpful....
– harsh khandhar
Nov 30 at 10:29
Happy to help !! Happy coding :) & Thank You @RamkishanSuthar
– Rohan Hapani
Nov 30 at 10:31
add a comment |
up vote
1
down vote
Create file named as db_schema.xml under etc folder in your any custom module.
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
<table name="books_data" resource="default" engine="innodb" comment="Book Table">
<column xsi:type="smallint" name="id" padding="6" unsigned="false" nullable="false" identity="true" comment="BOOK ID"/>
<column xsi:type="varchar" name="book_name" nullable="false" length="255" comment="Book Name"/>
<column xsi:type="int" name="author" unsigned="true" nullable="true" identity="false" default="" comment="Author"/>
<column xsi:type="varchar" name="isbn_no" nullable="true" comment="ISBN No"/>
<column xsi:type="timestamp" name="publish_date" on_update="false" nullable="false" default="CURRENT_TIMESTAMP"
comment="Publish Date"/>
<column xsi:type="varchar" name="language" nullable="true" comment="Language"/>
<column xsi:type="decimal" name="mrp" scale="4" precision="12" unsigned="false" nullable="false"
default="0" comment="MRP"/>
<constraint xsi:type="primary" name="PRIMARY">
<column name="id"/>
</constraint>
</table>
<table name="author_data" resource="default" engine="innodb" comment="Author Table">
<column xsi:type="smallint" name="id" padding="6" unsigned="false" nullable="false" identity="true" comment="Author ID"/>
<column xsi:type="varchar" name="author_name" nullable="false" length="255" comment="Author Name"/>
<column xsi:type="varchar" name="author_email" nullable="false" length="255" comment="Author Email"/>
<column xsi:type="varchar" name="affliation" nullable="false" length="255" comment="Affliation"/>
<column xsi:type="int" name="age" unsigned="true" nullable="true" identity="false" default="" comment="Age"/>
<constraint xsi:type="primary" name="PRIMARY">
<column name="id"/>
</constraint>
</table>
</schema>
Now create db_whitelist_schema.json at same path
php bin/magento setup:db-declaration:generate-whitelist --module-name=Vendor_Module
After that just run php bin/magento setup:upgrade. For more information you can check Here . Let me know in case you need more explanation on this.
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
5
down vote
accepted
First of all, create db_schema.xml
file inside /RH/Helloworld/etc
and write the following code :
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
<table name="rh_helloworld" resource="default" engine="innodb" comment="RH Helloworld">
<column xsi:type="smallint" name="id" padding="6" unsigned="false" nullable="false" identity="true" comment="ID"/>
<column xsi:type="varchar" name="author_name" nullable="false" length="25" comment="Name"/>
<column xsi:type="varchar" name="email" nullable="false" length="25" comment="Email"/>
<column xsi:type="varchar" name="description" nullable="false" length="255" comment="Descrition"/>
<constraint xsi:type="primary" name="PRIMARY">
<column name="id"/>
</constraint>
</table>
</schema>
<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 like
primary 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 :
php bin/magento setup:db-declaration:generate-whitelist --module-name=RH_Helloworld
Now, there are db_whitelist_schema.json
file will be create in /RH/Helloworld/etc
folder.
Now, run php bin/magento s:up
Table will be create inside database.
=> If you want to renaming a column, you need to set below line in your db_schema.xml
at appropriate column :
<column xsi:type="varchar" name="customer_email" onCreate="migrateDataFrom(email)" on_update="false" nullable="false" default="" comment="Customer Email"/>
here, name = "new column name" and onCreate="migrateDataFrom()" = "old column name"
=> If you want to drop table, then you can either remove entire table node from xml file or you can set disabled attribute to true as like below line in your db_schema.xml
:
<table name="rh_helloworld" resource="default" engine="innodb" comment="RH Helloworld" disabled="true">
..
</table>
Hope, It will helpful for you.
1
Good one @Rohan
– Ramkishan Suthar
Nov 30 at 4:36
Nice explanation..... Thank you so much.... It is really helpful....
– harsh khandhar
Nov 30 at 10:29
Happy to help !! Happy coding :) & Thank You @RamkishanSuthar
– Rohan Hapani
Nov 30 at 10:31
add a comment |
up vote
5
down vote
accepted
First of all, create db_schema.xml
file inside /RH/Helloworld/etc
and write the following code :
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
<table name="rh_helloworld" resource="default" engine="innodb" comment="RH Helloworld">
<column xsi:type="smallint" name="id" padding="6" unsigned="false" nullable="false" identity="true" comment="ID"/>
<column xsi:type="varchar" name="author_name" nullable="false" length="25" comment="Name"/>
<column xsi:type="varchar" name="email" nullable="false" length="25" comment="Email"/>
<column xsi:type="varchar" name="description" nullable="false" length="255" comment="Descrition"/>
<constraint xsi:type="primary" name="PRIMARY">
<column name="id"/>
</constraint>
</table>
</schema>
<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 like
primary 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 :
php bin/magento setup:db-declaration:generate-whitelist --module-name=RH_Helloworld
Now, there are db_whitelist_schema.json
file will be create in /RH/Helloworld/etc
folder.
Now, run php bin/magento s:up
Table will be create inside database.
=> If you want to renaming a column, you need to set below line in your db_schema.xml
at appropriate column :
<column xsi:type="varchar" name="customer_email" onCreate="migrateDataFrom(email)" on_update="false" nullable="false" default="" comment="Customer Email"/>
here, name = "new column name" and onCreate="migrateDataFrom()" = "old column name"
=> If you want to drop table, then you can either remove entire table node from xml file or you can set disabled attribute to true as like below line in your db_schema.xml
:
<table name="rh_helloworld" resource="default" engine="innodb" comment="RH Helloworld" disabled="true">
..
</table>
Hope, It will helpful for you.
1
Good one @Rohan
– Ramkishan Suthar
Nov 30 at 4:36
Nice explanation..... Thank you so much.... It is really helpful....
– harsh khandhar
Nov 30 at 10:29
Happy to help !! Happy coding :) & Thank You @RamkishanSuthar
– Rohan Hapani
Nov 30 at 10:31
add a comment |
up vote
5
down vote
accepted
up vote
5
down vote
accepted
First of all, create db_schema.xml
file inside /RH/Helloworld/etc
and write the following code :
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
<table name="rh_helloworld" resource="default" engine="innodb" comment="RH Helloworld">
<column xsi:type="smallint" name="id" padding="6" unsigned="false" nullable="false" identity="true" comment="ID"/>
<column xsi:type="varchar" name="author_name" nullable="false" length="25" comment="Name"/>
<column xsi:type="varchar" name="email" nullable="false" length="25" comment="Email"/>
<column xsi:type="varchar" name="description" nullable="false" length="255" comment="Descrition"/>
<constraint xsi:type="primary" name="PRIMARY">
<column name="id"/>
</constraint>
</table>
</schema>
<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 like
primary 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 :
php bin/magento setup:db-declaration:generate-whitelist --module-name=RH_Helloworld
Now, there are db_whitelist_schema.json
file will be create in /RH/Helloworld/etc
folder.
Now, run php bin/magento s:up
Table will be create inside database.
=> If you want to renaming a column, you need to set below line in your db_schema.xml
at appropriate column :
<column xsi:type="varchar" name="customer_email" onCreate="migrateDataFrom(email)" on_update="false" nullable="false" default="" comment="Customer Email"/>
here, name = "new column name" and onCreate="migrateDataFrom()" = "old column name"
=> If you want to drop table, then you can either remove entire table node from xml file or you can set disabled attribute to true as like below line in your db_schema.xml
:
<table name="rh_helloworld" resource="default" engine="innodb" comment="RH Helloworld" disabled="true">
..
</table>
Hope, It will helpful for you.
First of all, create db_schema.xml
file inside /RH/Helloworld/etc
and write the following code :
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
<table name="rh_helloworld" resource="default" engine="innodb" comment="RH Helloworld">
<column xsi:type="smallint" name="id" padding="6" unsigned="false" nullable="false" identity="true" comment="ID"/>
<column xsi:type="varchar" name="author_name" nullable="false" length="25" comment="Name"/>
<column xsi:type="varchar" name="email" nullable="false" length="25" comment="Email"/>
<column xsi:type="varchar" name="description" nullable="false" length="255" comment="Descrition"/>
<constraint xsi:type="primary" name="PRIMARY">
<column name="id"/>
</constraint>
</table>
</schema>
<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 like
primary 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 :
php bin/magento setup:db-declaration:generate-whitelist --module-name=RH_Helloworld
Now, there are db_whitelist_schema.json
file will be create in /RH/Helloworld/etc
folder.
Now, run php bin/magento s:up
Table will be create inside database.
=> If you want to renaming a column, you need to set below line in your db_schema.xml
at appropriate column :
<column xsi:type="varchar" name="customer_email" onCreate="migrateDataFrom(email)" on_update="false" nullable="false" default="" comment="Customer Email"/>
here, name = "new column name" and onCreate="migrateDataFrom()" = "old column name"
=> If you want to drop table, then you can either remove entire table node from xml file or you can set disabled attribute to true as like below line in your db_schema.xml
:
<table name="rh_helloworld" resource="default" engine="innodb" comment="RH Helloworld" disabled="true">
..
</table>
Hope, It will helpful for you.
answered Nov 30 at 3:49
Rohan Hapani
5,33321560
5,33321560
1
Good one @Rohan
– Ramkishan Suthar
Nov 30 at 4:36
Nice explanation..... Thank you so much.... It is really helpful....
– harsh khandhar
Nov 30 at 10:29
Happy to help !! Happy coding :) & Thank You @RamkishanSuthar
– Rohan Hapani
Nov 30 at 10:31
add a comment |
1
Good one @Rohan
– Ramkishan Suthar
Nov 30 at 4:36
Nice explanation..... Thank you so much.... It is really helpful....
– harsh khandhar
Nov 30 at 10:29
Happy to help !! Happy coding :) & Thank You @RamkishanSuthar
– Rohan Hapani
Nov 30 at 10:31
1
1
Good one @Rohan
– Ramkishan Suthar
Nov 30 at 4:36
Good one @Rohan
– Ramkishan Suthar
Nov 30 at 4:36
Nice explanation..... Thank you so much.... It is really helpful....
– harsh khandhar
Nov 30 at 10:29
Nice explanation..... Thank you so much.... It is really helpful....
– harsh khandhar
Nov 30 at 10:29
Happy to help !! Happy coding :) & Thank You @RamkishanSuthar
– Rohan Hapani
Nov 30 at 10:31
Happy to help !! Happy coding :) & Thank You @RamkishanSuthar
– Rohan Hapani
Nov 30 at 10:31
add a comment |
up vote
1
down vote
Create file named as db_schema.xml under etc folder in your any custom module.
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
<table name="books_data" resource="default" engine="innodb" comment="Book Table">
<column xsi:type="smallint" name="id" padding="6" unsigned="false" nullable="false" identity="true" comment="BOOK ID"/>
<column xsi:type="varchar" name="book_name" nullable="false" length="255" comment="Book Name"/>
<column xsi:type="int" name="author" unsigned="true" nullable="true" identity="false" default="" comment="Author"/>
<column xsi:type="varchar" name="isbn_no" nullable="true" comment="ISBN No"/>
<column xsi:type="timestamp" name="publish_date" on_update="false" nullable="false" default="CURRENT_TIMESTAMP"
comment="Publish Date"/>
<column xsi:type="varchar" name="language" nullable="true" comment="Language"/>
<column xsi:type="decimal" name="mrp" scale="4" precision="12" unsigned="false" nullable="false"
default="0" comment="MRP"/>
<constraint xsi:type="primary" name="PRIMARY">
<column name="id"/>
</constraint>
</table>
<table name="author_data" resource="default" engine="innodb" comment="Author Table">
<column xsi:type="smallint" name="id" padding="6" unsigned="false" nullable="false" identity="true" comment="Author ID"/>
<column xsi:type="varchar" name="author_name" nullable="false" length="255" comment="Author Name"/>
<column xsi:type="varchar" name="author_email" nullable="false" length="255" comment="Author Email"/>
<column xsi:type="varchar" name="affliation" nullable="false" length="255" comment="Affliation"/>
<column xsi:type="int" name="age" unsigned="true" nullable="true" identity="false" default="" comment="Age"/>
<constraint xsi:type="primary" name="PRIMARY">
<column name="id"/>
</constraint>
</table>
</schema>
Now create db_whitelist_schema.json at same path
php bin/magento setup:db-declaration:generate-whitelist --module-name=Vendor_Module
After that just run php bin/magento setup:upgrade. For more information you can check Here . Let me know in case you need more explanation on this.
add a comment |
up vote
1
down vote
Create file named as db_schema.xml under etc folder in your any custom module.
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
<table name="books_data" resource="default" engine="innodb" comment="Book Table">
<column xsi:type="smallint" name="id" padding="6" unsigned="false" nullable="false" identity="true" comment="BOOK ID"/>
<column xsi:type="varchar" name="book_name" nullable="false" length="255" comment="Book Name"/>
<column xsi:type="int" name="author" unsigned="true" nullable="true" identity="false" default="" comment="Author"/>
<column xsi:type="varchar" name="isbn_no" nullable="true" comment="ISBN No"/>
<column xsi:type="timestamp" name="publish_date" on_update="false" nullable="false" default="CURRENT_TIMESTAMP"
comment="Publish Date"/>
<column xsi:type="varchar" name="language" nullable="true" comment="Language"/>
<column xsi:type="decimal" name="mrp" scale="4" precision="12" unsigned="false" nullable="false"
default="0" comment="MRP"/>
<constraint xsi:type="primary" name="PRIMARY">
<column name="id"/>
</constraint>
</table>
<table name="author_data" resource="default" engine="innodb" comment="Author Table">
<column xsi:type="smallint" name="id" padding="6" unsigned="false" nullable="false" identity="true" comment="Author ID"/>
<column xsi:type="varchar" name="author_name" nullable="false" length="255" comment="Author Name"/>
<column xsi:type="varchar" name="author_email" nullable="false" length="255" comment="Author Email"/>
<column xsi:type="varchar" name="affliation" nullable="false" length="255" comment="Affliation"/>
<column xsi:type="int" name="age" unsigned="true" nullable="true" identity="false" default="" comment="Age"/>
<constraint xsi:type="primary" name="PRIMARY">
<column name="id"/>
</constraint>
</table>
</schema>
Now create db_whitelist_schema.json at same path
php bin/magento setup:db-declaration:generate-whitelist --module-name=Vendor_Module
After that just run php bin/magento setup:upgrade. For more information you can check Here . Let me know in case you need more explanation on this.
add a comment |
up vote
1
down vote
up vote
1
down vote
Create file named as db_schema.xml under etc folder in your any custom module.
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
<table name="books_data" resource="default" engine="innodb" comment="Book Table">
<column xsi:type="smallint" name="id" padding="6" unsigned="false" nullable="false" identity="true" comment="BOOK ID"/>
<column xsi:type="varchar" name="book_name" nullable="false" length="255" comment="Book Name"/>
<column xsi:type="int" name="author" unsigned="true" nullable="true" identity="false" default="" comment="Author"/>
<column xsi:type="varchar" name="isbn_no" nullable="true" comment="ISBN No"/>
<column xsi:type="timestamp" name="publish_date" on_update="false" nullable="false" default="CURRENT_TIMESTAMP"
comment="Publish Date"/>
<column xsi:type="varchar" name="language" nullable="true" comment="Language"/>
<column xsi:type="decimal" name="mrp" scale="4" precision="12" unsigned="false" nullable="false"
default="0" comment="MRP"/>
<constraint xsi:type="primary" name="PRIMARY">
<column name="id"/>
</constraint>
</table>
<table name="author_data" resource="default" engine="innodb" comment="Author Table">
<column xsi:type="smallint" name="id" padding="6" unsigned="false" nullable="false" identity="true" comment="Author ID"/>
<column xsi:type="varchar" name="author_name" nullable="false" length="255" comment="Author Name"/>
<column xsi:type="varchar" name="author_email" nullable="false" length="255" comment="Author Email"/>
<column xsi:type="varchar" name="affliation" nullable="false" length="255" comment="Affliation"/>
<column xsi:type="int" name="age" unsigned="true" nullable="true" identity="false" default="" comment="Age"/>
<constraint xsi:type="primary" name="PRIMARY">
<column name="id"/>
</constraint>
</table>
</schema>
Now create db_whitelist_schema.json at same path
php bin/magento setup:db-declaration:generate-whitelist --module-name=Vendor_Module
After that just run php bin/magento setup:upgrade. For more information you can check Here . Let me know in case you need more explanation on this.
Create file named as db_schema.xml under etc folder in your any custom module.
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
<table name="books_data" resource="default" engine="innodb" comment="Book Table">
<column xsi:type="smallint" name="id" padding="6" unsigned="false" nullable="false" identity="true" comment="BOOK ID"/>
<column xsi:type="varchar" name="book_name" nullable="false" length="255" comment="Book Name"/>
<column xsi:type="int" name="author" unsigned="true" nullable="true" identity="false" default="" comment="Author"/>
<column xsi:type="varchar" name="isbn_no" nullable="true" comment="ISBN No"/>
<column xsi:type="timestamp" name="publish_date" on_update="false" nullable="false" default="CURRENT_TIMESTAMP"
comment="Publish Date"/>
<column xsi:type="varchar" name="language" nullable="true" comment="Language"/>
<column xsi:type="decimal" name="mrp" scale="4" precision="12" unsigned="false" nullable="false"
default="0" comment="MRP"/>
<constraint xsi:type="primary" name="PRIMARY">
<column name="id"/>
</constraint>
</table>
<table name="author_data" resource="default" engine="innodb" comment="Author Table">
<column xsi:type="smallint" name="id" padding="6" unsigned="false" nullable="false" identity="true" comment="Author ID"/>
<column xsi:type="varchar" name="author_name" nullable="false" length="255" comment="Author Name"/>
<column xsi:type="varchar" name="author_email" nullable="false" length="255" comment="Author Email"/>
<column xsi:type="varchar" name="affliation" nullable="false" length="255" comment="Affliation"/>
<column xsi:type="int" name="age" unsigned="true" nullable="true" identity="false" default="" comment="Age"/>
<constraint xsi:type="primary" name="PRIMARY">
<column name="id"/>
</constraint>
</table>
</schema>
Now create db_whitelist_schema.json at same path
php bin/magento setup:db-declaration:generate-whitelist --module-name=Vendor_Module
After that just run php bin/magento setup:upgrade. For more information you can check Here . Let me know in case you need more explanation on this.
answered Nov 30 at 3:32
Ramkishan Suthar
1,9041932
1,9041932
add a comment |
add a comment |
harsh khandhar is a new contributor. Be nice, and check out our Code of Conduct.
harsh khandhar is a new contributor. Be nice, and check out our Code of Conduct.
harsh khandhar is a new contributor. Be nice, and check out our Code of Conduct.
harsh khandhar is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f251884%2fmagento-2-3-how-to-implement-declarative-schema-in-custom-module%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
database Or custom table in Magento database?
– Pawan
Nov 30 at 3:30