I'm developing an installation profile which requires multiple databases to be set up (the database that Drupal is being installed to, and another to import some initial data - nodes etcetera - from). This is now a complex thing that I believe could be easier.

Additionally, I see it may be helpful to be able to configure slave databases during installation of Drupal

Current way to get this accomplished, requires a lot of coding in the installation profile

  • Add a form for database configuration
    This requires copying the form from the original installation process, adding/modifying fields if necessary (e.g. the database connection name, other than 'default'). Lots of code duplication here...
  • Copy the form validation function. Big issue here: the _install_settings_form_validate() writes the database url that's passed on to the global $databases['default']['default'], so they can be tested. All of this means you also can't use the DatabaseInstaller class to test the connection -- or you need to write code so the default/default connection is preserved.
  • Copy the form submit function
    After all, the original submit function only writes the default database. This copy has to write out all databases, including the one just created.

The main things that need to be changed for this:

  • Make it possible to have DatabaseInstaller test databases other than the default/default one. I don't know the code well, but I believe this means adding properties for the database to select (database name and target database), and use these properties in the db_set_active() call in testConnect()
  • _install_settings_form_validate() needs to be changed to receive additional (optional?) parameters for the database to use, and the target database. Should probably default to the "default" database with "default" target, though these should really be set in the form and come from the caller.
  • So the database setup form also needs to be changed: it should pass on default settings for the database and target names.
  • Additionally, the form may need an extra button (in the advanced options, I guess) to add extra targets for the database. Either the default target should be saved and then the form should be shown again for the new target, or the form should have/get multiple tabs to set up other targets.
  • Allow installation profiles to tell the install system which databases need to be set up, besides "default". This way all databases can be set up right after each other, without the site information form popping up in between (which also happens to tell the user that write access to settings.php should be removed, which would break changing settings.php afterwards, when the installation profile runs).

(For the last item: see #445012: Prevent drupal_rewrite_settings() from overwriting customizations made to settings.php: the "remove write access" message is shown before the profile runs; perhaps this should be delayed to the end of the installation? Currently a user with initially an empty/non-existent settings.php file should not follow these instructions if the profile requires write access to settings.php)

An alternative approach is to have the installation profile just check the settings, and if they're not available show a message to the user to change the settings manually, then keep checking until the user got it right. Still: being able to check for extra databases using the existing functions from the install system would be nice, so the first 3 changes would still need to be made for that. In my opinion if a user needs to make changes to settings.php manually for the profile is unnecessarily complicated though.

Would this be possible, or am I trying to do things which are perhaps too advanced? Opinions, please! I am willing to develop this and make the necessary patches to accomplish the above, if more people see the need for this.

Background
I'll try to explain where all of this comes from: I'm currently writing an installation profile for an existing PostNuke site, which is going to be migrated to Drupal. Some new content has to be imported from another (prepared) Drupal database, the rest comes from the existing PostNuke database. To make the migration on the live site as smooth (and short) as possible, I'm writing support modules to migrate all the content -- but these need extra database connections. This importing will run in batch-mode during installation of Drupal, so as little as possible needs to be done during the actual deployment. Added bonus is that this way it can reliably be tested offline, and so downtime and the chance of (manual) mistakes is limited as much as possible. Preparing a Drupal database right now is impossible, since the PostNuke site is still online and changing all the time - we don't want any data to be lost in the progress, of course.

All this is still Drupal 6 and I know it's too late to get the changes I want in D6. I guess there will be others like me though in the future, so having this in D7 will help them. If the extra databases can be configured - or at least easily checked - during installation, it becomes much easier to make sure nothing goes wrong when performing the deployment on the production site. Moreover, it allows for more advanced database configurations without having to manually prepare a settings.php file.

Comments

stephencamilo’s picture

Status: Active » Closed (won't fix)
hestenet’s picture

Status: Closed (won't fix) » Active

Reset issue status.