2

When writing a re-initialisation script / extension or drupal module, how would you reset CiviCRM back to clean installation state? Is it possible to install "minimal" without components and their data? Or is component data always pre-installed, enabled or not?

With component data I mean the database data that is needed for some of the build in civicrm components as listed in /civicrm/admin/setting/component. As far as I can remember, at installation I never choose components, they came pre-activated by default. When I deactivate the unnecessary components, a lot of their data is not removed from database and remains. I was wondering if there is a way to force a minimal installation without components and then programmatically activate / install the ones I need.

I was wondering if there is a way to use part of the installer code to restore the initial database, without having to reinvent the wheel.

3
  • do you want to reinstall a fresh copy again ? Commented Jun 16, 2016 at 11:14
  • Yes, but I would like to do it from an extension or Drupal module. A reset button for "prototypers". After that a reinitialisation code would restore the empty prototype ready for use .
    – ñull
    Commented Jun 24, 2016 at 16:56
  • I don't understand any of these answers! I want to "Nuke" my civiCRM install, but only the database, start from scratch. How can I do that? Is there an original SQL file I can get and then import it in PHPmyadmin? I'me working with locahost Xampp, windows 10, Drupal 7 / CiviCRM , sharing the database with Drupal instal. I don't care about the data of either one! Commented Jul 29, 2018 at 4:08

2 Answers 2

2

I'm not certain what's meant by "component data" here - but in all likelihood the easiest approach is to restore a copy of the civicrm.mysql and civicrm_generated.mysql files in the "sql" directory. Don't forget to drop your database first, restoring a SQL file won't drop existing tables created, e.g. by generating custom fields.

2
  • I updated my question in the hope I now explain it better. I was already looking at using civicrm.mysql but I became discouraged by the many civicrm_updatedb_*. So you say I don't need to apply these patches?
    – ñull
    Commented Jul 28, 2016 at 16:46
  • 1
    @ñull No, those are only for upgrades! You just need civicrm.mysql and civicrm_generated.mysql. Are you aware of the "regen.sh" file in the <civiroot>/bin folder? This does what you want and more - but if you look at the last four lines you'll see the part you're interested in. Commented Jul 28, 2016 at 18:14
1

In that case you should be using hooks in the extension

you should have all the code related to extension in this below hook while install

hook_civicrm_install

And you should roll back all the action which you did while installing against uninstall

hook_civicrm_uninstall

more reference: https://wiki.civicrm.org/confluence/display/CRMDOC/Hook+Reference

I guess this helps !!!

2
  • I know that "mechanism" but that is not what I am after. An extension uninstall only removes what the extension added. I want an extension install to resets CiviCRM to a (near) virginal state.
    – ñull
    Commented Jun 27, 2016 at 18:10
  • In that case you need to try by taking a back up of the database - but I don't think you can write an extension for this - Commented Jun 28, 2016 at 8:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.