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

Migration generator creates an almost empty file

I'm trying to set up migrations in Phalcon 3. I gitcloned the fresh version of developer tools and run

phalcon migration generate --config=app/Config/Settings.dev.php --migrations=./migrations

but I've got an almost empty file:

<?php 

use Phalcon\Db\Column;
use Phalcon\Db\Index;
use Phalcon\Db\Reference;
use Phalcon\Mvc\Model\Migration;

/**
 * Class PotdMigration_100
 */
class PotdMigration_100 extends Migration
{
    /**
     * Define the table structure
     *
     * @return void
     */
    public function morph()
    {
        $this->morphTable('potd', [
                'columns' => [

                ],
                'indexes' => [
                    new Index('potd_pkey', ['id'], null)
                ],
            ]
        );
    }

    /**
     * Run the migrations
     *
     * @return void
     */
    public function up()
    {

    }

    /**
     * Reverse the migrations
     *
     * @return void
     */
    public function down()
    {

    }

}

As you can see, there is no any column definition, while in this sample video I see that whole table structure in there out of the box. The other strange thing is phalcon created indexes with my primary key index, so I assume that it was able to access the DB itself, but something went wrong. Is this generator behavior was changed since that video was created? I could describe all columns by hand, but in the video it were described automatically.

  • Phalcon version is 3.0.1
  • PG version is 9.5.4
  • DevTools is 3.0.1 installed manually via clone of https://github.com/phalcon/phalcon-devtools.git


145.0k
Accepted
answer
edited Oct '16

You need to checkout 3.0.x i think in devtools possibly.

@tommiv Did you try to checkout 3.0.x branch?

edited Oct '16

Thanks for your responses, after checkout I've got this message:

Phalcon DevTools (3.0.2)

1476833375.3419: SELECT table_name FROM information_schema.tables WHERE table_schema = 'whitespace' ORDER BY table_name  => 1476833375.3507 (0.0087659358978271)

  Info: Nothing to generate. You should create tables at first.

At first I even afraid that my DB is gone (thanks god I have a dump), but no, table is intact.

Should I install devtools via composer instead?

edited Oct '16

Found my error. In DevTools readme there is a sample of adapter config. For PG is adapter => Postgresql (note a capital P). In my config it was lowercased postgresql. Somehow it worked (well, kinda) for master branch, but it's a dealbreaker for 3.0.x. I double checked and with lowercase I get an error about "nothing to generate", while capitalized letter gives me a proper migration::

public function morph()
    {
        $this->morphTable('potd', [
                'columns' => [
                    new Column(
                        'id',
                        [
                            'type' => Column::TYPE_INTEGER,
                            'notNull' => true,
                            'first' => true
                        ]
                    ),
                    ...etc

Thanks again for your blazing fast responses.