propelorm / Propel2

Propel2 is an open-source high-performance Object-Relational Mapping (ORM) for modern PHP
http://propelorm.org/
MIT License
1.26k stars 397 forks source link

Multiple schema files in different folder fail to work #327

Closed tentacode closed 11 years ago

tentacode commented 11 years ago

In a effort to organize my code into modules (in a Silex project), I wanted to take a look at packages, or more generally multiple schemas.

Schema files are located in different dir, and there is only one place where the config files are (build.properties and runtime-conf.xml).

First the buil-sql task fails to work as expected (the sql file should have the package name).

Also the build-model fails if I'm having a foreign key on a distant schema.

I'm looking for something like in Symfony2 where you can organize add a schema file to each bundle.

I made a repository explaining the problem and how to reproduce it.

https://github.com/tentacode/Propel2MultipleSchemas

bonus : I know in the documentation is writen "all schema files should be in the same directory", I think it's a limitation... and I tried and it does not work any better, perhaps I'm missing something ? :)

If there is any other way to get several schema files to work, I'd gladly take it.

cristianoc72 commented 11 years ago

Hi, Propel generator considers each schema file as a "stand-alone" Propel\Generator\Database object. During the generation process, Propel doesn't know anything about database itself, and its work is based only on the current schema. So, it's not possibile to define a foreign key referencing an extra-schema table, because there isn't a way to let Propel know anithing about this table. All those tables referencig each other via foreign keys must be in the same schema file or in a file in the same directory.

tentacode commented 11 years ago

Well, first of all it did not work any better with all schema in the same directory. But that is not what matters really, I think it's a limitation and the location of schema files should not matter in a multiple component approach (http://propelorm.org/cookbook/multi-component-data-model.html).

I'm pretty sure Symfony2 and the PropelBundle already allow to put schema files in bundles and reference foreign key from one to another, why should this be framework specific ? I'm trying to give a chance to Silex framework and it's the only thing right now that could make me come back to Symfony2.

The purpose is to open source pieces of working MVC code.

willdurand commented 11 years ago

In the PropelBundle, I find all schemas and merge them IIRC. That's probably why it works.

In Silex, we rely on "raw" Propel features.

Le 7 déc. 2012 à 10:13, Gabriel Pillet notifications@github.com a écrit :

Well, first of all it did not work any better with all schema in the same directory. But that is not what matters really, I think it's a limitation and the location of schema files should not matter in a multiple component approach (http://propelorm.org/cookbook/multi-component-data-model.html).

I'm pretty sure Symfony2 and the PropelBundle already allow to put schema files in bundles and reference foreign key from one to another, why should this be framework specific ? I'm trying to give a chance to Silex framework and it's the only thing right now that could make me come back to Symfony2.

The purpose is to open source pieces of working MVC code.

— Reply to this email directly or view it on GitHub.

tentacode commented 11 years ago

Yeah, that's how I thought it work. I think I'll do the same in a Silex package, but then it would be a requirement for my other packages... Do you think it would be a good PR for https://github.com/propelorm/PropelServiceProvider ?

If not I'll just code my own Propel helper

willdurand commented 11 years ago

Sure it could be nice. The PropelServiceProvider is a bit useless at the moment.

tentacode commented 11 years ago

I'll try to think of something, I might just fork PropelServiceProvier and play with it for the moment, thank you for the details.