php - doctrine manyToMany SQLSTATE[HY000]: General error: 1005 Can't create table (errno: 150) -
i have issue
/** * @package entity * @orm\entity * @orm\table(name="r_country") */ class rcountry { /** * @orm\column(type="string", length=2) * @orm\id */ protected $id; ... /** * * @orm\manytomany(targetentity="rlanguage") * @orm\jointable(name="prohibited_language_display", * joincolumns={@orm\joincolumn(name="country_id", referencedcolumnname="id", ondelete="cascade")}, * inversejoincolumns={@orm\joincolumn(name="language_id", referencedcolumnname="id", ondelete="cascade")} * ) * */ protected $prohibitedlanguagedisplay; ... } /** * @package entity * @orm\entity * @orm\table(name="r_language") */ class rlanguage { /** * @orm\column(type="string", length=20) * @orm\id * */ protected $id; ... }
i'm trying manytomany relation doctrine when update fires error
[doctrine\dbal\exception\driverexception]
exception occurred while executing 'alter table prohibited_language_display add constraint fk_77b02d13f92f3e70 foreign key (country_id) references r_country (id) on delete cascade':
sqlstate[hy000]: general error: 1005 can't create table 'database.#sql-498_8797' (errno: 150)[doctrine\dbal\driver\pdoexception]
sqlstate[hy000]: general error: 1005 can't create table 'database.#sql-498_8797' (errno: 150)
[pdoexception]
sqlstate[hy000]: general error: 1005 can't create table 'database.#sql-498_8797' (errno: 150)
this th dump sql
create table prohibited_language_google (country_id varchar(2) not null, language_id varchar(20) not null, index idx_77b02d13f92f3e70 (country_id), index idx_77b02d1382f1baf4 (language_id), primary key(country_id, language_id)) default character set utf8 collate utf8_unicode_ci engine = innodb; alter table prohibited_language_display add constraint fk_77b02d13f92f3e70 foreign key (country_id) references r_country (id) on delete cascade; alter table prohibited_language_google add constraint fk_77b02d1382f1baf4 foreign key (language_id) references r_language (id) on delete cascade;
i've tryed de drop database , create new 1 doctrine , it's ok way, want update otherwise ill lose data in database.
is there 1 can me?
the problem doctrine generates script create table collation utf_unicode_ci, changed utf8_general_ci in order change had add doctrineconfiguration in app/config.yml
doctrine.dbal.default_table_options.collate: "utf8_general_ci"
Comments
Post a Comment