У меня возникла ошибка при выполнении команды:
php bin / console доктрина: миграция: миграция
-> ALTER TABLE user CHANGE roles roles JSON NOT NULL
Migration 20181113215357 failed during Execution. Error An exception occurred while executing 'ALTER TABLE user CHANGE roles roles JSON NOT NULL':
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'JSON NOT NULL' at line 1
Не могли бы вы сказать мне, что не так с моими миграциями?
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20181113215357 extends AbstractMigration
{
public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('ALTER TABLE user CHANGE roles roles JSON NOT NULL');
}
public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('ALTER TABLE user CHANGE roles roles VARCHAR(255) NOT NULL COLLATE utf8mb4_unicode_ci');
}
}
Я допустил ошибку при создании своей сущности, я назначил роли в виде строки вместо массива JSON ...