addSql('ALTER TABLE machines DROP CONSTRAINT IF EXISTS uniq_f1ce8ded5e237e06'); $this->addSql('DROP INDEX IF EXISTS uniq_f1ce8ded5e237e06'); // Defensive fallbacks for other possible legacy names of the global unique index on name. $this->addSql('ALTER TABLE machines DROP CONSTRAINT IF EXISTS machines_name_key'); $this->addSql('DROP INDEX IF EXISTS machines_name_key'); // New uniqueness scope: a machine name is unique within a given site only. $this->addSql('CREATE UNIQUE INDEX IF NOT EXISTS uniq_machine_name_site ON machines (name, siteid)'); } public function down(Schema $schema): void { $this->addSql('DROP INDEX IF EXISTS uniq_machine_name_site'); // Best-effort restore of the global unique index on machines(name). // WARNING: this will fail if duplicate names now exist across sites (which the // per-site scope allowed). Resolve duplicates manually before rolling back. $this->addSql('CREATE UNIQUE INDEX IF NOT EXISTS uniq_f1ce8ded5e237e06 ON machines (name)'); } }