cancel
Showing results for 
Search instead for 
Did you mean: 

Upgrade Issue 2.2.7 to 2.3.0 Types char is not declared

Upgrade Issue 2.2.7 to 2.3.0 Types char is not declared

Hi,

 

Was able to upgrade from 2.2.6 to 2.2.7 fine. I took a brand new copy of the file for Magento 2.3.0 and then attempted to run an upgrade against it.

 

When I run the following from ssh to upgrade the database

php bin/magento setup:upgrade

I end up with the following error:

Updating modules:
Schema creation/updates:
Types char is not declared

I managed to track down the error message source to:

 

namespace Magento\Framework\Setup\Declaration\Schema\Dto;

Specifically, but I'm lost as to why the error

 

    /**
     * Instantiate different types of elements, depends on their xsi:type.
     *
     * @param  string $type
     * @param  array  $elementStructuralData
     * @return ElementInterface | object
     */
    public function create($type, array $elementStructuralData)
    {
        if (!isset($this->typeFactories[$type])) {
            throw new \InvalidArgumentException(sprintf("Types %s is not declared", $type));
        }

        $elementStructuralData = $this->castGenericAttributes($elementStructuralData);
        $elementStructuralData['type'] = $type;
        return $this->typeFactories[$type]->create($elementStructuralData);
    }

Any tips would be appreciated

 

Regards

Developer
11 REPLIES 11

Re: Upgrade Issue 2.2.7 to 2.3.0 Types char is not declared

OK, found the cause,

 

I had some custom tables in magento used for SAP integrations. There included a field type of char. Which it seems magento 2.3.0 doesnt agree with.

 

So If in future you see this, just run the following against your mysql database. This will show up any char data types

 

SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE DATA_TYPE ='char'

Regards

Developer

Re: Upgrade Issue 2.2.7 to 2.3.0 Types char is not declared

Yes, Its works. Thanks

Re: Upgrade Issue 2.2.7 to 2.3.0 Types char is not declared

where should i place this code?

Re: Upgrade Issue 2.2.7 to 2.3.0 Types char is not declared

Experienced the very same issue recently, which could be resolved by adding the CHAR element type mapping to the related DTO factory DI.xml. See next pull request for more on the solution (just in case others would come across the notice too): https://github.com/magento/magento2/pull/22442

Re: Upgrade Issue 2.2.7 to 2.3.0 Types char is not declared

Hello, 

The same issue which i can see in my site when i run the upgrade command it gives an error 

"Types char is not declared" ..

How can i solve this.

please help i'm really very appreciate 

thank you 

 

Re: Upgrade Issue 2.2.7 to 2.3.0 Types char is not declared

Hi @dearshikha 

Did you tried the following query in your database?

SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE DATA_TYPE ='char'


This issue is also reported on magento Github.
https://github.com/magento/magento2/pull/22442
You can take pull from the repo.

I hope it will help you!

Re: Upgrade Issue 2.2.7 to 2.3.0 Types char is not declared

Yes..

 i have run the query

you can see my output like this 

http://prntscr.com/nxhdr8

 

but nothing to happen

Re: Upgrade Issue 2.2.7 to 2.3.0 Types char is not declared

I wrote a shell script that finds the offending custom tables, dumps them to a file, and then creates another file with the appropriate "DROP TABLE" instructions. It's written for Debian Linux and Debian-based distributions (like Ubuntu), and it assumes the database is on the local server, but can be modified to support other Linux/UNIX-like systems and situations.

 

It does not actually run the "DROP TABLE" or recreate table SQL commands or modify the database in any way - it simply creates two convenient SQL command files to allow you to do so. It works fine for me, but obviously it should be used with extreme caution, multiple backups, and standard assumptions about random people who post code on the Internet, etc. It also needs to be run as root, so cringe even harder if you want.

 

I'm not going to give any other instructions or support. If you don't understand this, then (no offense) somebody else that does understand it should be doing the work. This is something I created as a convenience for myself that I'm willing to share, but that's about it.

 

#!/bin/bash


# Change these if necessary
export CRUDINI_PATH=/usr/bin/crudini
export DATABASE_NAME=magento
export DATABASE_SERVER=localhost
export OUTPUT_SQL_FILE=~/magento_char_custom_table_dump_$$.sql
export OUTPUT_TABLE_DROP_FILE=~/magento_char_custom_table_drop_$$.sql

export TABLE_LISTFILE=/tmp/magento_tablefix_$$.txt

if [[ ! -e $CRUDINI_PATH ]]; then
  echo 'FATAL - crudini not found. Please install (Debian/Ubuntu: "sudo apt install crudini")'
  exit 1
fi

if [[ -e "$OUTPUT_SQL_FILE" ]]; then
  echo 'FATAL - Output file "'$OUTPUT_SQL_FILE'" alraedy exists. Figure out what to do with it first.'
  exit 2
fi

if [[ -e "$OUTPUT_TABLE_DROP_FILE" ]]; then
  echo 'FATAL - Output file "'$OUTPUT_TABLE_DROP_FILE'" alraedy exists. Figure out what to do with it first.'
  exit 3
fi

export MYSQL_USERNAME=`crudini --get /etc/mysql/debian.cnf 'mysql_upgrade' 'user'`
export MYSQL_PASSWORD=`crudini --get /etc/mysql/debian.cnf 'mysql_upgrade' 'password'`

mysql -u "$MYSQL_USERNAME" -h "$DATABASE_SERVER" -p"$MYSQL_PASSWORD" mysql --execute='SELECT TABLE_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE DATA_TYPE ='\''char'\'' AND TABLE_SCHEMA='\'$DATABASE_NAME\'';' 2>/dev/null| \
     egrep -E '^\|\s[a-zA-Z0-9_]*\s+|$' | grep -v 'TABLE_NAME' | sort -u > "$TABLE_LISTFILE"

while read MYSQL_TABLENAME; do
  echo Processing Table $MYSQL_TABLENAME
  mysqldump -u "$MYSQL_USERNAME" -h "$DATABASE_SERVER" -p"$MYSQL_PASSWORD" "$DATABASE_NAME" "$MYSQL_TABLENAME" >> "$OUTPUT_SQL_FILE" 2>/dev/null
  echo 'DROP TABLE '$MYSQL_TABLENAME';' >> "$OUTPUT_TABLE_DROP_FILE"
done < "$TABLE_LISTFILE"
rm "$TABLE_LISTFILE"

echo 'Tables successfully dumped to "'$OUTPUT_SQL_FILE'"'
echo 'Table drop commands exported to "'$OUTPUT_TABLE_DROP_FILE'"'
echo 'Have a nice day.'

 

Re: Upgrade Issue 2.2.7 to 2.3.0 Types char is not declared

Thanks for sharing this. It really helps me.

routerlogin