Before creating the files, need to create the Setup folder at app/code/Or**/En**/Setup
After created the folders, need create a InstallSchema.php file in app/code/Or**/En**/Setup/InstallSchema.php And paste the below code:

namespace or**\En**\Setup;

use Magento\Framework\Setup\InstallSchemaInterface;

use Magento\Framework\Setup\ModuleContextInterface;

use Magento\Framework\Setup\SchemaSetupInterface;

 

class InstallSchema implements InstallSchemaInterface

{

public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)

{

$installer = $setup;

$installer->startSetup();

 

if ( ! $installer->tableExists(‘order_enquiry_items’)) {

$table = $installer->getConnection()->newTable(

$installer->getTable(‘order_enquiry_items’)

)

->addColumn(

‘id’,

\Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,

null,

[

‘identity’ => true,

‘nullable’ => false,

‘primary’  => true,

‘unsigned’ => true,

],

‘ID’

)

->addColumn(

‘name’,

\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,

255,

[‘nullable => false’],

‘Name’

)

->addColumn(

‘client_id’,

\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,

255,

[‘nullable => false’],

‘Client Id’

)

->addColumn(

‘order_number’,

\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,

255,

[‘nullable => false’],

‘Order Number’

)

->addColumn(

‘enquiry_content’,

\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,

’64k’,

[],

‘Enquiry Content’

)

->addColumn(

‘attachment’,

\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,

255,

[],

‘Attachment’

)

->addColumn(

‘enabled’,

\Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,

1,

[],

‘Enabled’

)

->addColumn(

‘created_at’,

\Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP,

null,

[],

‘Created At’

);

$installer->getConnection()->createTable($table);

}

$installer->endSetup();

}

}

More Article


0 thoughts on “Create Custom Database Table Or InstallSchema in Magento 2”

Leave a Reply

Related Article

Blog

Om Beach: Gokarna, Karnataka, India

The modest sanctuary town of Gokarna gloats a modest bunch of shorelines worth going by, yet Om Beach named because of its normal similarity of the Om image makes our rundown on account of its Read more…

Blog

Chowpatty Beach: Mumbai, Maharashtra, India

Chowpatty Beach is an unquestionable requirement visit for sightseers going by Mumbai, particularly amid Ganesh Chaturthi, a Hindu celebration celebrated out of appreciation for the divinity Ganesha. The celebration, which ordinarily happens in August or Read more…

Blog

Could White Wine increase Your Melanoma Risk?

Another review raises the likelihood that individuals who appreciate a glass of white wine each day may confront a somewhat lifted danger of melanoma. Add up to liquor admission was connected with a 14 percent Read more…