what the fuck
This commit is contained in:
1 parent
c1b1c2f372
commit
72a99a5bcd
69 files changed
+7519
-558
No files matched your search
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20260402120000 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add nullable cover_image_path to albums for user-uploaded album artwork';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
if (!$this->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';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user