Answer the question
In order to leave comments, you need to log in
Foreign key constraint is incorrectly formed?
$this->addSql('ALTER TABLE user_notification_settings ADD CONSTRAINT FK_7051D51E539B0606 FOREIGN KEY (uid)
REFERENCES useraccounts_v3 (id)');
$this->addSql('ALTER TABLE user_notification_settings ADD CONSTRAINT FK_7051D51E4FBDA576 FOREIGN KEY (eid)
REFERENCES events (id)');
$this->addSql('CREATE INDEX IDX_7051D51E539B0606 ON user_notification_settings (uid)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_7051D51E4FBDA576 ON user_notification_settings (eid)');
[notice] Migrating up to DoctrineMigrations\Version20200709062413
[error] Migration DoctrineMigrations\Version20200709062413 failed during Execution. Error: "An exception occurred while
executing 'ALTER TABLE user_notification_settings ADD CONSTRAINT FK_7051D51E4FBDA576 FOREIGN KEY (eid) REFERENCES events (id)':
SQLSTATE[HY000]: General error: 1005 Can't create table `event_app`.`#sql-339_28` (errno: 150 "Foreign key constraint is incorrectly formed")"
In AbstractMySQLDriver.php line 106:
An exception occurred while executing 'ALTER TABLE user_notification_settings ADD CONSTRAINT
FK_7051D51E4FBDA576 FOREIGN KEY (eid) REFERENCES events (id)':
SQLSTATE[HY000]: General error: 1005 Can't create table `event_app`.`#sql-339_28` (errno: 150 "Foreign key constraint is incorrectly formed")
In PDOConnection.php line 43:
SQLSTATE[HY000]: General error: 1005 Can't create table `event_app`.`#sql-339_28` (errno: 150 "Foreign key constraint is
incorrectly formed")
In PDOConnection.php line 41:
SQLSTATE[HY000]: General error: 1005 Can't create table `event_app`.`#sql-339_28` (errno: 150 "Foreign key constraint is incorrectly formed")
/**
* @var User
*
* @ORM\ManyToOne(
* targetEntity="App\Entity\User\DIgnore\User",
* )
* @ORM\JoinColumn(name="uid", referencedColumnName="id")
*
* @Groups({"all"})
*/
private $owner;
/**
* @var Event
*
* @ORM\OneToOne(targetEntity="App\Entity\Event")
* @ORM\JoinColumn(name="eid", referencedColumnName="id")
*
* @Groups({"all"})
*/
private $event;
/**
* Event
*
* @ORM\Table(name="events")
* @ORM\Entity(repositoryClass="App\Repository\EventRepository")
*/
class Event
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*
* @Groups({"all"})
*/
private $id;
$this->addSql(
'CREATE TABLE IF NOT EXISTS events (id INT AUTO_INCREMENT NOT NULL, ....., PRIMARY KEY(id)) DEFAULT
CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = MyISAM COMMENT = \'\' '
);
$this->addSql(
'CREATE TABLE IF NOT EXISTS `user_notification_settings` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`uid` int(11) DEFAULT NULL,
`eid` int(11) DEFAULT NULL,
...,
PRIMARY KEY (`id`)
) DEFAULT CHARSET=utf8;'
);
Answer the question
In order to leave comments, you need to log in
Here's what I noticed, the difference is ENGINE tables
PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = MyISAM COMMENT = \'\' '
);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question