有没有办法自动创建关系?
CREATE TABLE `user` (`id` BIGINT AUTO_INCREMENT, `name` VARCHAR(255) NOT NULL, PRIMARY KEY(`id`)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = INNODB;
CREATE TABLE `profile` (`id` BIGINT AUTO_INCREMENT, `user_id` BIGINT, `photo` VARCHAR(255), INDEX `user_id_idx` (`user_id`), PRIMARY KEY(`id`)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = INNODB;
ALTER TABLE `profile` ADD CONSTRAINT `profile_user_id_user_id` FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON DELETE CASCADE;
当我通过 gii 生成模型时,它不会建立关系。