yii2-gii
yii2-gii copied to clipboard
active relations not generated in PostgreSQL database
This issue has originally been reported by @tepaleguiojo at https://github.com/yiisoft/yii2/issues/15823. Moved here by @SilverFire.
What steps will reproduce the problem?
- create migration for
user
schema - create migration for table
user.account
- create migration for table
user.profile
with foreign key touser.account
- run
php yii gii/model --tableName=user.* --ns="app\modules\user\models" --baseClass="app\components\ActiveRecord"
What is the expected result?
Relation method/s like getUserAccount()
or getAccount()
, depends on what the gii will produce, functions to be used in with()
and joinWith()
What do you get instead?
No relations method created. Only rules()
and attributeLabels()
methods in model class are generated.
Additional info
Q | A |
---|---|
Yii version | 2.0.14.1 |
PHP version | 7.1.9 |
Operating system | Windows 7 Ultimate 64 Bit |
PostgreSQL | Version 10.1, compiled by Visual C++ build 1800, 64-bit |
Такая же проблема. Исправьте, пожалуйста =) В файле \generators\model\default\model.php переменная $relations содержит пустой массив. Gii version: 2.1.0 Yii version: 2.0.19
@sokollondon можете сделать дамп схемы? Если генерируете не из консоли, а из веб-интерфейса, всё нормально?
@samdark генерирую из веб-интерфейса. Дамп тут https://yadi.sk/d/tsWhBdKMEe1bKA для примера пытался сгенерировать модель таблицы planning.invoices, должен быть relation getContracts
Solved the problem by unchecking the Generate Relations from Current Schema
In general, if you check the box, then the relation is displayed only from the public schema, although the current schema is different. But for me it doesn't matter, I made the checkbox unchecked by default in the gii config 'generateRelationsFromCurrentSchema' => false,
let all be displayed =)
@sokollondon do you have public as default schema for the connection?
@samdark Yes
OK. Cross-schema relations aren't detected.
@samdark @sokollondon
Hi, whether the issue solved? I got same issue.
Thanks
It is not. Noone is working on it at the moment. If you want to, feel free to take it.