Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Howto create database structure using models and annotations


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.

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