. */ declare(strict_types=1); use Illuminate\Database\Migrations\Migration; use Illuminate\Database\QueryException; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; /** * Class FixLdapConfiguration. * * @codeCoverageIgnore */ class FixLdapConfiguration extends Migration { /** * Reverse the migrations. */ public function down(): void { if (Schema::hasColumn('users', 'objectguid')) { try { Schema::table( 'users', static function (Blueprint $table): void { $table->dropColumn(['objectguid']); } ); } catch (QueryException $e) { app('log')->error(sprintf('Could not execute query: %s', $e->getMessage())); app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); } } } /** * Run the migrations. * * @SuppressWarnings(PHPMD.ShortMethodName) */ public function up(): void { /* * ADLdap2 appears to require the ability to store an objectguid for LDAP users * now. To support this, we add the column. */ if (!Schema::hasColumn('users', 'objectguid')) { try { Schema::table( 'users', static function (Blueprint $table): void { $table->uuid('objectguid')->nullable()->after('id'); } ); } catch (QueryException $e) { app('log')->error(sprintf('Could not execute query: %s', $e->getMessage())); app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); } } } }