The default Gii Model Generator (ModelCode.php) has a method called generateRelations. This method loops over all database tables, looking at all the foreign keys and creating a 'relations' array. This array is used to construct the relations method in the generated model class.
This code fails to look at any foreign key in a MANY_MANY table that is not also a primary key. These columns represent metadata about relationships. For example:
Table CARS = car_id (PK), car_model, car_manufacturer
Table OWNERS = owner_id (PK), owner_name
Table DEALERS = dealer_id (PK), dealer_name, dealer_address
Table PURCHASES = owner_id (PK/FK), car_id (PK/FK), dealer_id (FK), purchase_date
In this example, the PURCHASES table has additional metadata about the purchase. When generating the model for DEALERS, Gii will ignore the PURCHASES.dealer_id relationship, and will not include a "purchases" relationship inside the Dealer class.
Is it ok if I push a change for this issue? I tried following the instructions on the "Git workflow for Yii contributors" page, but I think I lack the permissions to perform the push. Or maybe I did something else wrong. The error message I get is "Repository not found."
Plaase follow this instruction.
You can attach PR to this issue by adding #2169 into title or comment text
Won't be implemented since 1.1 is reaching EOL and new features aren't accepted.