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
CommentFileSizeAuthor
#5 drush-domain-modify.patch1.41 KBdevelnk
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

agentrickard’s picture

Makes 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?

Mark_L6n’s picture

Thanks 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:

  1. Would table 'staging_domain' have the same structure as table 'domain'?
  2. Would table 'staging_domain_alias' have the same structure as a 'domain_alias' table added by the Domain Alias extension module?
  3. Where would that custom code be placed?
agentrickard’s picture

1. Yes
2. Yes
3. settings.php

agentrickard’s picture

The drush command would also be scriptable, as part of a deployment.

develnk’s picture

Issue summary: View changes
FileSize
1.41 KB

I 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.