Switching Installation Profiles on Existing Drupal Sites

In my last blog post I outlined how to use per project installation profiles. If you read that post and want to use installation profiles to take advantage of site wide content changes and centralised dependency management, this post will show you how to do it quickly and easily.

The easiest way to switch installation profiles is using the command line with drush. The following command will do it for you:

$ drush vset --exact -y install_profile my_profile

An alternative way of doing this is by directly manipulating the database. You can run the following SQL on your Drupal database to switch installation profiles:


UPDATE variable SET value = 'my_profile' WHERE name = 'install_profile';
-- Clear the cache using MySQL only syntax, when DB caching is used.
TRUNCATE cache;

Before you switch installation profiles, you should check that you have all the required modules enabled in your site. If you don't have all of the modules required by the new installation profile enabled in your site, your are likely to have issues. The best way to ensure you have all the depedencies enabled is to run the following one liner:

drush en $(grep depedencies /path/to/my-site/profiles/my_profile/my_profile.info | sed -n 's/depedencies\[\]=\(.*\)/\1/p')

Even though it is pretty easy to switch installation profiles I would recommend starting your project with a project specific installation profile.

Edit: Fellow Technocrat, Jaime Schmidt picked up a missing step in the instructions above. You need to enable the installation profile in the system table. The easiest way to do that is with this drush one liner:

echo UPDATE system SET schema_version = 0 WHERE name = 'my_profile' | drush sqlc && drush cc all

Nice

Alex Weber wrote:

Thats a cool little trick, thanks for sharing!

Added Thu, 2012-09-13 05:24

a bit more to it

patcon wrote:

Great point to make Dave, but I think there are also issues with module paths being in the registry and other places in the db (likely only poorly architected contrib modules).

I toyed with using registry_rebuild, a drush contrib module, but it ended up not working as expected on a complex site with lots of custom code. A simple db dump and command-line sed search and replace did thr trick before importing again :)

Added Sat, 2012-09-15 04:58

a bit more to it

patcon wrote:

Great point to make Dave, but I think there are also issues with module paths being in the registry and other places in the db (likely only poorly architected contrib modules).

I toyed with using registry_rebuild, a drush contrib module, but it ended up not working as expected on a complex site with lots of custom code. A simple db dump and command-line sed search and replace did thr trick before importing again :)

Added Sat, 2012-09-15 04:59

What about the entry for the

Lukas von Blarer wrote:

What about the entry for the profile entry itself in the system table?

Added Mon, 2012-10-22 18:53

RE: What about the entry for the

Dave wrote:

This was caught by my colleague after my post was published. The update at the end of the post covers this.

Added Mon, 2012-11-12 22:21

Probably you want to change

Aroq wrote:

Probably you want to change the

echo UPDATE system SET schema_version = 0 WHERE name = 'my_profile' | drush sqlc && drush cc all

into

drush en my_profile

Added Fri, 2014-01-10 19:08

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <p> <div> <blockquote> <pre>

More information about formatting options