0 votes

Received by email:
My environment is Symfony 2.2 a nd Propel 1.6. Many to many do not generate properly associations in schema.

in Solved by Skipper developer (138k points)

1 Answer

0 votes
Best answer

Next ORM Designer version will fix support for many-to-many relations in Propel ORM.

Here is example how ORM Designer export common and many to many associations with single and multiple PK fields.

ORM Designer and Propel ORM - many to many

This model will be exported to following definition file:

<?xml version="1.0"?>
<database name="conn_aviva" namespace="Aviva\DossierBundle\Model" defaultIdMethod="native">
    <table name="RealMN" isCrossRef="true">
        <column name="B_ID" type="Integer" required="true" primaryKey="true"/>
        <column name="A_ID1" type="Char" size="2" required="true" primaryKey="true"/>
        <column name="A_ID2" type="Char" size="8" required="true" primaryKey="true"/>
        <foreign-key foreignTable="A">
            <reference local="A_ID1" foreign="ID1"/>
            <reference local="A_ID2" foreign="ID2"/>
        </foreign-key>
        <foreign-key foreignTable="B">
            <reference local="B_ID" foreign="ID"/>
        </foreign-key>
    </table>
    <table name="SimulateMN" isCrossRef="true" heavyIndexing="true">
        <column name="B_ID" type="Integer" required="true" primaryKey="true"/>
        <column name="A_ID1" type="Char" size="2" required="true" primaryKey="true"/>
        <column name="A_ID2" type="Char" size="8" required="true" primaryKey="true"/>
        <foreign-key foreignTable="B" onDelete="cascade" onUpdate="cascade">
            <reference foreign="ID" local="B_ID"/>
        </foreign-key>
        <foreign-key foreignTable="A" onDelete="cascade" onUpdate="cascade">
            <reference foreign="ID1" local="A_ID1"/>
            <reference foreign="ID2" local="A_ID2"/>
        </foreign-key>
    </table>
    <table name="B">
        <column name="ID" description="FK de itool_auth.TS_DOSSIER" type="Integer" primaryKey="true"/>
    </table>
    <table name="D" description="aka Code soci&#xE9;t&#xE9;&#10;1 Aviva Assurance&#10;2 Aviva Vie&#10;3 Courtage">
        <column name="ID" type="Char" size="2" required="true" primaryKey="true"/>
        <unique name="IX_UQ_D_ID">
            <unique-column name="ID"/>
        </unique>
    </table>
    <table name="C">
        <column name="ID" type="Integer" size="11" autoIncrement="true" primaryKey="true"/>
        <column name="A_ID1" type="Char" size="2" required="true"/>
        <column name="A_ID2" type="Char" size="8" required="true"/>
        <unique name="IX_UQ_C_ID">
            <unique-column name="ID"/>
        </unique>
        <foreign-key foreignTable="A">
            <reference foreign="ID1" local="A_ID1"/>
            <reference foreign="ID2" local="A_ID2"/>
        </foreign-key>
    </table>
    <table name="A" heavyIndexing="true">
        <column name="ID1" description="Code soci&#xE9;t&#xE9; (1 pour AVIVA ASSURANCE ou 2 pour AVIVA VIE)" type="Char" size="2" required="true" autoIncrement="true" primaryKey="true"/>
        <column name="ID2" type="Char" size="8" required="true" primaryKey="true"/>
        <foreign-key foreignTable="D">
            <reference foreign="ID" local="ID1"/>
        </foreign-key>
    </table>
</database> 
by Skipper developer (138k points)