public function setUp()
    {
        parent::setUp();
        if (!class_exists('\\Relation1UserFriendQuery')) {
            $schema = '
    <database name="migration" schema="migration">
        <table name="relation1_user_friend" isCrossRef="true">
            <column name="user_id" type="integer" primaryKey="true"/>
            <column name="friend_id" type="integer" primaryKey="true"/>

            <foreign-key foreignTable="relation1_user" phpName="Who">
                <reference local="user_id" foreign="id"/>
            </foreign-key>

            <foreign-key foreignTable="relation1_user" phpName="Friend">
                <reference local="friend_id" foreign="id"/>
            </foreign-key>
        </table>

        <table name="relation1_user">
            <column name="id" type="integer" primaryKey="true" autoIncrement="true"/>
            <column name="name"/>
        </table>
    </database>
        ';
            $this->buildAndMigrate($schema);
        }
    }
    public function setUp()
    {
        parent::setUp();
        if (!class_exists('\\Relation2UserQuery')) {
            $schema = '
    <database name="migration" schema="migration">
        <table name="relation2_user_group" isCrossRef="true">
            <column name="user_id" type="integer" primaryKey="true"/>
            <column name="group_id" type="integer" primaryKey="true"/>
            <column name="position_id" type="integer" primaryKey="true"/>

            <foreign-key foreignTable="relation2_user" phpName="User" onDelete="cascade">
                <reference local="user_id" foreign="id"/>
            </foreign-key>

            <foreign-key foreignTable="relation2_group" phpName="Group" onDelete="cascade">
                <reference local="group_id" foreign="id"/>
            </foreign-key>

            <foreign-key foreignTable="relation2_position" phpName="Position" onDelete="cascade">
                <reference local="position_id" foreign="id"/>
            </foreign-key>
        </table>

        <table name="relation2_user">
            <column name="id" type="integer" primaryKey="true" autoIncrement="true"/>
            <column name="name" />
        </table>

        <table name="relation2_group">
            <column name="id" type="integer" primaryKey="true" autoIncrement="true"/>
            <column name="name" />
        </table>

        <table name="relation2_position">
            <column name="id" type="integer" primaryKey="true" autoIncrement="true"/>
            <column name="name" />
        </table>
    </database>
        ';
            $this->buildAndMigrate($schema);
        }
    }
示例#3
0
 protected function tearDown()
 {
     $this->removeTables();
     parent::tearDown();
 }