Drupal 8,

How to switch between installation profiles in same instance??
(minimal to standard / standard to minimal)

Comments

heykarthikwithu created an issue. See original summary.

ajalan065’s picture

heykarthikwithu’s picture

hi @ajalan065, since vset not existing in 8.x this might not workout,

but will check the profile_switcher, how its working :) thanks.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

geerlingguy’s picture

I had the same question, but for standard to lightning (Acquia's distribution). AFAICT, it might just be adding a line like the following to your settings.php:

$settings['install_profile'] = 'lightning';

See also, #2839593-9: Undefined index: name and version on Status report

geerlingguy’s picture

Status: Active » Fixed

It looks like there's one more step required to get it working; you have to 'enable' the profile like you would a module. So the entire process for switching to a new profile is:

  1. Add/update the install_profile in settings.php: $settings['install_profile'] = 'lightning';
  2. Run the following command to enable the profile: drush cset core.extension module.lightning 0
  3. (If you use CMI/have the core.extension.yml exported, export the updated extension listing to file).

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

alexmoreno’s picture

jonathanshaw’s picture

You have to set the profile value in the config, then rebuild caches, then install the profile. This worked for me:

\Drupal::configFactory()->getEditable('core.extension')
  ->set('profile', 'my_new_profile')
  ->save();
drupal_flush_all_caches();

\Drupal::service('module_installer')->install(['my_new_profile']);  
\Drupal::service('module_installer')->uninstall(['my_old_profile']);

$sc = \Drupal::keyValue('system.schema');
if ($sc->get('my_old_profile')) {
  $sc->delete('my_old_profile');
}
drupal_flush_all_caches();
Mr K’s picture

@ajalan065, @geerlingguy, @jonathanshaw, @alexmoreno, @Dropa

Thanks guys for all the great work. Am not a coder and a newbie to drush. Could you give a step-by-step on how to use Profile Switcher with Drush.

I really need to urgently switch from standard profile on an already installed site to a new profile generated with the Features module. I have installed Drush 9.4 on Drupal 8.4.5

Thanks in advance.

jonathanshaw’s picture

Install the devel module
Go to /devel/php
Paste code from #10
Modify to insert your profile names
Execute
Uninstall devel

Try first on something other than live site

Mr K’s picture

Thanks jonathanshaw. Will try it out.

jonathanshaw’s picture

I missed something, we need to set schema as well. Updated script:

$old = 'YOUR_OLD_PROFILE_NAME';
$new = 'YOUR_NEW_PROFILE_NAME';
\Drupal::configFactory()->getEditable('core.extension')
  ->set('profile', $new)
  ->save();
drupal_flush_all_caches();

\Drupal::service('module_installer')->install([$new]);  
\Drupal::service('module_installer')->uninstall([$old]);

$sc = \Drupal::keyValue('system.schema');
$weight = 8000;
if ($weight = $sc->get($old)) {
  $sc->delete($old);
}
$sc->set($new, $weight);
drupal_flush_all_caches();
bcweaver’s picture

On my site, after running the code in #14, the admin pages would just show a generic error, logging this error in watchdog (which I could see via drush):

Drupal\Core\Extension\Exception\UnknownExtensionException: The module standard does not exist. in Drupal\Core\Extension\ExtensionList->get()

I was able to get it working by putting the code in #14 in a stand-alone php file and executing it using "drush scr", and then executing the code below using a separate script, also run using "drush scr":

$old = 'YOUR_OLD_PROFILE_NAME';

// Read the configuration.
$module_data = \Drupal::config('core.extension')->get('module');

// Unset the modules you do not need.
unset($module_data[$old]);

// // Write the configuration.
\Drupal::configFactory()->getEditable('core.extension')->set('module', $module_data)->save();

Then clear cache one more time.

Sharing my experience here in case it helps anyone who ran into the same troubles that I did.

Jon Pugh’s picture

Looks like you forgot a double ==?

if ($weight = $sc->get($old)) {

should be

if ($weight == $sc->get($old)) {
RabiaSajjad’s picture

The solution in #14 works. I needed an additional step prior to executing the code in #14

drush state:delete system.profile.files;

colan’s picture

The general comments above are now all incorporated into Profile Switcher, which was mentioned in #2. If you have additional changes, please contribute in that project.