Magento Development 03: Creating Tables
<?xml version="1.0"?>
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
<table name="blogmanager_blog" resource="default" engine="innodb" comment="Blogs Table">
<column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="true" comment="Entity Id"/>
<column xsi:type="int" name="user_id" padding="10" unsigned="true" nullable="false" comment="Customer/User Id"/>
<column xsi:type="varchar" name="title" nullable="false" length="255" comment="Blog Title"/>
<column xsi:type="longtext" name="content" nullable="false" comment="Blog Content"/>
<column xsi:type="smallint" name="status" padding="11" unsigned="false" nullable="false" default="0" comment="Blog Status"/>
<column xsi:type="timestamp" name="created_at" on_update="false" nullable="false" default="CURRENT_TIMESTAMP" comment="Creation Time"/>
<column xsi:type="timestamp" name="updated_at" on_update="true" nullable="false" default="CURRENT_TIMESTAMP" comment="Updated At"/>
<constraint xsi:type="primary" referenceId="PRIMARY">
<column name="entity_id"/>
</constraint>
<index referenceId="BLOGMANAGER_BLOG_USER_ID" indexType="btree">
<column name="user_id"/>
</index>
</table>
<table name="blogmanager_comment" resource="default" engine="innodb" comment="Blog Comments Table">
<column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="true" comment="Entity Id"/>
<column xsi:type="int" name="blog_id" padding="10" unsigned="true" nullable="false" comment="Blog Id"/>
<column xsi:type="int" name="user_id" padding="10" unsigned="true" nullable="false" comment="User Id"/>
<column xsi:type="varchar" name="screen_name" nullable="false" length="255" comment="Screen Name"/>
<column xsi:type="text" name="comment" nullable="false" comment="Comment"/>
<column xsi:type="smallint" name="status" padding="11" unsigned="false" nullable="false" default="0" comment="Status"/>
<column xsi:type="timestamp" name="created_at" on_update="false" nullable="false" default="CURRENT_TIMESTAMP" comment="Creation Time"/>
<constraint xsi:type="primary" referenceId="PRIMARY">
<column name="entity_id"/>
</constraint>
<constraint xsi:type="foreign" referenceId="FK_BLOG_COMMENT" table="blogmanager_comment" column="blog_id" referenceTable="blogmanager_blog" referenceColumn="entity_id" onDelete="CASCADE"/>
<index referenceId="BLOGMANAGER_COMMENT_BLOG_ID" indexType="btree">
<column name="blog_id"/>
</index>
</table>
</schema>
Advertising by Adpathway




