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

Howto create database structure using models and annotations

Hello,

I'm used to create my own database tables using cli/pma, but this thime I'd like to create it using only models, annotations and ORM. In these, I saw multiple examples using annotations to bind variables to databases, but I didn't find any way to create the database structure from these annotations.

I've followed the official tutorials, read what I think are related references (model, meta-data, migration...) and checked the source code available on github, but I didn't find any answers for this.

So far, I understood these points (please correct me if I'm wrong) :

  • metadata (and related functions) are to bind models with existing database fields
  • Migration (+ devtools cli) translate existing database structure into up/down + morph.
  • Annotations and related strategies does not seems to be used on devtools.

Can you explain me how to create the database structure only using annotations in models ? Preferably with standard devtools module, so it can be portable.

Thanks for this great tool ! It's a real pleasure to work with it !

IMHO, creating database model should always be done the right way.

I'm not sure Phalcon ORM will offer you such function by default.



145.0k
Accepted
answer
edited Jul '16

Short answer - you can't. Currently there is only migrations. In future i have in my plans creating functionallity which you mention.

Ok, short answer is pretty clear :)

I'll continue the manual (and more correct to me) way :)

Thanks all !

Come back like something before end of year, maybe it will be added :D