0 votes

I have finally figured out how to use the doctrine scheme tool to update my DB:

./doctrine-module orm:schema-tool:create --dump-sql

The problem I face is that I keep getting the following errors:

Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes

It would seem this is happening due to certain field lengths being ignored via skipper.

In skipper I create the following table:

enter image description here

This creates the following annotations:

  /**
 * CloudSettings
 *
 * @ORM\Table(name="application_settings")
 * @ORM\Entity
 */
class AppSettings
{
    /**
     * @var integer
     *
     * @ORM\Column(type="integer", name="id")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $id;

    /**
     * @ORM\OneToOne(targetEntity="RoleBasedUser\Entity\User")
     * @ORM\JoinColumn(name="cronUser_id", referencedColumnName="id", unique=true)
     */
    private $cronUser;


    /**
     * @ORM\Column(type="string", unique=true, length=256, nullable=false, name="support_email")
     *
     * @var string
     * @access private
     */
    private $supportEmail;

    /**
     * @ORM\Column(type="string", unique=true, length=256, nullable=false, name="noreply_email")
     *
     * @var string
     * @access private
     */
    private $noreplyEmail;

    /**
     * @var datetime $created
     * @Gedmo\Timestampable(on="create")
     * @ORM\Column(type="datetime", nullable=true)
     *
     */
    protected $created;

    /**
     * @var datetime $modified
     * @Gedmo\Timestampable(on="update")
     * @ORM\Column(type="datetime", nullable=true)
     *
     */
    protected $modified;

Now I run:

./doctrine-module orm:schema-tool:create --dump-sql

which creates all my tables including:

CREATE TABLE applicationsettings (id INT AUTOINCREMENT NOT NULL,
supportemail VARCHAR(256) NOT NULL, noreplyemail VARCHAR(256) NOT
NULL, created DATETIME DEFAULT NULL, modified DATETIME DEFAULT NULL,
cronUserid INT DEFAULT NULL, UNIQUE INDEX UNIQ5A7E7FD615286AAC
(supportemail), UNIQUE INDEX UNIQ5A7E7FD6E2589581 (noreplyemail),
UNIQUE INDEX UNIQ
5A7E7FD6E309DDFB (cronUserid), PRIMARY KEY(id))
DEFAULT CHARACTER SET utf8 COLLATE utf8
unicode_ci ENGINE = InnoDB;

When the tool attempts to create a new table it returns the following error:

Specified key was too long; max key length is 767 bytes

What is the solution to this?

in Solved by (550 points)
recategorized by

2 Answers

0 votes

Hi,

you have something wrong in your definitions. Recommended way how to solve such situations is to make your schema work manually without Skipper and then find a way how to configure it in Skipper.

We're here to help you with anything with Skipper but this question is much rather Doctrine (or MySQL) than Skipper and unfortunately we can't do also Doctrine support. For such situation it's better to ask on Doctrine forum or stackoverflow.

As a clue for your problem, it seems that you have defined unique indexes on string fields which are too long (based on the SQL command, because your screenshot shows only fields, not indexes). Try to simplify your schema file manually (remove fields, remove @Gedmo) as long as your schema will work.

Also, you're combining Skipper export together with Gedmo defintiions, maybe the problem is there.

After you will be able to figure out how to configure schema file manually, it will be easy to configure it in Skipper. In case you will not be sure how to configure specific feature in Skipper, please don't hesitate to ask and we will be glad to help you. But as mentioned before, we're not Doctrine specialist and can't assist with such questions. Thanks for understanding.

by Skipper developer (141k points)

I guess it means developing a strategy with pre-existing projects.

For now, I just create the entities I need to work on rather than importing the whole project, that is too much of a headache at this point of my learning curve.

thanks for your help.

0 votes

Starting with version 3.2.5.1264 Skipper fully supports Gedmo extensions.

Currently support is in beta stage.

More info http://support.skipper18.com/2290/gedmo-extensions-beta-support

by Skipper developer (141k points)