yiisoft / yii2-gii

Yii 2 Gii Extension
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
202 stars 192 forks source link

Generating models and PostgreSQL with many schemas #203

Open tontm1981 opened 7 years ago

tontm1981 commented 7 years ago

I have a PostgreSQL database, with 4 schemas, each one with a specific purpose. Looking for a help through forums and sites, I read that I must to specify a default schema to create a model. But when I want to create a model for another table in different schema, I must to change the default schema in configurations. Everytime I create a model for a table in different schema, I really have to change default schema in configs? Even when I configure many connections each one pointing to a different schema, Gii is unable to find table names in another schemas, writing the pattern [schemaname].[tablename] or not.

samdark commented 7 years ago

For now — yes. It can definitely be improved.

tontm1981 commented 7 years ago

Hi samdark, thanks for reply and sorry me for take so long in give you a feedback.

I managed to make some improvements, making some changes in yii\db\pgsql\Schema file and now, I can get a full list of tables names with its respective schema name, in the pattern schemaname.tablename. But, I noticed that Gii Generator have problems when the tablename field contains a dot char in its content.

Can you help, telling me where Gii builds the model name from a given table name? It occurs in the Gii's Model creator, when tablename field lost it focus.

samdark commented 7 years ago

It happens here: https://github.com/yiisoft/yii2-gii/blob/master/assets/gii.js#L230

tontm1981 commented 7 years ago

@samdark Thanks. Now it is working fine. I will fork and bring the project to my local repo to do a little contribution for you.