You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ever since DBAL 2.5 was released and we upgraded to it, Doctrine migrations have been generating migrations to rename all of the indexes. This uses the RENAME INDEX command. Example:
$this->addSql('ALTER TABLE account RENAME INDEX account_admin_id_idx TO IDX_7D3656A4642B8210');
$this->addSql('ALTER TABLE account RENAME INDEX account_plan_id_uniq TO UNIQ_7D3656A4E899029B');
$this->addSql('ALTER TABLE account RENAME INDEX account_address_id_uniq TO UNIQ_7D3656A4F5B7AF75');
$this->addSql('ALTER TABLE account RENAME INDEX account_profile_id_uniq TO UNIQ_7D3656A4CCFA12B8');
$this->addSql('ALTER TABLE account RENAME INDEX account_invoice_settings_id_uniq TO UNIQ_7D3656A44EDAFABB');
Problem is that Maria DB fails on this. Could this be because I'm not on a latest version and that it doesn't recognizes the syntax? Here's the stacktrace what I get when running doctrine migrations:migrate
WARNING! You are about to execute a database migration that could result in schema changes and data lost. Are you sure you wish to continue? (y/n)y
Migrating up to 20141219134957 from 20141218132129
++ migrating 20141219134957
-> ALTER TABLE account RENAME INDEX account_admin_id_idx TO IDX_7D3656A4642B8210
Migration 20141219134957 failed during Execution. Error An exception occurred while executing 'ALTER TABLE account RENAME INDEX account_admin_id_idx TO IDX_7D3656A4642B8210':
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 version for the right syntax to use near 'INDEX account_admin_id_idx TO IDX_7D3656A4642B8210' at line 1
[Doctrine\DBAL\Exception\SyntaxErrorException]
An exception occurred while executing 'ALTER TABLE account RENAME INDEX account_admin_id_i dx TO IDX_7D3656A4642B8210':
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL synt
ax; check the manual that corresponds to your MariaDB server version for the right syntax
to use near 'INDEX account_admin_id_idx TO IDX_7D3656A4642B8210' at line 1
[Doctrine\DBAL\Driver\PDOException]
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL synt
ax; check the manual that corresponds to your MariaDB server version for the right syntax
to use near 'INDEX account_admin_id_idx TO IDX_7D3656A4642B8210' at line 1
[PDOException]
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL synt
ax; check the manual that corresponds to your MariaDB server version for the right syntax
to use near 'INDEX account_admin_id_idx TO IDX_7D3656A4642B8210' at line 1
Output for mysql --version is:
mysql Ver 15.1 Distrib 10.0.14-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
Funny thing is that if I run doctrine orm:schema-tool:update --dump-sql on a MySQL based DB I don't get the RENAME INDEX syntax but a drop/create syntax:
DROPINDEX account_admin_id_idx ON account;
CREATEINDEXIDX_7D3656A4642B8210ON account (admin_id);
DROPINDEX account_plan_id_uniq ON account;
CREATEUNIQUE INDEXUNIQ_7D3656A4E899029BON account (plan_id);
DROPINDEX account_address_id_uniq ON account;
CREATEUNIQUE INDEXUNIQ_7D3656A4F5B7AF75ON account (address_id);
DROPINDEX account_profile_id_uniq ON account;
CREATEUNIQUE INDEXUNIQ_7D3656A4CCFA12B8ON account (profile_id);
DROPINDEX account_invoice_settings_id_uniq ON account;
CREATEUNIQUE INDEXUNIQ_7D3656A44EDAFABBON account (invoice_settings_id);
MySQL version for this is:
mysql Ver 14.14 Distrib 5.1.73, for debian-linux-gnu (i486) using readline 6.1
So my question basically is: how can I get my migrations to generate and run properly for Maria DB?
The text was updated successfully, but these errors were encountered:
This is because of the version guessing in the platform. doctrine/dbal#742 is fixing the issue.
In the meantime, you can configure the serverVersion explicitly to avoid this (set it to something lower than 5.7 because MariaDB does not support the MySQL 5.7 syntax for indexes). If you are using Symfony, the way to configure this in DoctrineBundle 1.3 is described in doctrine/DoctrineBundle#351 (comment)
Anyway, closing this issue as it is not an issue in doctrine/migrations but in doctrine/dbal.
Ever since DBAL 2.5 was released and we upgraded to it, Doctrine migrations have been generating migrations to rename all of the indexes. This uses the
RENAME INDEX
command. Example:Problem is that Maria DB fails on this. Could this be because I'm not on a latest version and that it doesn't recognizes the syntax? Here's the stacktrace what I get when running
doctrine migrations:migrate
Output for
mysql --version
is:mysql Ver 15.1 Distrib 10.0.14-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
Funny thing is that if I run
doctrine orm:schema-tool:update --dump-sql
on a MySQL based DB I don't get theRENAME INDEX
syntax but a drop/create syntax:MySQL version for this is:
mysql Ver 14.14 Distrib 5.1.73, for debian-linux-gnu (i486) using readline 6.1
So my question basically is: how can I get my migrations to generate and run properly for Maria DB?
The text was updated successfully, but these errors were encountered: