Skip to content
This repository was archived by the owner on Jun 4, 2024. It is now read-only.
This repository was archived by the owner on Jun 4, 2024. It is now read-only.

Migration Generator: Foreign keys are created even though they already exist #14

@cebe

Description

@cebe

When a table has been created with foreign keys, the next generator run will include a migration again that adds the same foreign keys.

Example:

<?php

/**
 * Table for Task
 */
class m200803_210003_change_table_tasks extends \yii\db\Migration
{
    public function safeUp()
    {
        $this->addForeignKey('fk_tasks_project_id_projects_id', '{{%tasks}}', 'project_id', '{{%projects}}', 'id');
        $this->addForeignKey('fk_tasks_creator_id_users_id', '{{%tasks}}', 'creator_id', '{{%users}}', 'id');
    }

    public function safeDown()
    {
        $this->dropForeignKey('fk_tasks_creator_id_users_id', '{{%tasks}}');
        $this->dropForeignKey('fk_tasks_project_id_projects_id', '{{%tasks}}');
    }
}

@Insolita You should be able to reproduce this in the layer5 project when running ./yii gii/api.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions