Skip to content

How to change table column type from Int to Decimal in db_schema.xml file In Magento 2

i’m trying to change the column data type from int to decimal for this tablemagento_reward (This table is exclusive for Enterprise edition) for the column called – points_balance , so this is how the below column structure in core file looks like (originally)

<column xsi:type="int" name="points_balance" unsigned="true" nullable="false" identity="false" default="0" comment="Points Balance"/>

Below is the xml i have changed to by adding decimal and removing other attributes

    <?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="magento_reward" resource="default" engine="innodb" comment="Enterprise Reward">
        <column xsi:type="decimal" name="points_balance" scale="4" precision="20" comment="Points Balance"/>
    </table>
</schema>

After doing this , when i run s:up , i get the below error as screenshot attached

Error details –

Invalid Document Error in merged XML after reading
/app/app/code/Custom/Module/etc/db_schema.xml Element ‘column’,
attribute ‘identity’: The attribute ‘identity’ is not allowed.

enter image description here