0 votes

I couldn't find the possibility to set the "tablePrefix" attribute for the "database" element in the exported DB schema file.
I suppose the proper place for it would be in the module settings in the application.
Please see the Propel's DB schema specs for details:
http://propelorm.org/reference/schema.html#database-element

in Solved by (310 points)
recategorized by

1 Answer

0 votes
Best answer

thanks for information. You're right that tablePrefix attribute is missing in our configuration file (together with schema attribute).
Next version will contain fix for this issue. In the meanwhile please use following quick fix:

Please edit file Configuration/Propel.ormd2.cfg.xml in your installation directory and add following lines:

            <attribute name="schema" type="string" help-text="pecifies the default SQL schema containing the tables. Ignored on RDBMS not supporting database schemas"/>
            <attribute name="tablePrefix" type="string" help-text="adds a prefix to all the SQL table names."/>

anywhere between line 30 and 38 (inside struct element) :

  <struct name="Module">
    <attribute name="name" type="string" help-text="name which is exported to database element"/>
    <attribute name="defaultIdMethod" type="enum" enum-values="native|none" help-text="default=`none`"/>
    <attribute name="package" type="string" help-text="default=`project name`"/>
    <attribute name="baseClass" type="string" help-text="default=`propel.om.BaseObject`"/>
    <attribute name="basePeer" type="string" help-text="default=`propel.util.BasePeer`"/>
    <attribute name="defaultPhpNamingMethod" type="enum" help-text="default=`underscore`" enum-values="nochange|underscore|phpname"/>
    <attribute name="heavyIndexing" type="bool" help-text="default=`false`"/>
    <attribute name="namespace" type="string" help-text="Namespace for all entities in this module"/>
    <attribute name="schema" type="string" help-text="pecifies the default SQL schema containing the tables. Ignored on RDBMS not supporting database schemas"/>
    <attribute name="tablePrefix" type="string" help-text="adds a prefix to all the SQL table names."/>
    <ordered name="behaviors" type="/Behaviors"/>
  </struct>

Please let me know if this fix resolve your problem.

by Skipper developer (136k points)
selected by

Well, it seems to solve the problem partially.
The attribute is correctly exported into the schema file, but when you run propel-gen, it reports the tables, which are affected by the prefix, cannot be found when processing foreign keys. It happens because these table names when exported into <"foreign-key" foreignTable=""> weren't prefixed. So effectively you can define the table prefix but your project won't be built correctly by the propel's generator.

Apart from this, the "skipSql" attribute (and maybe some more?) for associations is also missing (see: http://propelorm.org/reference/schema.html#foreign-key-element). I used your solution for that, it seems to work, but it would be nice not to have to correct it after installing the application;).

Thanks for feedback. So If I understand correctly, propel supports prefix for tables in separate attribute but it's still necessary to export this prefix directly to tableNames? It's seems pretty weird to me ;-).

Could you please share some code snippet which works correctly for you?

Regarding to other Propel attributes, I will check it all and update ORM Designer configuration files.

All new properties should be added in latest released version: http://www.orm-designer.com/download-orm-designer