Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
SOHELAHMED7 committed Jun 21, 2024
1 parent c205866 commit 2d10ff4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/lib/migrations/BaseMigrationBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,9 @@ protected function buildRelations():void
$tableAlias = $this->model->getTableAlias();
$existedRelations = [];
foreach ($this->tableSchema->foreignKeys as $fkName => $relation) {
$refTable = $this->unPrefixTableName(array_shift($relation));
$refCol = array_keys($relation)[0];
$fkCol = $relation[$refCol];
$refTable = array_shift($relation);
$fkCol = array_keys($relation)[0];
$refCol = $relation[$fkCol];
$existedRelations[$fkName] = ['refTable' => $refTable, 'refCol' => $refCol, 'fkCol' => $fkCol];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function down()
$this->alterColumn('{{%v2_comments}}', 'message', 'json NOT NULL DEFAULT \'[]\'');
$this->addColumn('{{%v2_comments}}', 'author_id', $this->integer(11)->notNull());
$this->dropColumn('{{%v2_comments}}', 'user_id');
$this->addForeignKey('fk_v2_comments_author_id_v2_users_id', '{{%v2_comments}}', 'id', 'v2_users', 'author_id');
$this->addForeignKey('fk_v2_comments_post_id_v2_posts_uid', '{{%v2_comments}}', 'uid', 'v2_posts', 'post_id');
$this->addForeignKey('fk_v2_comments_author_id_v2_users_id', '{{%v2_comments}}', 'author_id', 'itt_v2_users', 'id');
$this->addForeignKey('fk_v2_comments_post_id_v2_posts_uid', '{{%v2_comments}}', 'post_id', 'itt_v2_posts', 'uid');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function down()
$this->alterColumn('{{%v2_comments}}', 'message', 'json NOT NULL');
$this->addColumn('{{%v2_comments}}', 'author_id', $this->integer()->notNull());
$this->dropColumn('{{%v2_comments}}', 'user_id');
$this->addForeignKey('fk_v2_comments_author_id_v2_users_id', '{{%v2_comments}}', 'id', 'v2_users', 'author_id');
$this->addForeignKey('fk_v2_comments_post_id_v2_posts_uid', '{{%v2_comments}}', 'uid', 'v2_posts', 'post_id');
$this->addForeignKey('fk_v2_comments_author_id_v2_users_id', '{{%v2_comments}}', 'author_id', 'itt_v2_users', 'id');
$this->addForeignKey('fk_v2_comments_post_id_v2_posts_uid', '{{%v2_comments}}', 'post_id', 'itt_v2_posts', 'uid');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function safeDown()
$this->alterColumn('{{%v2_comments}}', 'message', "SET DEFAULT '[]'");
$this->alterColumn('{{%v2_comments}}', 'meta_data', "SET NOT NULL");
$this->alterColumn('{{%v2_comments}}', 'meta_data', "SET DEFAULT '[]'");
$this->addForeignKey('fk_v2_comments_post_id_v2_posts_uid', '{{%v2_comments}}', 'uid', 'v2_posts', 'post_id');
$this->addForeignKey('fk_v2_comments_author_id_v2_users_id', '{{%v2_comments}}', 'id', 'v2_users', 'author_id');
$this->addForeignKey('fk_v2_comments_post_id_v2_posts_uid', '{{%v2_comments}}', 'post_id', 'itt_v2_posts', 'uid');
$this->addForeignKey('fk_v2_comments_author_id_v2_users_id', '{{%v2_comments}}', 'author_id', 'itt_v2_users', 'id');
}
}

0 comments on commit 2d10ff4

Please sign in to comment.