Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Whenever I upload a site from my local dev machine, I need to change the domain names to match the online sites. It would be great if I could automate this using a drush command, for example like the following:
drush @remotesite domain-modify localsite1.example.com remotesite1.com
drush @remotesite domain-modify localsite2.example.com remotesite2.com
Comment | File | Size | Author |
---|---|---|---|
#5 | drush-domain-modify.patch | 1.41 KB | develnk |
Comments
Comment #1
agentrickardMakes sense, if I were you I would be aliasing sites and using the techniques discussed here: https://drupal.org/node/1096988
See also #1303616: Allow alias registry for auto-creation.
As to this exact request, I presume you want to change the 'subdomain' value in the database, not the sitename?
Comment #2
Mark_L6n CreditAttribution: Mark_L6n commentedThanks for the response! What I'd like to modify is the field at: Administration » Structure » Domains -> edit domain -> Domain , for every domain. Yes, this appears to be the 'subdomain' field in table 'domain'.
I looked at https://drupal.org/node/1096988 at the two options listed for solving this problem; I guess this drush approach would be a 3rd option. It'd be nice as it's an easy solution and doesn't require adding any code to run. [Edit]Also, more importantly, it allows for multiple locations, such as dev, staging, live and backup sites.[End edit]
In the 2nd option there:
Comment #3
agentrickard1. Yes
2. Yes
3. settings.php
Comment #4
agentrickardThe drush command would also be scriptable, as part of a deployment.
Comment #5
develnk CreditAttribution: develnk commentedI created patch adding to drush ability to change sitename and subdomain.
Using: drush domain-modify example.com new.example.com
Replace sitename and subdomain "example.com" to "new.example.com"
This is functional was needed for personal objectives. I think it's not bad to include in the module.