0

M2.4.3-p1. Trying to use db_schema.xml as that appears to be the way forward. setup:upgrade is not adding my tables. setup:db-declaration:generate-whitelist is not generating the whitelist. Basically nothing is happening and no errors are being shown/logged. I understand previous versions of Magento would silently fail but apparently this was addressed in 2.4.x. Now supposed to give us something useful (as should all commands!). I added some further logging as per this: Magento 2 is not generating the db_schema_whitelist.json file via CLI, but still nothing being logged.

Can anyone spot what is wrong with this:

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

    <table name="alp_tablepricing_quantities" resource="default" engine="innodb" comment="TablePricing Quantities">
        <column xsi:type="int" name="quantity_id" unsigned="true" nullable="false" identity="true" comment="Quantity Id"/>
        <column xsi:type="int" name="product_id" unsigned="true" nullable="false" comment="Product Id"/>
        <column xsi:type="int" name="quantity" unsigned="true" nullable="false" comment="Quantity"/>
        <constraint xsi:type="primary" referenceId="PRIMARY">
            <column name="quantity_id"/>
        </constraint>
    </table>

    <table name="alp_tablepricing_prices" resource="default" engine="innodb" comment="TablePricing Prices">
        <column xsi:type="int" name="price_id" unsigned="true" nullable="false" identity="true" comment="Price Id"/>
        <column xsi:type="int" name="product_id" unsigned="true" nullable="false" comment="Product Id"/>
        <column xsi:type="int" name="quantity_id" unsigned="true" nullable="false" comment="Quantity Id"/>
        <column xsi:type="int" name="option_one_id" unsigned="true" nullable="false" comment="Option One Id"/>
        <column xsi:type="int" name="option_two_id" unsigned="true" nullable="false" comment="Option Two Id"/>
        <constraint xsi:type="primary" referenceId="PRIMARY">
            <column name="price_id"/>
        </constraint>
    </table>

    <table name="alp_tablepricing_customprices" resource="default" engine="innodb" comment="TablePricing Custom Prices">
        <column xsi:type="int" name="customprices_id" unsigned="true" nullable="false" identity="true" comment="Custom Price Id"/>
        <column xsi:type="int" name="product_id" unsigned="true" nullable="false" comment="Product Id"/>
        <column xsi:type="int" name="custom_attribute_option_id" unsigned="true" nullable="false" comment="Attribute Id"/>
        <column xsi:type="int" name="option_one_id" unsigned="true" nullable="false" comment="Option One Id"/>
        <column xsi:type="int" name="option_two_id" unsigned="true" nullable="false" comment="Option Two Id"/>
        <column xsi:type="decimal" name="price" scale="6" precision="20" unsigned="false" nullable="false" default="0" comment="Price"/>
        <constraint xsi:type="primary" referenceId="PRIMARY">
            <column name="customprices_id"/>
        </constraint>
    </table>
    
</schema>

1 Answer 1

0

Just check the module is enabled or not.

Try the same code by removing resource="default" engine="innodb" . Code looks perfect.

2
  • Thanks. Originally didn't have these params (not in examples) but added to see if it made a difference. Didn't! The XML is correct so there must be an error elsewhere. Not reporting anything leaves nowhere to go except debug the core. Feb 21, 2022 at 9:10
  • Had the module installed, not installed, enabled, not enabled - no difference. The correct process is quite unclear. According to the docs, the reference id for constraints should be taken from the generated whitelist. But to generate the whitelist the module has to be installed/enabled (apparently). So how do you correctly create the schema XML when it must have been installed to generate whitelist!? Chicken & egg! Feb 21, 2022 at 9:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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