2

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?

1
  • 1
    I can't delete that field because it makes data loss in the field. – VIPIN A ROY Apr 9 at 5:25
0

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 – VIPIN A ROY Apr 9 at 5:37
  • Is it the same error? If it is then it must be coming from another place. – Adarsh Khatri Apr 9 at 5:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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