-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CREACION DE TABLA [mageplaza_helloworld_post] la tabla se creo sin datos
- Loading branch information
1 parent
16f8c38
commit 6fdc2db
Showing
3 changed files
with
202 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<?php | ||
namespace Mageplaza\HelloWorld\Setup; | ||
|
||
class InstallSchema implements \Magento\Framework\Setup\InstallSchemaInterface | ||
{ | ||
|
||
public function install(\Magento\Framework\Setup\SchemaSetupInterface $setup, \Magento\Framework\Setup\ModuleContextInterface $context) | ||
{ | ||
$installer = $setup; | ||
$installer->startSetup(); | ||
if (!$installer->tableExists('mageplaza_helloworld_post')) { | ||
$table = $installer->getConnection()->newTable( | ||
$installer->getTable('mageplaza_helloworld_post') | ||
) | ||
->addColumn( | ||
'post_id', | ||
\Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, | ||
null, | ||
[ | ||
'identity' => true, | ||
'nullable' => false, | ||
'primary' => true, | ||
'unsigned' => true, | ||
], | ||
'Post ID' | ||
) | ||
->addColumn( | ||
'name', | ||
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT, | ||
255, | ||
['nullable => false'], | ||
'Post Name' | ||
) | ||
->addColumn( | ||
'url_key', | ||
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT, | ||
255, | ||
[], | ||
'Post URL Key' | ||
) | ||
->addColumn( | ||
'post_content', | ||
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT, | ||
'64k', | ||
[], | ||
'Post Post Content' | ||
) | ||
->addColumn( | ||
'tags', | ||
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT, | ||
255, | ||
[], | ||
'Post Tags' | ||
) | ||
->addColumn( | ||
'status', | ||
\Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, | ||
1, | ||
[], | ||
'Post Status' | ||
) | ||
->addColumn( | ||
'featured_image', | ||
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT, | ||
255, | ||
[], | ||
'Post Featured Image' | ||
) | ||
->addColumn( | ||
'created_at', | ||
\Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, | ||
null, | ||
['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT], | ||
'Created At' | ||
)->addColumn( | ||
'updated_at', | ||
\Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, | ||
null, | ||
['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT_UPDATE], | ||
'Updated At') | ||
->setComment('Post Table'); | ||
$installer->getConnection()->createTable($table); | ||
|
||
$installer->getConnection()->addIndex( | ||
$installer->getTable('mageplaza_helloworld_post'), | ||
$setup->getIdxName( | ||
$installer->getTable('mageplaza_helloworld_post'), | ||
['name','url_key','post_content','tags','featured_image'], | ||
\Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_FULLTEXT | ||
), | ||
['name','url_key','post_content','tags','featured_image'], | ||
\Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_FULLTEXT | ||
); | ||
} | ||
$installer->endSetup(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
<?php | ||
namespace Mageplaza\HelloWorld\Setup; | ||
|
||
use Magento\Framework\Setup\UpgradeSchemaInterface; | ||
use Magento\Framework\Setup\SchemaSetupInterface; | ||
use Magento\Framework\Setup\ModuleContextInterface; | ||
|
||
class UpgradeSchema implements UpgradeSchemaInterface | ||
{ | ||
public function upgrade( SchemaSetupInterface $setup, ModuleContextInterface $context ) { | ||
$installer = $setup; | ||
|
||
$installer->startSetup(); | ||
|
||
if(version_compare($context->getVersion(), '1.1.0', '<')) { | ||
if (!$installer->tableExists('mageplaza_helloworld_post')) { | ||
$table = $installer->getConnection()->newTable( | ||
$installer->getTable('mageplaza_helloworld_post') | ||
) | ||
->addColumn( | ||
'post_id', | ||
\Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, | ||
null, | ||
[ | ||
'identity' => true, | ||
'nullable' => false, | ||
'primary' => true, | ||
'unsigned' => true, | ||
], | ||
'Post ID' | ||
) | ||
->addColumn( | ||
'name', | ||
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT, | ||
255, | ||
['nullable => false'], | ||
'Post Name' | ||
) | ||
->addColumn( | ||
'url_key', | ||
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT, | ||
255, | ||
[], | ||
'Post URL Key' | ||
) | ||
->addColumn( | ||
'post_content', | ||
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT, | ||
'64k', | ||
[], | ||
'Post Post Content' | ||
) | ||
->addColumn( | ||
'tags', | ||
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT, | ||
255, | ||
[], | ||
'Post Tags' | ||
) | ||
->addColumn( | ||
'status', | ||
\Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, | ||
1, | ||
[], | ||
'Post Status' | ||
) | ||
->addColumn( | ||
'featured_image', | ||
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT, | ||
255, | ||
[], | ||
'Post Featured Image' | ||
) | ||
->addColumn( | ||
'created_at', | ||
\Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, | ||
null, | ||
['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT], | ||
'Created At' | ||
)->addColumn( | ||
'updated_at', | ||
\Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, | ||
null, | ||
['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT_UPDATE], | ||
'Updated At') | ||
->setComment('Post Table'); | ||
$installer->getConnection()->createTable($table); | ||
|
||
$installer->getConnection()->addIndex( | ||
$installer->getTable('mageplaza_helloworld_post'), | ||
$setup->getIdxName( | ||
$installer->getTable('mageplaza_helloworld_post'), | ||
['name','url_key','post_content','tags','featured_image'], | ||
\Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_FULLTEXT | ||
), | ||
['name','url_key','post_content','tags','featured_image'], | ||
\Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_FULLTEXT | ||
); | ||
} | ||
} | ||
|
||
$installer->endSetup(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<?xml version="1.0"?> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> | ||
<module name="Mageplaza_HelloWorld" setup_version="0.0.1"> | ||
<module name="Mageplaza_HelloWorld" setup_version="0.1.0"> | ||
</module> | ||
</config> |