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

RSS Feed
Nice
Alex Weber wrote:Thats a cool little trick, thanks for sharing!
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 :)
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 :)
What about the entry for the
Lukas von Blarer wrote:What about the entry for the profile entry itself in the system table?
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.
Post new comment