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

Migrations - Up(), Down() Empty

Hi everyone,

I am trying to create migrations so other team members can update their databases, but the main problem is that methods that should contain changes (Up() and Down() methods according to the documentation) are empty. Only thing that occurs in migration classes is this morph() method which indeed contains new structure, but does not seem to be affecting migration process.

When I run migration on a database that has not previously been modified i get:

C:\xampp\htdocs\project>phalcon migration run

Phalcon DevTools (2.1.0 RC 1)

Also, we are using PostgreSQL 9.4.6 and Dev Tools 2.1.0 RC1 from 2.1.X branch.

Any help is appreciated!

You have to write migration yourself, migration generate just creates a directory with file(s) in it. Autocreated files contain just the current structure, up() and down() functions are for you to fill.

And of course, running an empty migration has no effect on a database.

You probably assumed that migration generate will create a migration which contains all the changes you've made to a database to a given moment, didn't you?



922

I did assume that, yes, since the documentation and that video shows particulary how changes to the database affect migration files (https://docs.phalcon.io/en/latest/reference/migrations.html). So, I would say that eather you are mistaken, or the documentation is misleading.

Eather way, this is what my migrations file look like: https://pastebin.com/49i1s6cq