Migrations: Default to unsignedInteger in changeReferences()

This commit is contained in:
Igor Scheller 2020-09-03 11:15:16 +02:00 committed by msquare
parent 8c630a2148
commit 8296ef0662
6 changed files with 18 additions and 21 deletions

View File

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

View File

@ -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');

View File

@ -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');

View File

@ -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');

View File

@ -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');

View File

@ -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()