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

active relations not generated in PostgreSQL database #343

Open
yii-bot opened this issue Mar 2, 2018 · 9 comments
Open

active relations not generated in PostgreSQL database #343

yii-bot opened this issue Mar 2, 2018 · 9 comments
Assignees
Labels
status:ready for adoption Feel free to implement this issue. type:enhancement Enhancement

Comments

@yii-bot
Copy link

yii-bot commented Mar 2, 2018

This issue has originally been reported by @tepaleguiojo at yiisoft/yii2#15823.
Moved here by @SilverFire.


What steps will reproduce the problem?

  1. create migration for user schema
  2. create migration for table user.account
  3. create migration for table user.profile with foreign key to user.account
  4. 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
@yii-bot yii-bot added the ext:gii label Mar 2, 2018
@samdark samdark added type:bug Bug and removed ext:gii labels Mar 2, 2018
@samdark samdark added this to the 2.0.7 milestone Mar 2, 2018
@samdark samdark added the status:to be verified Needs to be reproduced and validated. label Apr 30, 2018
@samdark samdark modified the milestones: 2.0.7, 2.0.8 Apr 30, 2018
@samdark samdark modified the milestones: 2.0.8, 2.1.1 Dec 8, 2018
@sokollondon
Copy link

Такая же проблема. Исправьте, пожалуйста =)
В файле \generators\model\default\model.php переменная $relations содержит пустой массив.
Gii version: 2.1.0
Yii version: 2.0.19

@samdark
Copy link
Member

samdark commented Jul 31, 2019

@sokollondon можете сделать дамп схемы? Если генерируете не из консоли, а из веб-интерфейса, всё нормально?

@sokollondon
Copy link

@samdark генерирую из веб-интерфейса. Дамп тут https://yadi.sk/d/tsWhBdKMEe1bKA для примера пытался сгенерировать модель таблицы planning.invoices, должен быть relation getContracts

@samdark samdark self-assigned this Jul 31, 2019
@samdark samdark modified the milestones: 2.1.1, 2.1.2 Aug 13, 2019
@sokollondon
Copy link

sokollondon commented Sep 12, 2019

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 =)

@samdark
Copy link
Member

samdark commented Sep 12, 2019

@sokollondon do you have public as default schema for the connection?

@sokollondon
Copy link

@samdark Yes

@samdark
Copy link
Member

samdark commented Sep 12, 2019

OK. Cross-schema relations aren't detected.

@samdark samdark added type:enhancement Enhancement and removed status:to be verified Needs to be reproduced and validated. labels Sep 12, 2019
@samdark samdark removed this from the 2.1.2 milestone Sep 12, 2019
@samdark samdark added status:ready for adoption Feel free to implement this issue. and removed type:bug Bug labels Sep 12, 2019
@haifahrul
Copy link

@samdark @sokollondon

Hi, whether the issue solved? I got same issue.

Thanks

@samdark
Copy link
Member

samdark commented Aug 9, 2020

It is not. Noone is working on it at the moment. If you want to, feel free to take it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:ready for adoption Feel free to implement this issue. type:enhancement Enhancement
Projects
None yet
Development

No branches or pull requests

4 participants