0

I must add column1 to sales_order_grid and create foreign key to table sales_grid.column1 When i try use bin/magento setup:upgrade i get next message

Table [myPrefix]_sales_order do not have column with name "name1"

In fact, the column exists and I do not confuse names and uppercases

module.xml

<module name="Vendor_ModuleName">
    <sequence>
        <module name="Magento_Backend"/>
        <module name="Magento_Ui"/>
    </sequence>
</module>

db_schema.xml

<table name="sales_order_grid">
    <column xsi:type="boolean" name="name"/>
    <constraint xsi:type="foreign" referenceId="SALES_ORDER_GRID_NAME_SALES_ORDER_NAME" table="sales_order_grid" column="name" referenceTable="sales_order" referenceColumn="nameRef" onDelete="CASCADE"/>
</table>

di.xml

<virtualType name="Magento\Sales\Model\ResourceModel\Order\Grid" type="Magento\Sales\Model\ResourceModel\Grid">
    <arguments>
        <argument name="columns" xsi:type="array">
            <item name="name" xsi:type="string">sales_order.label_Name</item>
        </argument>
    </arguments>
</virtualType>

other info:

docker images:

  1. mariaDB - mariadb:10.4
  2. nginx - markoshust/magento-nginx:1.18-7
  3. php-fpm - markoshust/magento-php:7.3-fpm-12

1 Answer 1

0

You have to add InstallData.php to the Setup directory in your module. Get the order grid table and add your column to the table.

1
  • can i do it with helps db_schema or something yet
    – esca7a
    Commented Aug 21, 2022 at 15:10

Your Answer

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

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