shouldAddColumn($schema, 'users', 'profile_image_path')) { $this->addSql('ALTER TABLE users ADD profile_image_path VARCHAR(255) DEFAULT NULL'); } if ($this->shouldAddColumn($schema, 'albums', 'cover_image_path')) { $this->addSql('ALTER TABLE albums ADD cover_image_path VARCHAR(255) DEFAULT NULL'); } } public function down(Schema $schema): void { if ($this->isSqlite()) { // SQLite cannot drop columns; leave them in place. return; } if ($schema->hasTable('users') && $schema->getTable('users')->hasColumn('profile_image_path')) { $this->addSql('ALTER TABLE users DROP profile_image_path'); } if ($schema->hasTable('albums') && $schema->getTable('albums')->hasColumn('cover_image_path')) { $this->addSql('ALTER TABLE albums DROP cover_image_path'); } } private function isSqlite(): bool { return $this->connection->getDatabasePlatform()->getName() === 'sqlite'; } private function shouldAddColumn(Schema $schema, string $tableName, string $column): bool { if (!$schema->hasTable($tableName)) { return false; } return !$schema->getTable($tableName)->hasColumn($column); } }