"SQLSTATE[23000]: нарушение ограничения целостности" в доктрине

Я получаю нарушение ограничения целостности для доктрины, хотя я действительно не понимаю, почему.

schema.yml

User:
  columns:
    id:
      type: integer
      primary: true
      autoincrement: true
    username:
      type: varchar(64)
      notnull: true
    email:
      type: varchar(128)
      notnull: true
    password:
      type: varchar(128)
      notnull: true
  relations:
    Websites:
      class: Website
      local: id
      foreign: owner
      type: many
      foreignType: one
      onDelete: CASCADE

Website:
  columns:
    id:
      type: integer
      primary: true
      autoincrement: true
    active:
      type: bool
    owner:
      type: integer
      notnull: true
    plz:
      type: integer
      notnull: true
    longitude:
      type: double(10,6)
      notnull: true
    latitude:
      type: double(10,6)
      notnull: true
  relations:
    Owner:
      type: one
      foreignType: many
      class: User
      local: owner
      foreign: id

А вот мои данные фикстуры (data.yml)

Model_User:
  User_1:
    username: as
    email: as****.com
    password: *****

Model_Website:
  Website_1:
    active: true
    plz: 34222
    latitude: 13.12
    longitude: 3.56
    Owner: User_1

1 ответ

Решение

Хорошо, я нашел проблему. Причиной этой ошибки было то, что я уже изменил Model_User и добавил "владельца" атрибута, а затем Doctrine попытался добавить уже существующий атрибут в модель.

Короткая история: не определяйте переменные в ваших моделях, которые также существуют в вашей схеме yaml!

Другие вопросы по тегам