hasTable($schema, 'albums') || $this->hasColumn($schema, 'albums', 'cover_image_path')) { return; } if ($this->isSqlite()) { $this->addSql('ALTER TABLE albums ADD COLUMN cover_image_path VARCHAR(255) DEFAULT NULL'); return; } $this->addSql('ALTER TABLE albums ADD cover_image_path VARCHAR(255) DEFAULT NULL'); } public function down(Schema $schema): void { if ($this->isSqlite()) { // SQLite column removal requires a table rebuild; keep this migration forward-only on SQLite. return; } if ($this->hasTable($schema, 'albums') && $this->hasColumn($schema, 'albums', 'cover_image_path')) { $this->addSql('ALTER TABLE albums DROP COLUMN cover_image_path'); } } private function hasTable(Schema $schema, string $tableName): bool { return $schema->hasTable($tableName); } private function hasColumn(Schema $schema, string $tableName, string $columnName): bool { return $this->hasTable($schema, $tableName) && $schema->getTable($tableName)->hasColumn($columnName); } private function isSqlite(): bool { return $this->connection->getDatabasePlatform()->getName() === 'sqlite'; } }