I have three domains/organisations sharing some content using Domain Access. This has been a really successful setup for a two year project where each organisaton needed to keep their own identity but share a lot of material for the joint project. Now one of the organisations is going their own way and I need to separate the sites without losing the rich information we have built up.

If my primary domain is 0, what I want to do is take 0 off to its own solitary web hosting. This is easy enough by turning off Domain Access. What I need help with is domains 2 and 3. I want 2 to become the new primary domain and I want 3 to stay part of the Domain Access stable. Is this doable?

thanks in expectation.
esme

Comments

agentrickard’s picture

Issue tags: +handbook

In Drupal 6, (and 7.x.2), you likely need to write a hook_update_N() function to perform the data changes that you need. This is not complete, but will get you started:

function custom_update_6200() {
  $return = array();
  $return[] = update_sql("DELETE FROM {domain} WHERE domain_id = 0");
  $return[] = update_sql("UPDATE {domain} SET domain_id = 0 WHERE domain_id = 2");
  // Set the default domain variables.
  $primary = db_fetch_object(db_query("SELECT * FROM {domain} WHERE domain_id = 0"));
  variable_set('domain_root', $primary->subdomain);
  variable_set('domain_scheme', $primary->scheme);
  variable_set('domain_sitename', $primary->sitename);
}

That's the easy part, but the UPDATE will need to be performed on every table that uses 'domain_id' as a key (e.g. {domain_editor} and {domain_conf}.

The remaining question is "What do you want to do with domain 0 content on the old site?" Do you want to DELETE it or RE-ASSIGN it to another domain?

esme’s picture

thanks agentrickard. I'm afraid this is a bit beyond me as php is not my forte... For example, where does this function go.
thanks

agentrickard’s picture

In a custom.install file in a custom.module folder.

If you are not comfortable with PHP, the process may be much more difficult.

Essentially, I think you should set up the new site:

a) Clone the database to the new site.
b) Disable DA on the new site.
c) Edit content on that site normally. However, doing so will re-assign all content from the original site to the new domain. If that's ok, you're fine. Otherwise, you have to delete the unwanted content (I would use Domain Content to do this), _before_ you disable DA.
d) Run the node access rebuild script after disabling DA.

On the "old" site, then, you essentially have to trade one domain for another, which is tricky because domains must be unique. I would do this:

a) Backup the database.
b) Delete any content from the primary domain that you don't want to keep on the old site. Be careful not to remove items viewable on all affiliates; leave those assigned to the primary domain. If you want to keep all content, you can skip this step.
c) Re-assign all content domain 2 to the primary domain.
d) Re-name domain 2 from whatever.example.com to bak-whatever.example.com. Set it to 'inactive'.
e) Re-set the primary domain to whatever.example.com.
f) Check that all content from the old domain 2 is now visible on the new primary domain.
g) If desired, delete domain 2 and leave only the primary and domain 3.
h) Run the node access rebuild script.

These are the basic steps, and it would be _very_ helpful if you documented exactly what you had to do. Look out for things that I may have missed, too.

esme’s picture

Thank you kindly for this advice. Much appreciated.

agentrickard’s picture

Component: Miscellaneous » Documentation

This really should get documented.

vidichannel’s picture

Just want to say thanks for the message exchange here. The DA module clearly has many uses (and challenges) that are convoluted and vacuous until they are applied. That was a great example.

agentrickard’s picture

Title: Change primary domain in Domain Access? » Document how to migrate domains
Version: 6.x-2.7 » 7.x-3.x-dev
Category: support » task
Status: Active » Needs work
dqd’s picture

Issue summary: View changes
Status: Needs work » Closed (outdated)

I'll close this issue due to inactivity for 12 years and upcoming EOL of Drupal 7 in January 2025. While the project's version for Drupal 7 will surely keep providing support for security issues and website breaking bug fixes for Drupal 7, we should try to minimize the open issues for Drupal 7 in the queue as much as possible. A big thanks around for the report and all the efforts in here. Feel free to re-open if you can provide a fix or found an additional related problem which increases the issue priority.