skipIf(! $this->isMicrosoftSql()); // Drop the existing unique index $shortUrls = $schema->getTable('short_urls'); $shortUrls->dropIndex('unique_short_code_plus_domain'); } public function postUp(Schema $schema): void { // The only way to get the index properly generated is by hardcoding the SQL. // Since this migration is run Microsoft SQL only, it is safe to use this approach. $this->connection->executeStatement( 'CREATE UNIQUE INDEX unique_short_code_plus_domain ON short_urls (short_code, domain_id);', ); } private function isMicrosoftSql(): bool { return $this->connection->getDatabasePlatform() instanceof SQLServerPlatform; } }