classyllama / ClassyLlama_AvaTax

This extension has been deprecated in favor of https://github.com/avadev/Avalara-AvaTax-for-Magento2
Open Software License 3.0
23 stars 15 forks source link

Split database #54

Closed keiant25 closed 7 years ago

keiant25 commented 7 years ago

The extension does not install on magento enterprise because it says:

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'sales_invoice' doesn't exist, query was: DESCRIBE sales_invoice

This happens when the split mode its enabled.

erikhansen commented 7 years ago

At this time the AvaTax extension does not support Magento Enterprise's split mode and we don't have this on our roadmap.

Per this page one of the requirements of using Magento's split database feature is that custom extensions can not "Use foreign keys to tables in the checkout, sales, or main databases". We are actually just getting ready to release a new version of this extension (see this PR) that will add foreign key constraints to the sales_invoice and sales_creditmemo tables, so this would make this extension even more incompatible with this mode.

@rsisco Can you take a look at the requirements of Enterprise's split database mode and come up with a level of effort for supporting it?

erikhansen commented 7 years ago

@keiant25 We've added support for Magento Enterprise's Split Database mode to the develop branch. We have not yet released this as an official release. We've tested this locally, but would you be willing to test this in your environment to ensure everything works for you? Here are instructions on how to install the extension from the develop branch:

Run these commands in your root Magento installation directory:

composer require classyllama/module-avatax:dev-develop
bin/magento module:enable --clear-static-content ClassyLlama_AvaTax 
bin/magento setup:upgrade 
bin/magento cache:flush
erikhansen commented 7 years ago

Split database support has been added in version 1.0.0 of this extension: https://github.com/classyllama/ClassyLlama_AvaTax/releases/tag/1.0.0

wsagen commented 6 years ago

Hey @erikhansen - I'm curious how you have got past the restriction to not use foreign keys against the sales tables in this instance?

erikhansen commented 6 years ago

@wsagen Take a look at this commit: https://github.com/classyllama/ClassyLlama_AvaTax/pull/58/files#diff-f28060adec80b6f03a1ae1302d809fffR34

What we did is we moved our custom DB tables into the "sales" connection so that our custom table could have foreign key constraints on other sales tables. It wouldn't work if we were trying to perform a foreign key constraint between the connection types. For your easy reference, here is the "create syntax" for one of the AvaTax tables that uses foreign key constraints:

CREATE TABLE `avatax_sales_invoice` (
  `entity_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Entity ID',
  `parent_id` int(10) unsigned NOT NULL COMMENT 'Sales Invoice ID',
  `is_unbalanced` smallint(5) unsigned DEFAULT NULL COMMENT 'Is Unbalanced In Relation To AvaTax Calculated Tax Amount',
  `base_avatax_tax_amount` decimal(12,4) DEFAULT NULL COMMENT 'Base AvaTax Calculated Tax Amount',
  PRIMARY KEY (`entity_id`),
  KEY `AVATAX_SALES_INVOICE_ENTITY_ID_PARENT_ID` (`entity_id`,`parent_id`),
  KEY `FK_F7B202752CA0A3244E879AF8ABB5C83E` (`parent_id`),
  CONSTRAINT `FK_F7B202752CA0A3244E879AF8ABB5C83E` FOREIGN KEY (`parent_id`) REFERENCES `sales_invoice` (`entity_id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=29 DEFAULT CHARSET=utf8 COMMENT='AvaTax Sales Invoice Table';

Note: the above table was created using the InstallSchema class.