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', 'User',
'UID', 'UID',
'users', 'users',
'id', 'id'
'unsignedInteger'
); );
} }

View File

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

View File

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

View File

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

View File

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

View File

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