Add Drush command to batch replace domain hostnames (e.g. after DB copy between environments)

Created on 31 July 2025, 1 day ago

Problem/Motivation

When copying the database between environments (e.g. from production to staging or local development), the domain hostnames often need to be updated to match the new environment.

Since we do (they are ignored in config_ignore ), this must be done directly in the database.

Currently, there is no convenient way to batch replace hostnames for all domain entities via Drush.

Proposed resolution

Introduce a new Drush command:

drush domain:replace <find> <replace> [--force]

This command will:

  • Iterate over all domain entities.
  • Replace the string with in the hostname field.
  • By default, do not apply changes unless --force is explicitly passed.
  • Output a table with the affected domains (showing before/after hostnames).

Example use case

drush domain:replace ".example.com" ".local.example.test" --force

This helps quickly adapt hostnames after database copies, without relying on config import/export, and avoids manual edits.

Feature request
Status

Active

Version

2.0

Component

Code

Created by

🇵🇹Portugal falsovsky

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024