Skip to content

Commit

Permalink
Merge pull request #60 from rensieeee/master
Browse files Browse the repository at this point in the history
Feature - Full 2.2.X compatibility
  • Loading branch information
lewisvoncken authored Feb 19, 2021
2 parents ceaa373 + 7cda5bd commit e69e8c1
Show file tree
Hide file tree
Showing 3 changed files with 141 additions and 1 deletion.
82 changes: 82 additions & 0 deletions Setup/InstallSchema.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?php
/**
* A Magento 2 module named Experius/EmailCatcher
* Copyright (C) 2019 Experius
*
* This file included in Experius/EmailCatcher is licensed under OSL 3.0
*
* http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* Please see LICENSE.txt for the full text of the OSL 3.0 license
*/

namespace Experius\EmailCatcher\Setup;

use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\SchemaSetupInterface;
use Magento\Framework\Setup\InstallSchemaInterface;

class InstallSchema implements InstallSchemaInterface
{
/**
* @inheritDoc
*/
public function install(
SchemaSetupInterface $setup,
ModuleContextInterface $context
) {
$installer = $setup;
$installer->startSetup();
$table_experius_emailcatcher = $setup->getConnection()->newTable($setup->getTable('experius_emailcatcher'));
$table_experius_emailcatcher->addColumn(
'emailcatcher_id',
\Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
null,
['identity' => true, 'nullable' => false, 'primary' => true, 'unsigned' => true,],
'Entity ID'
);
$table_experius_emailcatcher->addColumn(
'to',
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
null,
[],
'To Email Address'
);
$table_experius_emailcatcher->addColumn(
'from',
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
null,
[],
'From Email Address'
);
$table_experius_emailcatcher->addColumn(
'subject',
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
null,
[],
'Subject'
);
$table_experius_emailcatcher->addColumn(
'body',
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
null,
[],
'Email Body'
);
$table_experius_emailcatcher->addColumn(
'created_at',
\Magento\Framework\DB\Ddl\Table::TYPE_DATETIME,
null,
[],
'Created At'
);
$table_experius_emailcatcher->addColumn(
'store_id',
\Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
null,
[],
'Store Id'
);
$setup->getConnection()->createTable($table_experius_emailcatcher);
$setup->endSetup();
}
}
58 changes: 58 additions & 0 deletions Setup/UpgradeSchema.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php
/**
* A Magento 2 module named Experius/EmailCatcher
* Copyright (C) 2019 Experius
*
* This file included in Experius/EmailCatcher is licensed under OSL 3.0
*
* http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* Please see LICENSE.txt for the full text of the OSL 3.0 license
*/
namespace Experius\EmailCatcher\Setup;
use Magento\Framework\Setup\UpgradeSchemaInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\SchemaSetupInterface;
class UpgradeSchema implements UpgradeSchemaInterface
{
/**
* @inheritDoc
*/
public function upgrade(
SchemaSetupInterface $setup,
ModuleContextInterface $context
) {
if (version_compare($context->getVersion(), "1.0.1", "<")) {
$connection = $setup->getConnection();
if (!$connection->tableColumnExists($setup->getTable('experius_emailcatcher'), 'recipient')) {
$connection->changeColumn(
$setup->getTable('experius_emailcatcher'),
'to',
'recipient',
['type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT]
);
}
if (!$connection->tableColumnExists($setup->getTable('experius_emailcatcher'), 'sender')) {
$connection->changeColumn(
$setup->getTable('experius_emailcatcher'),
'from',
'sender',
['type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT]
);
}
}
if (version_compare($context->getVersion(), "1.0.2", "<")) {
$connection = $setup->getConnection();
if (!$connection->tableColumnExists($setup->getTable('experius_emailcatcher'), 'template_identifier')) {
$connection->addColumn(
$setup->getTable('experius_emailcatcher'),
'template_identifier',
[
'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
'nullable' => true,
'comment' => 'Email Template Identifier'
]
);
}
}
}
}
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?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="Experius_EmailCatcher" setup_version="1.0.1" schema_version="1.0.1">
<module name="Experius_EmailCatcher" setup_version="1.0.2" schema_version="1.0.2">
<sequence>
<module name="Magento_Email"/>
</sequence>
Expand Down

1 comment on commit e69e8c1

@rensieeee
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:)

Please sign in to comment.