38 lines
825 B
PHP
38 lines
825 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace DoctrineMigrations;
|
|
|
|
use Doctrine\DBAL\Schema\Schema;
|
|
use Doctrine\Migrations\AbstractMigration;
|
|
|
|
final class Version20260216143100 extends AbstractMigration
|
|
{
|
|
public function getDescription(): string
|
|
{
|
|
return 'Backfill site display_order';
|
|
}
|
|
|
|
public function up(Schema $schema): void
|
|
{
|
|
$this->addSql('
|
|
UPDATE sites s
|
|
SET display_order = ranked.rn
|
|
FROM (
|
|
SELECT id,
|
|
ROW_NUMBER() OVER (
|
|
ORDER BY name ASC, id ASC
|
|
) AS rn
|
|
FROM sites
|
|
) ranked
|
|
WHERE ranked.id = s.id
|
|
');
|
|
}
|
|
|
|
public function down(Schema $schema): void
|
|
{
|
|
// Pas de rollback pertinent.
|
|
}
|
|
}
|