DBAL-400: can't add primary key to mysql table after the table is created #1593

Closed
doctrinebot opened this Issue Dec 20, 2012 · 2 comments

2 participants

@doctrinebot

Jira issue originally created by user jrobeson:

A table in this application had no primary keys. I created an entity
so i could attempt to use the doctrine:schema:update command to fix it up.

When i attempted to add this:

 * @ORM\Id
 * @ORM\GeneratedValue(strategy="NONE")

to this:
* @ORM\Column(name="session_id", type="string", length=128,
nullable=false)

it generates SQL like this:
{quote}
ALTER TABLE whosonline DROP INDEX idx_session_id_zen, ADD UNIQUE INDEX primary (sessionid);
ALTER TABLE whosonline CHANGE ip_address ip_address VARCHAR(45) NOT NULL, CHANGE host_address hostaddress VARCHAR(512) NOT NULL;
{quote}

and says this:
{quote}

An exception occurred while executing 'ALTER TABLE whosonline DROP INDEX idx_session_id_zen, ADD UNIQUE INDEX primary (sessionid );

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 'primary (session_id)' at line 1

{quote}

@doctrinebot

Comment created by @deeky666:

Fixed in PR:

#435

@doctrinebot

Issue was closed with resolution "Fixed"

@doctrinebot doctrinebot added the Bug label Dec 6, 2015
@beberlei beberlei was assigned by doctrinebot Dec 6, 2015
@doctrinebot doctrinebot added this to the 2.4.2 milestone Dec 6, 2015
@doctrinebot doctrinebot closed this Dec 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment