Skip to content

Commit

Permalink
fix issue with #85
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzaloebiz committed Sep 12, 2017
1 parent 7a567b7 commit 5c0506c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
12 changes: 10 additions & 2 deletions Setup/InstallSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,22 @@
use Magento\Framework\Setup\SchemaSetupInterface;
use Symfony\Component\Config\Definition\Exception\Exception;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\App\DeploymentConfig;

class InstallSchema implements InstallSchemaInterface
{
/**
* @var ResourceConnection
*/
protected $_resource;
public function __construct(ResourceConnection $resource)
/**
* @var DeploymentConfig
*/
protected $_deploymentConfig;
public function __construct(ResourceConnection $resource,DeploymentConfig $deploymentConfig)
{
$this->_resource = $resource;
$this->_deploymentConfig = $deploymentConfig;
}

/**
Expand Down Expand Up @@ -205,7 +211,9 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'comment' => 'Retrieved from Mailchimp'
]
);
$connection = $this->_resource->getConnectionByName('checkout');
if ($this->_deploymentConfig->get(\Magento\Framework\Config\ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTIONS . '/checkout')) {
$connection = $this->_resource->getConnectionByName('checkout');
}
$connection->addColumn(
$connection->getTableName('quote'),
'mailchimp_abandonedcart_flag',
Expand Down
15 changes: 13 additions & 2 deletions Setup/UpgradeSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,22 @@
use Magento\Framework\Setup\SchemaSetupInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\App\DeploymentConfig;

class UpgradeSchema implements UpgradeSchemaInterface
{
/**
* @var ResourceConnection
*/
protected $_resource;
public function __construct(ResourceConnection $resource)
/**
* @var DeploymentConfig
*/
protected $_deploymentConfig;
public function __construct(ResourceConnection $resource,DeploymentConfig $deploymentConfig)
{
$this->_resource = $resource;
$this->_deploymentConfig = $deploymentConfig;
}

/**
Expand All @@ -34,7 +40,12 @@ public function __construct(ResourceConnection $resource)
public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
{
$connection = $this->_resource->getConnectionByName('default');
$checkoutConnection = $this->_resource->getConnectionByName('checkout');
if ($this->_deploymentConfig->get(\Magento\Framework\Config\ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTIONS . '/checkout')) {
$checkoutConnection = $this->_resource->getConnectionByName('checkout');
}
else {
$checkoutConnection = $connection;
}
if (version_compare($context->getVersion(), '1.0.5') < 0) {
$table = $connection
->newTable($connection->getTableName('mailchimp_stores'))
Expand Down

0 comments on commit 5c0506c

Please sign in to comment.