Coming from #3025393: Imported Platform & Site causes site to not have a Profile set, there are certainly use cases switching sites' installation profiles. For example, a site running on a shared platform with a shared installation profile may with to switch to having its own.

Prerequisites

  • The Profile Switcher module, and
  • Both the old and new profiles in the /profiles directory.

Switching the profile

We'd just need to run the Profile Switcher's Drush command:

drush @site switch:profile old_profile new_profile

Telling Aegir about it

Here's the SQL that the task should run after Profile Switcher does its thing:

UPDATE hosting_site SET profile = (
  SELECT nid FROM hosting_package WHERE package_type = 'profile' AND short_name = '$PROFILE_NAME'
) WHERE nid = (
  SELECT n.nid FROM node n, (
    SELECT * FROM hosting_site
  ) AS s WHERE n.nid = s.nid AND n.title = '$SITE_NAME'
);

The inner-most subquery is necessary because MySQL doesn't allow you to write queries where the inner query references the one being updated. It's a workaround.

Comments

colan created an issue.

shaneonabike’s picture

It's cool we are going to get progress on this. Honestly, I would have been ok with changing the name of my ticket in order to incorporate more of a task. But anyway all good! I never thought about using Profile Switcher that's awesome

colan’s picture

I had to figure all of this out for a client so I thought I'd document it here in case someone else wants to pick it up at some point, as clearly I'm not the only one running into this. I'm not planning on doing any more on this right now though so it's free for others to work on.

colan’s picture