Migrations: Default to unsignedInteger in changeReferences()

main
Igor Scheller 4 years ago committed by msquare
parent 8c630a2148
commit 8296ef0662

@ -160,8 +160,7 @@ class CreateUsersTables extends Migration
'User',
'UID',
'users',
'id',
'unsignedInteger'
'id'
);
}

@ -38,8 +38,7 @@ class CreateNewsTable extends Migration
'PreviousNews',
'ID',
'news',
'id',
'unsignedInteger'
'id'
);
$this->schema->drop('PreviousNews');
}
@ -59,8 +58,7 @@ class CreateNewsTable extends Migration
'new_news',
'id',
'News',
'ID',
'unsignedInteger'
'ID'
);
$this->schema->drop('new_news');

@ -30,8 +30,7 @@ class CreateNewsCommentsTable extends Migration
'NewsComments',
'ID',
'news_comments',
'id',
'unsignedInteger'
'id'
);
$this->schema->drop('NewsComments');
}
@ -48,8 +47,7 @@ class CreateNewsCommentsTable extends Migration
'news_comments',
'id',
'NewsComments',
'ID',
'unsignedInteger'
'ID'
);
$this->schema->drop('news_comments');

@ -38,8 +38,7 @@ class CreateMessagesTable extends Migration
'PreviousMessages',
'ID',
'messages',
'id',
'unsignedInteger'
'id'
);
$this->schema->drop('PreviousMessages');
}
@ -59,8 +58,7 @@ class CreateMessagesTable extends Migration
'new_messages',
'id',
'Messages',
'ID',
'unsignedInteger'
'ID'
);
$this->schema->drop('new_messages');

@ -37,8 +37,7 @@ class CreateQuestionsTable extends Migration
'PreviousQuestions',
'QID',
'questions',
'id',
'unsignedInteger'
'id'
);
$this->schema->drop('PreviousQuestions');
}
@ -58,8 +57,7 @@ class CreateQuestionsTable extends Migration
'new_questions',
'id',
'Questions',
'QID',
'unsignedInteger'
'QID'
);
$this->schema->drop('new_questions');

@ -14,8 +14,13 @@ trait ChangesReferences
* @param string $targetColumn
* @param string $type
*/
protected function changeReferences($fromTable, $fromColumn, $targetTable, $targetColumn, $type)
{
protected function changeReferences(
string $fromTable,
string $fromColumn,
string $targetTable,
string $targetColumn,
string $type = 'unsignedInteger'
) {
$references = $this->getReferencingTables($fromTable, $fromColumn);
foreach ($references as $reference) {
@ -41,9 +46,10 @@ trait ChangesReferences
/**
* @param string $table
* @param string $column
*
* @return array
*/
protected function getReferencingTables($table, $column): array
protected function getReferencingTables(string $table, string $column): array
{
return $this->schema
->getConnection()

Loading…
Cancel
Save