I need to change the type of the column "value" in the table catalog_product_entity_varchar from varchar(255) to varchar(512), but I find nothing in the documentation about how to do it, so I copy pasted something together from the code I found.




namespace Company\Base\Setup;

use \Magento\Framework\Setup\UpgradeSchemaInterface;
use \Magento\Framework\Setup\ModuleContextInterface;
use \Magento\Framework\Setup\SchemaSetupInterface;
use \Magento\Framework\DB\Ddl\Table;

class UpgradeSchema implements UpgradeSchemaInterface
    public function upgrade(SchemaSetupInterface $setup,
                            ModuleContextInterface $context) {

        // Wenn Version kleiner als 1.0.1
        if (version_compare($context->getVersion(), '1.0.1', '<')) {

            // Get module table
            $table = $setup->getTable('catalog_product_entity_varchar');
            $connection = $setup->getConnection();

            // Check if the table already exists
            if ($connection->isTableExists($table) == true) {
                        'type' => Table::TYPE_TEXT,
                        'length' => '512',


I also increased the version in my module.xml from 1.0.0 to 1.0.1:


<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Company_Base" setup_version="1.0.1"/>

Then I executed bin/magento setup:upgrade but it changed it to text instead of varchar(512) and it removed the comment and the Standard NULL:





1 Answer 1


Magento replaced the database schema system and replaced it by a better one. It works now with etc/db_schema.xml instead of Setup/UpgradeSchema.php


<?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="catalog_product_entity_varchar" resource="default">
        <column xsi:type="varchar" length="512" name="value" nullable="true" comment="Value"/>

Then I ran bin/magento setup:upgrade

Note: You can convert your old .php scripts by running bin/magento setup:install --convert-old-scripts=1, this won't work if you added custom SQL though. Read the documentation for more informations.

  • 1
    Thank you this helped fix my issue.
    – thindery
    May 24, 2021 at 14:40

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.