5

I want to change the field type of catalogrule_product table from varchar to text.

<column xsi:type="varchar" name="action_operator" nullable="true" length="10" default="to_fixed"
                comment="Action Operator"/>

For this first I overrided db_schema.xml as below:

<?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="catalogrule_product" resource="default" >
<column xsi:type="text" name="action_operator" nullable="true" default="to_fixed"
                comment="Action Operator"/>
    </table>
</schema>

But when I'm doing the setup:upgrade I'm getting the below error:

Invalid Document 
Element 'column', attribute 'length': The attribute 'length' is not allowed.

Can anyone help me to resolve this issue?

3
  • 1
    I can't delete that field because it makes data loss in the field. Apr 9, 2021 at 5:25
  • Same issue here... May 6, 2022 at 6:45
  • If the "lenght" error is related to the same attribute, it means there is another db_schema.xml in another module (probably the original declaration of the field). Magento tried to merge the xml attributes to preserve upgradability, but they didn't predicted this type of scenario I guess. I had the same issue here, and ended up by manually modifying the original db_schema.xml file instead. =/ Sep 13, 2022 at 6:38

1 Answer 1

1

You will have to remove length and default from the text type.

It only takes nullable attribute.

See this:

<xs:complexType name="text">
    <xs:complexContent>
        <xs:extension base="abstractColumnType">
            <xs:annotation>
                <xs:documentation>
                    Here plain text can be persisted. Length of this field is more than 255 characters
                    and less than 65536
                </xs:documentation>
            </xs:annotation>

            <xs:attribute name="nullable" type="xs:boolean" />
        </xs:extension>
    </xs:complexContent>
</xs:complexType>

So it will become this:

<column xsi:type="text" name="action_operator" nullable="true" comment="Action Operator"/>
2
  • I have removed default also, but still the issue there Apr 9, 2021 at 5:37
  • Is it the same error? If it is then it must be coming from another place. Apr 9, 2021 at 5:59

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.