0

I want to create a custom table using db_schema.xml like that contains column like this:

enter image description here enter image description here

I tried to do it like this:

<column name="description" nullable="false" default="null" xsi:type="text"/>

but always got an error like this:

The XML in file "/var/www/M2/app/code/Vendor/Module/etc/db_schema.xml" is invalid:
Element 'column', attribute 'default': The attribute 'default' is not allowed.
  • What error you are getting? – aravind Feb 17 at 8:26
  • @aravind see my updated question – jojo Feb 18 at 3:07
  • change nullable="false" to nullable="true" – Sohel Rana Feb 18 at 3:28
  • @SohelRana i need this column not nullable with default value None – jojo Feb 18 at 3:52
1

I think the problem is nullable="false" your setting the column should not be null and you are setting its default value to null, so, here you are creating a conflict for an interpreter I guess. Try the below code and let us know the result.

<column xsi:type="text" name="description" nullable="true" default="NULL" comment="Description"/>
| improve this answer | |
0

run this command

php bin/magento setup:db-declaration:generate-whitelist --module-name=VendorName_ModuleName

then change this

<column xsi:type="text" name="description" nullable="false" comment="Description"/>

and finally run this command

php bin/magento setup:upgrade
| improve this answer | |

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.