Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Generate] relationship --belongs-to fails if child model has non-canonical PK #35

Open
claudiopro opened this issue Aug 16, 2023 · 0 comments
Labels

Comments

@claudiopro
Copy link
Member

claudiopro commented Aug 16, 2023

Steps to reproduce

  1. Create a model with a non-standard primary key e.g. Car, PK=registration
  2. Create a standard model e.g. Person
  3. Invoke the generator to create a 1-1 relationship:
$ emerails_generate relationship --belongs-to person car

Expected behavior

The generator can correctly create a foreign key column in the cars table.

Actual behavior

Error:

☠ Error (ALTER TABLE `cars` ADD `person_id` int(11) NULL DEFAULT NULL AFTER `id`, ADD INDEX (`person_id`);
ALTER TABLE `cars` ADD FOREIGN KEY (`person_id`) REFERENCES `people`(`id`) ON DELETE NO ACTION ON UPDATE NO ACTION;): Unknown column 'id' in 'cars'
@claudiopro claudiopro added the bug label Aug 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant