0

My module was implemented and working on Magento 2.2.

We are moving to Magento 2.3, but failed in Declarative Schema.

I follow this. Created db_schema.xml. Following is the example

    <schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">

   <table name="options" resource="default" engine="innodb" comment="Option entities">
        <column xsi:type="int" name="option_id" padding="10" unsigned="true" identity="true" nullable="false" comment="Option Id"/>
        <column xsi:type="varchar" name="name" nullable="false" length="255" comment="Option name"/>
        <column xsi:type="varchar" name="value" nullable="false" length="255" comment="Option value"/>
        <column xsi:type="timestamp" name="created" comment="Time of event"/>
        <constraint xsi:type="primary" referenceId="PRIMARY">
            <column name="option_id"/>
        </constraint>
    </table>
</schema>

Then, whatever commands I tried to run returns the same error..

PHP Fatal error:  Uncaught TypeError: Return value of Magento\Framework\Setup\Declaration\Schema\Declaration\SchemaBuilder::processTable() must be an instance of Magento\Framework\Setup\Declaration\Schema\Dto\Table, boolean returned in C:\xampp\htdocs\magento23\vendor\magento\framework\Setup\Declaration\Schema\Declaration\SchemaBuilder.php:251
Stack trace:
#0 C:\xampp\htdocs\magento23\vendor\magento\framework\Setup\Declaration\Schema\Declaration\SchemaBuilder.php(148): Magento\Framework\Setup\Declaration\Schema\Declaration\SchemaBuilder->processTable(Object(Magento\Framework\Setup\Declaration\Schema\Dto\Schema), Array)
#1 C:\xampp\htdocs\magento23\vendor\magento\framework\Setup\Declaration\Schema\SchemaConfig.php(78): Magento\Framework\Setup\Declaration\Schema\Declaration\SchemaBuilder->build(Object(Magento\Framework\Setup\Declaration\Schema\Dto\Schema))
#2 C:\xampp\htdocs\magento23\setup\src\Magento\Setup\Model\DeclarationInstaller.php(57): Magento\Framework\Setup\Declaration\Schema\SchemaConfig->getDeclarationConfig()
#3 C:\ in C:\xampp\htdocs\magento23\vendor\magento\framework\Setup\Declaration\Schema\Declaration\SchemaBuilder.php on line 251

Fatal error: Uncaught TypeError: Return value of Magento\Framework\Setup\Declaration\Schema\Declaration\SchemaBuilder::processTable() must be an instance of Magento\Framework\Setup\Declaration\Schema\Dto\Table, boolean returned in C:\xampp\htdocs\magento23\vendor\magento\framework\Setup\Declaration\Schema\Declaration\SchemaBuilder.php:251
Stack trace:
#0 C:\xampp\htdocs\magento23\vendor\magento\framework\Setup\Declaration\Schema\Declaration\SchemaBuilder.php(148): Magento\Framework\Setup\Declaration\Schema\Declaration\SchemaBuilder->processTable(Object(Magento\Framework\Setup\Declaration\Schema\Dto\Schema), Array)
#1 C:\xampp\htdocs\magento23\vendor\magento\framework\Setup\Declaration\Schema\SchemaConfig.php(78): Magento\Framework\Setup\Declaration\Schema\Declaration\SchemaBuilder->build(Object(Magento\Framework\Setup\Declaration\Schema\Dto\Schema))
#2 C:\xampp\htdocs\magento23\setup\src\Magento\Setup\Model\DeclarationInstaller.php(57): Magento\Framework\Setup\Declaration\Schema\SchemaConfig->getDeclarationConfig()
#3 C:\ in C:\xampp\htdocs\magento23\vendor\magento\framework\Setup\Declaration\Schema\Declaration\SchemaBuilder.php on line 251

Commands which produces the above error:

bin/magento setup:db-declaration:generate-whitelist   
bin/magento module:upgrade

I tried to install the module on a fresh installed Magento 2.3

Can anyone please help?

  • Please check my ans and let me know if you have any issue. – Aasim Goriya Feb 7 at 5:25
0

I had the exact same issue in custom module and found out that setAreaCode() in constructor was causing it. I relocate setAreaCode in execute() method and issue got fixed.

New contributor
Jam Arshad is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • Seems like any php or Magento functions can cause this output error. So I traced all the module code to find the bugs. The error did not even related to the declarative schema... After fix the error, upgrade can run. – BlueTong Feb 13 at 7:15

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.