Add role if missing on create users
This commit is contained in:
parent
8622dfd2bd
commit
262f742017
1 changed files with 13 additions and 0 deletions
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
|
||||
use Doctrine\DBAL\Schema\Column;
|
||||
use Doctrine\DBAL\Types\SmallIntType;
|
||||
use Doctrine\DBAL\Types\Type;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
|
@ -17,8 +18,20 @@ return new class extends Migration
|
|||
*/
|
||||
public function up()
|
||||
{
|
||||
$columns = collect(
|
||||
Schema::getConnection()
|
||||
->getDoctrineSchemaManager()
|
||||
->listTableColumns('users')
|
||||
)->mapWithKeys(function (Column $column) {
|
||||
return [$column->getName() => $column];
|
||||
});
|
||||
if (Schema::hasTable('users')) {
|
||||
Log::debug('already has users');
|
||||
|
||||
if ($columns->has('role')) {
|
||||
Log::debug('already has role column');
|
||||
return;
|
||||
}
|
||||
Log::debug('adding role');
|
||||
if (!Type::hasType('integer')) {
|
||||
Type::addType('integer', SmallIntType::class);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue