Search code examples
symfonymariadbupgrade

Symfony doctrine:schema:update mariadb problem


Few days ago i updated my xampp to it's latest 64 bit version with php 7.1.33, MySQL Ver 15.1 - 10.4.10-MariaDB

My last setup was 32bit version - php 7.1.22, mysql 10.1.36.

My Symfony version is too old - 2.8.52, but I can't upgrade it with the current.

Why i upgraded? Because composer update exits with out of memory error.

The problem:

When I run php app/console doctrine:schema:update --force, it tries to update some of the tables, even though they are exactly as they should be, and exist with error

[Doctrine\DBAL\DBALException] An exception occurred while executing 'ALTER TABLE sport_monks_odds CHANGE bookmaker_id bookmaker_id INT DEFAULT NULL, CHANGE match_id_id match_id_id INT DEFAULT NULL, CHANGE home home NUMERIC(8, 3) DEFAULT NULL, CHANGE draw draw NUMERIC(8, 3) DEFAULT NULL, CHANGE away away NUMERIC(8, 3) DEFAULT NULL, CHANGE over over NUMERIC(8, 3) DEFAULT NULL, CHANGE under under NUMERIC(8, 3) DEFAULT NULL, CHANGE handicap handicap NUMERIC(8, 2) DEFAULT NULL, CHANGE lastUpdated lastUpdated DATETIME DEFAULT NULL, CHANGE total total NUMERIC(8, 2) DEFAULT NULL, CHANGE probability1 probability1 VARCHAR(10) DEFAULT NULL, CHANGE probability2 probability2 VARCHAR(10) DEFAULT NULL, CHANGE probabilityx probabilityx VARCHAR(10) DEFAULT NULL':

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server v ersion for the right syntax to use near 'over over NUMERIC(8, 3) DEFAULT NULL, CHANGE under under NUMERIC(8, 3) DEFAULT N' at line 1

[PDOException] SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server v ersion for the right syntax to use near 'over over NUMERIC(8, 3) DEFAULT NULL, CHANGE under under NUMERIC(8, 3) DEFAULT N' at line 1

Okay. I copied the needed SQL code with --dump-sql and executed it manually in the mysql console. I put back ticks to over -> over and it worked.

But every time I start php app/console doctrine:schema:update --force it tries to execute the same sql code.

What did I do wrong?


Solution

  • Sadly doctrine does not really escape reserved words (issue). As a workaround set the field names to not reserved words (list of reserved words).

    /*
     *@Orm\Column(name="my_order", type="string", length=255)
     */
    private $order;