I set up a new project with symfony and doctrine. I created a database using the following command:
php bin/console doctrine:database:create
Then I created an entity using the following command:
php bin/console make:entity
This was the code generated:
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\UserRepository")
*/
class User
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\Column(type="string", length=255)
*/
private $email;
/**
* @ORM\Column(type="string", length=24, nullable=true)
*/
private $phone;
/**
* @ORM\Column(type="integer")
*/
private $zip_code;
public function getId()
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone(?string $phone): self
{
$this->phone = $phone;
return $this;
}
public function getZipCode(): ?int
{
return $this->zip_code;
}
public function setZipCode(int $zip_code): self
{
$this->zip_code = $zip_code;
return $this;
}
}
When I try to run the migration, I keep getting the following error:
php bin/console make:migration
And
php bin/console doctrine:migrations:migrate
Error:
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes
This is extremely frustrating as I am using the command line generate code and a brand new project and have been trying to troubleshoot this for quite some time.
I appreciate any suggestions on how to resolve.