We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

DevTools - Cannot create models from Postgresql DB

I am trying to generate models with DevTools for my already existing db structure. I have a db called postgre and it has 2 schemas - the default one called public and another one called coiny. The coiny schema contains 5 tables with their foreign keys.

My config.php contents:

    return new \Phalcon\Config(array(
        'database' => array(
            'adapter'       => 'Postgresql',
            'host'          => 'localhost',
            'port'          => '5432',
            'username'      => 'postgres',
            'password'      => '*********',
            'dbname'        => 'postgres',
            'schema'        => 'coiny',
        ),
        'application' => array(
            'controllersDir'=> __DIR__ . '/../../app/controllers/',
            'modelsDir'     => __DIR__ . '/../../app/models/',
            'viewsDir'      => __DIR__ . '/../../app/views/',
            'pluginsDir'    => __DIR__ . '/../../app/plugins/',
            'libraryDir'    => __DIR__ . '/../../app/library/',
            'cacheDir'      => __DIR__ . '/../../app/cache/',
            'baseUri'       => '/coiny/',
        ),
    ));

My services.php has:

    use Phalcon\Db\Adapter\Pdo\Postgresql as DbAdapter;

    ...

    $di->setShared('db', function () use ($config) {
        return new DbAdapter(array(
            'host' => $config->database->host,
            'port' => $config->database->port,
            'username' => $config->database->username,
            'password' => $config->database->password,
            'dbname' => $config->database->dbname,
            'schema' => $config->database->schema,
        ));
    });

When I try to generate models from the DT GUI I only get this screen:

I've tried also to use the command line, still there was no result. No output or error was presented after executing

phalcon.bat model --schema=coiny --get-set --name=participants

I am using a Win7 x64 with Bitnami WAPP Statck 5.515'0 Dev and the Phalcon 1.3.2 x86 extension

I will highly appreciate any comments and suggestions in order to solve this.



43.9k

Hi,

looks like you can't connect to your postgreSQL Db.

Can you try:

$connection = new \Phalcon\Db\Adapter\Pdo\Postgresql($config);

That was one of my first thoughts. Tested it with presenting invalid login config.

SQLSTATE[08006] [7] FATAL:  database "postgres22" does not exist

The problem seems to be somewhere else.



43.9k

just double check your config settings

Did it.

I've tried different approaches including creating new postgres role, new superuser, limiting and granting privileges to the db users - all of that tests succeeded with the expected outcome. I don't get it why DevTools is still populating the dbname from the config in the input for schema. Even after manually submitting the form with the proper schema name still it doesn't generate any models.

Any other ideas? Could it be a bug in the DevTools for the current (1.3.2) framework implementation?

edited Jan '15

It's been some months and this question hasn't been answered properly. I had the same issue:

got the error "table xx does not exist".

It turned out to be a problem with permission/ownership of tables and schema, and also a question of case sensitivity. The error is misleading as the tables do exist I just wasn't careful when I created them so they were owned by user postgres rather than the webapp user. Also I had some names with wrong case. All my errors resulting in the same error message. After correcting the errors everything works smoothly.