Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generating unique index for HasOne relation in Cycle\MigrateCommand #50

Closed
Eugentis opened this issue Apr 8, 2020 · 0 comments
Closed
Labels
bug Something isn't working

Comments

@Eugentis
Copy link

Eugentis commented Apr 8, 2020

I've detected some strange logic on generating index for HasOne relation.
I have 2 entities:

class Item extends AbstractEntity
{
    /**
     * @Cycle\Relation\HasOne(
     *     target="ItemInfo ",
     *     outerKey="item_id",
     *     fkAction="CASCADE"
     * )
     */
    public ItemInfo $info;
    ...
}
class ItemInfo extends AbstractEntity
{
    /**
     * @Cycle\Relation\BelongsTo(
     *     target="Item",
     *     innerKey="item_id",
     *     fkAction="CASCADE"
     * )
     */
    public Item $item;
    ...
}

I am expecting from generated migration that index will be unique but the command prepares next description:

public function up()
    {
        $this->table('item_info')
            ...
            ->addIndex(["item_id"], [
                'name'   => 'item_info_index_item_id_5e8d9e2681e26',
                'unique' => false
            ])
            ->addForeignKey(["item_id"], 'item', ["id"], [
                'name'   => 'item_info_foreign_item_id_5e8d9e2681e33',
                'delete' => 'CASCADE',
                'update' => 'CASCADE'
            ])
            ...
            ->create();
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants