isSqlite()) { // SQLite installs get albums from Version20251127235840. return; } // Idempotent guard: if table already exists (from previous migration), skip if ($schema->hasTable('albums')) { return; } $this->addSql('CREATE TABLE albums (id SERIAL NOT NULL, spotify_id VARCHAR(64) NOT NULL, name VARCHAR(255) NOT NULL, artists JSON NOT NULL, release_date VARCHAR(20) DEFAULT NULL, total_tracks INT NOT NULL, cover_url VARCHAR(1024) DEFAULT NULL, external_url VARCHAR(1024) DEFAULT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(id))'); $this->addSql('CREATE UNIQUE INDEX UNIQ_F4E2474FA905FC5C ON albums (spotify_id)'); $this->addSql('COMMENT ON COLUMN albums.created_at IS \'(DC2Type:datetime_immutable)\''); $this->addSql('COMMENT ON COLUMN albums.updated_at IS \'(DC2Type:datetime_immutable)\''); } public function down(Schema $schema): void { if ($this->isSqlite()) { return; } // Be defensive: only drop the table if it exists if ($schema->hasTable('albums')) { $this->addSql('DROP TABLE albums'); } } private function isSqlite(): bool { return $this->connection->getDatabasePlatform()->getName() === 'sqlite'; } }