Hello!
Can you post your solution here?
I have the same problem!
I'm running the command "doctrine:migrations:diff" to generate my
migrations, but I have the error:
"[Doctrine\DBAL\Schema\SchemaException]
There is no column with name 'user' on table 'course'."
My Entity class: (unnecessary information omitted)
<?php
namespace MainBundle\Entity;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Course
*
* @ORM\Table(
* name="course",
* uniqueConstraints={
* @ORM\UniqueConstraint(name="unique_course", columns={"name",
"institution_id", "user_id"})
* },
* indexes={
* @ORM\Index(name="IDX_169E6FB9A76ED395", columns={"user_id"})
* }
* )
* @ORM\Entity(repositoryClass="MainBundle\Entity\CourseRepository")
* @UniqueEntity(
* fields={"name", "institution", "user"},
* errorPath="name",
* message="unique.course.name"
* )
* @ORM\HasLifecycleCallbacks
*/
class Course extends AbstractEntity
{
/**
* @var integer
*
* @ORM\Column(name="id", type="bigint", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="SEQUENCE")
* @ORM\SequenceGenerator(sequenceName="course_id_seq", allocationSize=1,
initialValue=1)
*/
private $id;
/**
* @var \MainBundle\Entity\User
*
* @ORM\ManyToOne(targetEntity="MainBundle\Entity\User",
inversedBy="series")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id")
*/
private $user;
}
My schema:
CREATE TABLE public.course (
id bigint DEFAULT nextval('course_id_seq'::regclass) NOT NULL,
name character varying(45) NOT NULL,
description text NOT NULL,
file character varying(255) NOT NULL,
status integer DEFAULT 0 NOT NULL,
price character varying(45) DEFAULT 0 NOT NULL,
user_id bigint NOT NULL,
city character varying(150) DEFAULT ''::character varying NOT NULL,
duration character varying(45) NULL,
vouchers integer DEFAULT 0 NOT NULL,
audience character varying(150) NULL,
institution_id bigint NOT NULL,
CONSTRAINT course_pkey PRIMARY KEY (id),
CONSTRAINT course_user_id_fkey FOREIGN KEY (user_id) REFERENCES "user"(id)
MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION ,
CONSTRAINT course_institution_id_fkey FOREIGN KEY (institution_id)
REFERENCES institution(id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION ) WITHOUT OIDS;
I just run "doctrine:migrations:diff" and get the error.
Help me?
Em terça-feira, 12 de julho de 2016 05:36:31 UTC-3, Juan Angosto escreveu:
>
> "1) you have an index on a `brand`, column, but none is defined (instead,
> you have a brand VO)”
>
> That`s it!!! Was blind to this constraint.
>
> Thanks so much Marco!!!
>
>
> - Juan Angosto
> - Departamento IT
> - Tlf +34 931 838 949
> - Fax +34 933 360 162
> - [email protected] <javascript:>
> - www.ofertix.com
> - [image: firma_ofertix]
> - Este correo electrónico y, en su caso, cualquier fichero anexo al
> mismo, contiene información de carácter confidencial exclusivamente
> dirigida a su destinatario. Queda prohibida su divulgación, copia o
> distribución a terceros sin la previa autorización escrita de
> OFERTIX,S.L.U. En el caso de haber recibido este correo electrónico por
> error, se ruega que notifique inmediatamente esta circunstancia mediante
> reenvío a la dirección electrónica del remitente. De conformidad con lo
> establecido en la LOPD. OFERTIX,S.L.U.,le informa que los datos personales
> están incorporados a un fichero de OFERTIX,S.L.U., con la finalidad de
> gestionar las comunicaciones corporativas. Los derechos de acceso,
> rectificación, cancelación y oposición pueden ejercitarse mediante
> petición
> escrita a la dirección de correo: [email protected] <javascript:>
>
>
>
>
>
> El 12 jul 2016, a las 10:30, Marco Pivetta <[email protected]
> <javascript:>> escribió:
>
> Few things are weird here:
>
> 1) you have an index on a `brand`, column, but none is defined (instead,
> you have a brand VO)
> 2) your schema indeed has no `brand` column either, so the migration was
> probably generated with the DB in a different state.
>
> If this is MySQL, remember that MySQL doesn't do transactional DDL, so you
> might be in some sort of limbo (neither pre- nor post- migration status)
>
> Marco Pivetta
>
> http://twitter.com/Ocramius
>
> http://ocramius.github.com/
>
> On 12 July 2016 at 10:27, <[email protected] <javascript:>> wrote:
>
>> Yeah, soory I forget to iclude the schema:
>>
>> CREATE TABLE `customer` (
>> `id` varchar(36) COLLATE utf8_unicode_ci NOT NULL,
>> `email` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
>> `brand_id` smallint(6) NOT NULL,
>> `type` smallint(6) NOT NULL,
>> `password` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
>> `version_status` smallint(6) NOT NULL,
>> `legal_id` varchar(24) COLLATE utf8_unicode_ci DEFAULT NULL,
>> `gender` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL,
>> `birthdate` date DEFAULT NULL,
>> `telephone` varchar(24) COLLATE utf8_unicode_ci DEFAULT NULL,
>> `creation_channel` varchar(2) COLLATE utf8_unicode_ci NOT NULL,
>> `marketing_lead` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
>> `first_name` varchar(96) COLLATE utf8_unicode_ci DEFAULT NULL,
>> `last_name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
>> `created_at` datetime NOT NULL,
>> `updated_at` datetime NOT NULL,
>> `salt` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
>> `facebook_id` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
>> PRIMARY KEY (`id`),
>> UNIQUE KEY `UNIQ_81398E09E7927C741C52F958B6D4D47`
>> (`email`,`brand_id`,`version_status`)
>> ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
>>
>>
>>
>>
>> On Tuesday, 12 July 2016 10:24:35 UTC+2, Marco Pivetta wrote:
>>>
>>> Not sure what is being asked: we don't know what your schema looks like
>>> before generating the migration...
>>>
>>> Marco Pivetta
>>>
>>> http://twitter.com/Ocramius
>>>
>>> http://ocramius.github.com/
>>>
>>> On 12 July 2016 at 10:21, <[email protected]> wrote:
>>>
>>>> I'm getting this error when executing doctrine:migrations:diff
>>>>
>>>> [Doctrine\DBAL\Schema\SchemaException] There is no column with name
>>>> 'brand' on table 'customer'.
>>>>
>>>> This is the previous migration I've made. I did it manually because
>>>> doctrine:migrations:diff was creating no migration
>>>>
>>>> <?php
>>>>
>>>> namespace Application\Migrations;
>>>>
>>>> use Doctrine\DBAL\Migrations\AbstractMigration;
>>>> use Doctrine\DBAL\Schema\Schema;
>>>>
>>>> class Version20160711123625 extends AbstractMigration
>>>> {
>>>> /**
>>>> * @param Schema $schema
>>>> */
>>>> public function up(Schema $schema)
>>>> {
>>>> $this->abortIf($this->connection->getDatabasePlatform()->getName()
>>>> != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
>>>>
>>>> $this->addSql('ALTER TABLE customer CHANGE brand brand_id SMALLINT
>>>> NOT NULL');
>>>> }
>>>>
>>>> /**
>>>> * @param Schema $schema
>>>> */
>>>> public function down(Schema $schema)
>>>> {
>>>> $this->abortIf($this->connection->getDatabasePlatform()->getName()
>>>> != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
>>>>
>>>> $this->addSql('ALTER TABLE customer CHANGE brand_id brand SMALLINT
>>>> NOT NULL');
>>>> }
>>>> }
>>>>
>>>>
>>>> The migration was done because of brand attribute need to be hydrated
>>>> as BranIdVO.
>>>>
>>>> Customer.orm.xml
>>>>
>>>> <?xml version="1.0" encoding="utf-8"?>
>>>> <doctrine-mapping
>>>> xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
>>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>>> xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
>>>> http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
>>>> <entity name="Component\Customer\Domain\Model\Customer"
>>>> table="customer"
>>>>
>>>> repository-class="GAT\CustomerBundle\Infrastructure\DoctrineCustomerRepository">
>>>>
>>>> <unique-constraints>
>>>> <unique-constraint columns="email,brand,version_status"/>
>>>> </unique-constraints>
>>>>
>>>> <id name="id" type="string" column="id" length="36">
>>>> <generator strategy="NONE"/>
>>>> </id>
>>>>
>>>> <field name="email" type="string" column="email" length="255"
>>>> nullable="false"/>
>>>> <field name="type" type="smallint" column="type" length="1"
>>>> nullable="false"/>
>>>> <field name="password" type="string" column="password"
>>>> length="255" nullable="true"/>
>>>> <field name="versionStatus" type="smallint"
>>>> column="version_status" length="1" nullable="false"/>
>>>> <field name="firstName" type="string" column="first_name"
>>>> length="96" nullable="true"/>
>>>> <field name="lastName" type="string" column="last_name"
>>>> length="255" nullable="true"/>
>>>> <field name="legalId" type="string" column="legal_id" length="24"
>>>> nullable="true"/>
>>>> <field name="gender" type="string" column="gender" length="1"
>>>> nullable="true"/>
>>>> <field name="birthdate" type="date" column="birthdate"
>>>> nullable="true"/>
>>>> <field name="phoneNumber" type="string" column="telephone"
>>>> length="24" nullable="true"/>
>>>> <field name="creationChannel" type="string"
>>>> column="creation_channel" length="2" nullable="false"/>
>>>> <field name="marketingLead" type="string" column="marketing_lead"
>>>> length="255" nullable="true"/>
>>>> <field name="createdAt" type="datetime" column="created_at"
>>>> nullable="false"/>
>>>> <field name="updatedAt" type="datetime" column="updated_at"
>>>> nullable="false"/>
>>>> <field name="salt" type="string" column="salt" nullable="true"/>
>>>> <field name="facebookId" type="string" column="facebook_id"
>>>> nullable="true"/>
>>>>
>>>> <embedded name="brand"
>>>> class="Component\Core\Domain\Model\BrandIdVO" use-column-prefix="false"/>
>>>> </entity>
>>>> </doctrine-mapping>
>>>>
>>>>
>>>> BrandIdVO.orm.xml
>>>>
>>>> <?xml version="1.0" encoding="utf-8"?>
>>>> <doctrine-mapping
>>>> xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
>>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>>>
>>>> xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
>>>>
>>>> http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
>>>> <embeddable name="Component\Core\Domain\Model\BrandIdVO">
>>>> <field name="id" column="brand_id" type="smallint" length="2"/>
>>>> </embeddable>
>>>> </doctrine-mapping>
>>>>
>>>>
>>>> Customer.php
>>>>
>>>> class Customer implements UserInterface, AdvancedUserInterface,
>>>> \Serializable, EquatableInterface
>>>> {
>>>> use TimestampableTrait;
>>>>
>>>> /** @var CustomerIdVO */
>>>> protected $id;
>>>>
>>>> /** @var EmailVO */
>>>> protected $email;
>>>>
>>>> /** @var BrandIdVO */
>>>> protected $brand;
>>>>
>>>> /** @var CustomerTypeVO */
>>>> protected $type;
>>>>
>>>> /** @var EncryptedPasswordVO */
>>>> protected $password;
>>>>
>>>> /** @var integer */
>>>> protected $versionStatus;
>>>>
>>>> /** @var string */
>>>> protected $firstName;
>>>>
>>>> /** @var string */
>>>> protected $lastName;
>>>>
>>>> /** @var string */
>>>> protected $legalId;
>>>>
>>>> /** @var GenderVO */
>>>> protected $gender;
>>>>
>>>> /** @var \DateTime */
>>>> protected $birthdate;
>>>>
>>>> /** @var PhoneNumberVO */
>>>> protected $phoneNumber;
>>>>
>>>> /** @var integer */
>>>> protected $feature;
>>>>
>>>> /** @var ChannelIdVO */
>>>> protected $creationChannel;
>>>>
>>>> /** @var string */
>>>> protected $marketingLead;
>>>>
>>>> /** @var string */
>>>> protected $salt;
>>>>
>>>> /** @var bool */
>>>> protected $isActive;
>>>>
>>>> /** @var string */
>>>> protected $facebookId;
>>>>
>>>>
>>>> Everything looks fine to me, so I must be shortsighted. Any help would
>>>> be greatly appreciated.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "doctrine-user" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to [email protected].
>>>> To post to this group, send email to [email protected].
>>>> Visit this group at https://groups.google.com/group/doctrine-user.
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "doctrine-user" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected]
>> <javascript:>.
>> Visit this group at https://groups.google.com/group/doctrine-user.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "doctrine-user" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/doctrine-user/lE9GQWaU9mM/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected] <javascript:>.
> To post to this group, send email to [email protected]
> <javascript:>.
> Visit this group at https://groups.google.com/group/doctrine-user.
> For more options, visit https://groups.google.com/d/optout.
>
>
>
--
You received this message because you are subscribed to the Google Groups
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.