User migration fails
up vote
0
down vote
favorite
1) I created User Class with make:user command:
Console image
2) I generated migration file with make:migration command.
3) Here is the up() function in migration file:
final class Version20181110133851 extends AbstractMigration
public function up(Schema $schema) : void
$this->abortIf($this->connection->getDatabasePlatform()->getName() !==
'mysql', 'Migration can only be executed safely on 'mysql'.');
$this->addSql('ALTER TABLE user ADD email VARCHAR(180) NOT NULL, ADD roles JSON NOT NULL, CHANGE id id INT AUTO_INCREMENT NOT NULL, ADD PRIMARY KEY (id)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_8D93D649E7927C74 ON user (email)');
...
4) This is what happens when I try to migrate to data base with doctrine:migration:migrate command
Image showing the error
and here is the content of the error:
-> ALTER TABLE user ADD email VARCHAR(180) NOT NULL, ADD roles JSON NOT
NULL, CHANGE id id INT AUTO_INCREMENT NOT NULL, ADD PRIMARY KEY (id)
Migration 20181110133851 failed during Execution. Error An exception
occurred while executing 'ALTER TABLE user ADD email VARCHAR(180) NOT
NULL, ADD roles JSON NOT NULL, CHANGE id id INT AUTO_INCREMENT NOT NULL,
ADD PRIMARY KEY (id)':
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 'JSON NOT NULL, CHANGE id
id INT AUTO_INCREMENT NOT NULL, ADD PRIMARY KEY (id)' at line 1
In AbstractMySQLDriver.php line 99:
An exception occurred while executing 'ALTER TABLE user ADD email
VARCHAR(180) NOT NULL, ADD roles JSON NOT NULL, CHANGE id id INT
AUTO_INCREMENT NOT NULL, ADD PRI
MARY KEY (id)':
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 'JSON NOT NULL, CHANGE id id INT
AUTO_INCREMENT NOT NULL, ADD PRIMARY KEY (id)' at line 1
In PDOConnection.php line 109:
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 'JSON NOT NULL, CHANGE id id INT
AUTO_INCREMENT NOT NULL, ADD PRIMARY KEY (id)' at line 1
In PDOConnection.php line 107:
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 'JSON NOT NULL, CHANGE id id INT
AUTO_INCREMENT NOT NULL, ADD PRIMARY KEY (id)' at line 1
5) I've been trying to solve it for hours, but I am still a newbie and I don't think I am going to solve it myself.
6) My question: Where is the SYNTAX ERROR?
php symfony security doctrine
add a comment |
up vote
0
down vote
favorite
1) I created User Class with make:user command:
Console image
2) I generated migration file with make:migration command.
3) Here is the up() function in migration file:
final class Version20181110133851 extends AbstractMigration
public function up(Schema $schema) : void
$this->abortIf($this->connection->getDatabasePlatform()->getName() !==
'mysql', 'Migration can only be executed safely on 'mysql'.');
$this->addSql('ALTER TABLE user ADD email VARCHAR(180) NOT NULL, ADD roles JSON NOT NULL, CHANGE id id INT AUTO_INCREMENT NOT NULL, ADD PRIMARY KEY (id)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_8D93D649E7927C74 ON user (email)');
...
4) This is what happens when I try to migrate to data base with doctrine:migration:migrate command
Image showing the error
and here is the content of the error:
-> ALTER TABLE user ADD email VARCHAR(180) NOT NULL, ADD roles JSON NOT
NULL, CHANGE id id INT AUTO_INCREMENT NOT NULL, ADD PRIMARY KEY (id)
Migration 20181110133851 failed during Execution. Error An exception
occurred while executing 'ALTER TABLE user ADD email VARCHAR(180) NOT
NULL, ADD roles JSON NOT NULL, CHANGE id id INT AUTO_INCREMENT NOT NULL,
ADD PRIMARY KEY (id)':
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 'JSON NOT NULL, CHANGE id
id INT AUTO_INCREMENT NOT NULL, ADD PRIMARY KEY (id)' at line 1
In AbstractMySQLDriver.php line 99:
An exception occurred while executing 'ALTER TABLE user ADD email
VARCHAR(180) NOT NULL, ADD roles JSON NOT NULL, CHANGE id id INT
AUTO_INCREMENT NOT NULL, ADD PRI
MARY KEY (id)':
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 'JSON NOT NULL, CHANGE id id INT
AUTO_INCREMENT NOT NULL, ADD PRIMARY KEY (id)' at line 1
In PDOConnection.php line 109:
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 'JSON NOT NULL, CHANGE id id INT
AUTO_INCREMENT NOT NULL, ADD PRIMARY KEY (id)' at line 1
In PDOConnection.php line 107:
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 'JSON NOT NULL, CHANGE id id INT
AUTO_INCREMENT NOT NULL, ADD PRIMARY KEY (id)' at line 1
5) I've been trying to solve it for hours, but I am still a newbie and I don't think I am going to solve it myself.
6) My question: Where is the SYNTAX ERROR?
php symfony security doctrine
1
What is your mysql version? JSON fields are only available for 5.7+
– Padam87
Nov 10 at 15:12
C:xamppmysqlbin>mysql --version mysql Ver 15.1 Distrib 10.1.36-MariaDB, for Win32 (AMD64)
– Maciek
Nov 10 at 17:21
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
1) I created User Class with make:user command:
Console image
2) I generated migration file with make:migration command.
3) Here is the up() function in migration file:
final class Version20181110133851 extends AbstractMigration
public function up(Schema $schema) : void
$this->abortIf($this->connection->getDatabasePlatform()->getName() !==
'mysql', 'Migration can only be executed safely on 'mysql'.');
$this->addSql('ALTER TABLE user ADD email VARCHAR(180) NOT NULL, ADD roles JSON NOT NULL, CHANGE id id INT AUTO_INCREMENT NOT NULL, ADD PRIMARY KEY (id)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_8D93D649E7927C74 ON user (email)');
...
4) This is what happens when I try to migrate to data base with doctrine:migration:migrate command
Image showing the error
and here is the content of the error:
-> ALTER TABLE user ADD email VARCHAR(180) NOT NULL, ADD roles JSON NOT
NULL, CHANGE id id INT AUTO_INCREMENT NOT NULL, ADD PRIMARY KEY (id)
Migration 20181110133851 failed during Execution. Error An exception
occurred while executing 'ALTER TABLE user ADD email VARCHAR(180) NOT
NULL, ADD roles JSON NOT NULL, CHANGE id id INT AUTO_INCREMENT NOT NULL,
ADD PRIMARY KEY (id)':
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 'JSON NOT NULL, CHANGE id
id INT AUTO_INCREMENT NOT NULL, ADD PRIMARY KEY (id)' at line 1
In AbstractMySQLDriver.php line 99:
An exception occurred while executing 'ALTER TABLE user ADD email
VARCHAR(180) NOT NULL, ADD roles JSON NOT NULL, CHANGE id id INT
AUTO_INCREMENT NOT NULL, ADD PRI
MARY KEY (id)':
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 'JSON NOT NULL, CHANGE id id INT
AUTO_INCREMENT NOT NULL, ADD PRIMARY KEY (id)' at line 1
In PDOConnection.php line 109:
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 'JSON NOT NULL, CHANGE id id INT
AUTO_INCREMENT NOT NULL, ADD PRIMARY KEY (id)' at line 1
In PDOConnection.php line 107:
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 'JSON NOT NULL, CHANGE id id INT
AUTO_INCREMENT NOT NULL, ADD PRIMARY KEY (id)' at line 1
5) I've been trying to solve it for hours, but I am still a newbie and I don't think I am going to solve it myself.
6) My question: Where is the SYNTAX ERROR?
php symfony security doctrine
1) I created User Class with make:user command:
Console image
2) I generated migration file with make:migration command.
3) Here is the up() function in migration file:
final class Version20181110133851 extends AbstractMigration
public function up(Schema $schema) : void
$this->abortIf($this->connection->getDatabasePlatform()->getName() !==
'mysql', 'Migration can only be executed safely on 'mysql'.');
$this->addSql('ALTER TABLE user ADD email VARCHAR(180) NOT NULL, ADD roles JSON NOT NULL, CHANGE id id INT AUTO_INCREMENT NOT NULL, ADD PRIMARY KEY (id)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_8D93D649E7927C74 ON user (email)');
...
4) This is what happens when I try to migrate to data base with doctrine:migration:migrate command
Image showing the error
and here is the content of the error:
-> ALTER TABLE user ADD email VARCHAR(180) NOT NULL, ADD roles JSON NOT
NULL, CHANGE id id INT AUTO_INCREMENT NOT NULL, ADD PRIMARY KEY (id)
Migration 20181110133851 failed during Execution. Error An exception
occurred while executing 'ALTER TABLE user ADD email VARCHAR(180) NOT
NULL, ADD roles JSON NOT NULL, CHANGE id id INT AUTO_INCREMENT NOT NULL,
ADD PRIMARY KEY (id)':
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 'JSON NOT NULL, CHANGE id
id INT AUTO_INCREMENT NOT NULL, ADD PRIMARY KEY (id)' at line 1
In AbstractMySQLDriver.php line 99:
An exception occurred while executing 'ALTER TABLE user ADD email
VARCHAR(180) NOT NULL, ADD roles JSON NOT NULL, CHANGE id id INT
AUTO_INCREMENT NOT NULL, ADD PRI
MARY KEY (id)':
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 'JSON NOT NULL, CHANGE id id INT
AUTO_INCREMENT NOT NULL, ADD PRIMARY KEY (id)' at line 1
In PDOConnection.php line 109:
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 'JSON NOT NULL, CHANGE id id INT
AUTO_INCREMENT NOT NULL, ADD PRIMARY KEY (id)' at line 1
In PDOConnection.php line 107:
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 'JSON NOT NULL, CHANGE id id INT
AUTO_INCREMENT NOT NULL, ADD PRIMARY KEY (id)' at line 1
5) I've been trying to solve it for hours, but I am still a newbie and I don't think I am going to solve it myself.
6) My question: Where is the SYNTAX ERROR?
php symfony security doctrine
php symfony security doctrine
asked Nov 10 at 13:57
Maciek
43
43
1
What is your mysql version? JSON fields are only available for 5.7+
– Padam87
Nov 10 at 15:12
C:xamppmysqlbin>mysql --version mysql Ver 15.1 Distrib 10.1.36-MariaDB, for Win32 (AMD64)
– Maciek
Nov 10 at 17:21
add a comment |
1
What is your mysql version? JSON fields are only available for 5.7+
– Padam87
Nov 10 at 15:12
C:xamppmysqlbin>mysql --version mysql Ver 15.1 Distrib 10.1.36-MariaDB, for Win32 (AMD64)
– Maciek
Nov 10 at 17:21
1
1
What is your mysql version? JSON fields are only available for 5.7+
– Padam87
Nov 10 at 15:12
What is your mysql version? JSON fields are only available for 5.7+
– Padam87
Nov 10 at 15:12
C:xamppmysqlbin>mysql --version mysql Ver 15.1 Distrib 10.1.36-MariaDB, for Win32 (AMD64)
– Maciek
Nov 10 at 17:21
C:xamppmysqlbin>mysql --version mysql Ver 15.1 Distrib 10.1.36-MariaDB, for Win32 (AMD64)
– Maciek
Nov 10 at 17:21
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
accepted
As @Padam87 said, MariaDB does not support the native JSON type. If you can't upgrade your database for whatever reason but don't want to change the column type, just define the database version in the Doctrine properties and let Doctrine handle the conversion for you.
doctrine.yaml:
doctrine:
dbal:
server_version: '10.1.36-MariaDB'
This will add a comment in the table definition which Doctrine will use later to encode/decode the values.
add a comment |
up vote
1
down vote
Mariadb 10.1 does not support the native json type, so you will have to use another type. Change your column definition, delete this migration, and generate a new one.
Alternatively, you can upgrade. Mariadb starts supporting the json type from 10.2.7 and up. https://mariadb.com/kb/en/library/json-data-type/
yep, it helped. Thanks. Ave Juve.
– Maciek
Nov 10 at 19:01
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
As @Padam87 said, MariaDB does not support the native JSON type. If you can't upgrade your database for whatever reason but don't want to change the column type, just define the database version in the Doctrine properties and let Doctrine handle the conversion for you.
doctrine.yaml:
doctrine:
dbal:
server_version: '10.1.36-MariaDB'
This will add a comment in the table definition which Doctrine will use later to encode/decode the values.
add a comment |
up vote
0
down vote
accepted
As @Padam87 said, MariaDB does not support the native JSON type. If you can't upgrade your database for whatever reason but don't want to change the column type, just define the database version in the Doctrine properties and let Doctrine handle the conversion for you.
doctrine.yaml:
doctrine:
dbal:
server_version: '10.1.36-MariaDB'
This will add a comment in the table definition which Doctrine will use later to encode/decode the values.
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
As @Padam87 said, MariaDB does not support the native JSON type. If you can't upgrade your database for whatever reason but don't want to change the column type, just define the database version in the Doctrine properties and let Doctrine handle the conversion for you.
doctrine.yaml:
doctrine:
dbal:
server_version: '10.1.36-MariaDB'
This will add a comment in the table definition which Doctrine will use later to encode/decode the values.
As @Padam87 said, MariaDB does not support the native JSON type. If you can't upgrade your database for whatever reason but don't want to change the column type, just define the database version in the Doctrine properties and let Doctrine handle the conversion for you.
doctrine.yaml:
doctrine:
dbal:
server_version: '10.1.36-MariaDB'
This will add a comment in the table definition which Doctrine will use later to encode/decode the values.
answered Nov 10 at 20:50
Arne
684
684
add a comment |
add a comment |
up vote
1
down vote
Mariadb 10.1 does not support the native json type, so you will have to use another type. Change your column definition, delete this migration, and generate a new one.
Alternatively, you can upgrade. Mariadb starts supporting the json type from 10.2.7 and up. https://mariadb.com/kb/en/library/json-data-type/
yep, it helped. Thanks. Ave Juve.
– Maciek
Nov 10 at 19:01
add a comment |
up vote
1
down vote
Mariadb 10.1 does not support the native json type, so you will have to use another type. Change your column definition, delete this migration, and generate a new one.
Alternatively, you can upgrade. Mariadb starts supporting the json type from 10.2.7 and up. https://mariadb.com/kb/en/library/json-data-type/
yep, it helped. Thanks. Ave Juve.
– Maciek
Nov 10 at 19:01
add a comment |
up vote
1
down vote
up vote
1
down vote
Mariadb 10.1 does not support the native json type, so you will have to use another type. Change your column definition, delete this migration, and generate a new one.
Alternatively, you can upgrade. Mariadb starts supporting the json type from 10.2.7 and up. https://mariadb.com/kb/en/library/json-data-type/
Mariadb 10.1 does not support the native json type, so you will have to use another type. Change your column definition, delete this migration, and generate a new one.
Alternatively, you can upgrade. Mariadb starts supporting the json type from 10.2.7 and up. https://mariadb.com/kb/en/library/json-data-type/
answered Nov 10 at 18:20
Padam87
88857
88857
yep, it helped. Thanks. Ave Juve.
– Maciek
Nov 10 at 19:01
add a comment |
yep, it helped. Thanks. Ave Juve.
– Maciek
Nov 10 at 19:01
yep, it helped. Thanks. Ave Juve.
– Maciek
Nov 10 at 19:01
yep, it helped. Thanks. Ave Juve.
– Maciek
Nov 10 at 19:01
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53239688%2fuser-migration-fails%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
What is your mysql version? JSON fields are only available for 5.7+
– Padam87
Nov 10 at 15:12
C:xamppmysqlbin>mysql --version mysql Ver 15.1 Distrib 10.1.36-MariaDB, for Win32 (AMD64)
– Maciek
Nov 10 at 17:21