We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Devtools not generating model relations

Hi,

I tried generating models with relations via webtools as wel as command line. But it never adds them.

example code:

CREATE TABLE `user` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `loginName` varchar(50) NOT NULL,
  `email` varchar(255) NOT NULL,
  `password` varchar(200) NOT NULL,
  `mustChangePassword` char(1) DEFAULT NULL,
  `profileId` int(10) unsigned NOT NULL,
  `banned` char(1) NOT NULL DEFAULT '0',
  `suspended` char(1) NOT NULL DEFAULT '0',
  `active` char(1) DEFAULT NULL,
  `slug` varchar(60) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `login_UNIQUE` (`loginName`),
  UNIQUE KEY `email_UNIQUE` (`email`),
  KEY `fk_user_profile1_idx` (`profileId`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;

CREATE TABLE `profile` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(64) NOT NULL,
  `active` char(1) NOT NULL DEFAULT 'Y',
  PRIMARY KEY (`id`),
  UNIQUE KEY `name_UNIQUE` (`name`),
  KEY `active` (`active`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;

CREATE TABLE `remember_token` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `userId` int(10) unsigned NOT NULL,
  `token` char(32) NOT NULL,
  `userAgent` varchar(120) NOT NULL,
  `createdAt` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `token` (`token`),
  KEY `fk_remember_token_user1_idx` (`userId`),
  CONSTRAINT `fk_remember_token_user` FOREIGN KEY (`userId`) REFERENCES `user` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

I even changed table type to MyISAM but did not do anything. Anyone know what is preventing the creation?

Thanks,

Alex



98.9k

What command are you using to generate the models + their relations?



2.9k

I tried doing it with the Webtools (all checkboxes checked). Also on command line witth command: phalcon all-models --relations (from the top of my head) in both cases all models are generated but no releations defined. In the webtools I also tried doing it one at a time.



2.9k

Hi,

Does anyone any clue what might be causing this?