. */ declare(strict_types=1); use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\QueryException; use Illuminate\Database\Schema\Blueprint; /** * Class ExpandTransactionsTable. * * @codeCoverageIgnore */ class ExpandTransactionsTable extends Migration { /** * Reverse the migrations. */ public function down(): void { if (Schema::hasColumn('transactions', 'identifier')) { try { Schema::table( 'transactions', static function (Blueprint $table) { $table->dropColumn('identifier'); } ); } catch (QueryException | ColumnDoesNotExist $e) { app('log')->error(sprintf('Could not drop column "identifier": %s', $e->getMessage())); app('log')->error('If the column does not exist, this is not an problem. Otherwise, please open a GitHub discussion.'); } } } /** * Run the migrations. * */ public function up(): void { if (!Schema::hasColumn('transactions', 'identifier')) { try { Schema::table( 'transactions', static function (Blueprint $table) { $table->smallInteger('identifier', false, true)->default(0); } ); } 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.'); } } } }