Skip to content

Instantly share code, notes, and snippets.

@jaytaph
Created March 23, 2013 17:32
Show Gist options
  • Save jaytaph/5228598 to your computer and use it in GitHub Desktop.
Save jaytaph/5228598 to your computer and use it in GitHub Desktop.
<?php
namespace Acme\DemoBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="Foo", uniqueConstraints={
@ORM\UniqueConstraint(name="fullname",columns={"firstname", "lastname"}),
@ORM\UniqueConstraint(name="uniq_key",columns={"key"})
})
*/
class Foo {
/**
* @ORM\Id
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=40)
*/
private $firstname;
/**
* @ORM\Column(type="string", length=40)
*/
private $lastname;
/**
* @ORM\Column(type="string", length=40)
*/
private $key;
}
/*
Doctrine:schema:create will generate:
CREATE TABLE Foo (id INT NOT NULL, firstname VARCHAR(40) NOT NULL, lastname VARCHAR(40) NOT NULL, `key` VARCHAR(40) NOT NULL, `varchar` VARCHAR(40) NOT NULL, UNIQUE INDEX fullname (firstname, lastname), UNIQUE INDEX uniqkey (key), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB
but it should generate:
... UNIQUE INDEX uniqkey (`key`), PRIMARY KEY(id)) ...
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment