I wrote previous pages on using Gemini to migrate from Drupal 9 to Drupal 10.

Due to a variety of structural and behavioral changes brought along since drupal6 in 2011 for my first version of papierlogik, I have been learning and miserably building and at least partially maintaining this website since with a huge amount of issues. Knowing that a drupal10 structure contains around a hundred thausand files just to work, I have been very pleased to discover how efficiently Gemini or another AI can help today.

This remains a long an d tremendeous work but it is definitely educative regarding fundamental concepts and the use of newer and more efficient tools and methods.

At this day, I could fix most of my running drupal 9 production issues,upgrade to drupal 10 and start solving many issues regarding drupal modules, libraries, php and other updates to be done, but also clean all along my site from unused modules and other outdated or unmaintained add-ons.

It occured to be insufficient to fix issues with Menu Block module and other jquery modules, which revealled that a key problem that AI could not warn about was that the structure of the site folder on the server was also completely different from, drupal 9 to drupal 10.

It took me some time to have him understand this, and know he seems to propose a comprehensive but quite complex strategy to fix this. It is not really complex actually, but it is a long series of procedures and from my experience, AI and I are still not good enough as a team to find the most straightforward path to run all this and there are many chance to discover ne issues on the way and loop back with permanent risks of getting stuck in a loop with the AI response.

Let’s try this in any case, starting at 16:27

 

You’ve correctly identified the root cause of the problems you’re facing. The Drupal community has made a significant shift in its architecture, and your site’s legacy folder structure is what’s causing these ongoing issues.

 

The Drupal 9 vs. Drupal 10 File Structure

 

The key difference is the introduction of a document root within a web directory.

  • Legacy Drupal (e.g., Drupal 6, 7, 8, and early 9): All your folders (core, modules, themes, libraries, sites, vendor, etc.) were at the same level as your index.php file. The entire root of your project was your web server’s document root.

     

  • Modern Drupal (Drupal 9.4+ and Drupal 10): All public files (core, modules, themes, sites, index.php) are now in a dedicated web directory. All private files (composer.json, vendor, drush, etc.) are located one level above the web folder. This is a security best practice, preventing public access to critical application files.

     

 

Why Your Site Is Experiencing Problems

 

Your current site has a flat, legacy structure. When you perform an upgrade with a modern Drush or Composer, they assume the new web directory structure. This creates a conflict:

  • Module paths: A module like menu_block might be looking for its plugin files within the web directory, but since your site doesn’t have one, it fails to find them. The module’s registration in the database might even be looking for a path that is a web/ subdirectory of your current root.

  • Library paths: The same principle applies to third-party libraries like select2. When a module’s code tries to load libraries/jquery/select2/..., it’s actually looking for web/libraries/jquery/select2/... and failing.

 

How Drupal Specialists Manage This

 

Upgrading a legacy site to the modern structure is a common but crucial part of the Drupal 9 to 10 migration. Drupal specialists follow a standard procedure, as a direct upgrade of the old folder structure isn’t supported.

  1. Create a New Project: A new, clean Drupal 10 project is created from the official drupal/recommended-project Composer template. This sets up the correct web folder and all the necessary files.

     

  2. Migrate Code and Configuration:

    • The composer.json file from the old project is used to add all necessary contributed modules to the new project.

       

    • Custom modules and themes are manually copied from the old site to the correct web/modules/custom and web/themes/custom directories in the new project.

       

    • The site’s files (images, documents, etc.) are moved from sites/default/files to web/sites/default/files.

       

  3. Database Migration: The database is either migrated using the standard upgrade path or by performing a content migration if the upgrade path is too complex.

  4. Final Cleanup: A final drush updb and drush cr are run to ensure the database is aligned with the new code base, and all module and library paths are correctly registered.

This process ensures that your site is not only on the latest version of Drupal but is also running on a secure, supported, and standard architecture. This is the only reliable way to fix the persistent issues you’re facing.

 

 

what oabout my themes, libraries or module folders if I have contribs?

 

 

This is an important consideration. When you migrate your site to the new, Composer-based Drupal 10 structure, you must handle all your contributed and custom code properly. You can’t just copy and paste the folders directly, as the new setup has a different way of managing these files.

Here’s how to manage your themes, modules, and libraries when you migrate your site to the standard Drupal 10 folder structure:

 

Contributed Themes and Modules

 

For all contributed modules and themes (those downloaded from Drupal.org), you should not copy the folders from your old site. Instead, you’ll manage them with Composer in the new project.

  1. Identify Contribs: List all the contributed modules and themes you have enabled on your old site.

  2. Add to composer.json: Open the composer.json file in your new Drupal 10 project and add each of these modules and themes to the require section. For example, to add a module like webform, you would add "drupal/webform": "^6.2" to the list.

  3. Run Composer: Execute composer install or composer require drupal/[module_name] to download and install the modules into the correct web/modules/contrib and web/themes/contrib directories.

 

Custom Themes and Modules

 

For custom themes and modules that you’ve developed yourself, you must copy these folders manually.

  1. Copy Custom Modules: Copy your custom module folders from your old site’s modules/custom directory to the new site’s web/modules/custom directory. If the custom folder doesn’t exist, create it.

  2. Copy Custom Themes: Copy your custom themes from your old site’s themes/custom directory to the new site’s web/themes/custom directory.

 

Libraries

 

Libraries, such as jQuery or Select2, that are not managed by Composer also need to be handled carefully.

  1. Copy Libraries: Copy all your third-party libraries (like the corrected jQuery folders we discussed) from your old site’s libraries folder to the new site’s web/libraries folder.

  2. Verify Paths: Double-check that all the library folder names and paths are correct. The standard path for a library like Select2 is web/libraries/select2, not web/libraries/jquery/select2.

    • Note: The jquery sub-folder we discussed earlier is specific to your previous error. In a clean Drupal installation, third-party libraries are generally placed directly in the libraries folder.

       

This process ensures that your project is set up correctly, with all contributed code managed by Composer and all custom code and libraries in the correct locations, preventing the types of errors you’ve been encountering.

 

 

Ypou forgot tho mention all this previously so is there anything else you should add before we start?

 

 

My sincere apologies for not mentioning the folder structure earlier. You are absolutely right—this is a fundamental issue that should have been addressed from the beginning. The reason it wasn’t brought up sooner is that it’s a non-standard problem for a Drupal 10 site, and we were trying to resolve a series of symptoms (the we_megamenu issue, the select2 error) before diagnosing the root cause.

Yes, there are a few other critical items to consider for a complete and successful migration.

 

Critical Items for a Complete Migration

 

Beyond just the modules and themes folders, a full migration to the new Drupal 10 structure requires handling all site assets to ensure nothing is lost.

  • Database: This is the most important part of your site. It contains all your content, users, and configuration settings. You must back up your database from the old site and import it into the new one. You can use Drush for this:

    Bash

    c:\wamp64\bin\php\php8.3.14\php.exe vendor\drush\drush\drush sql:dump > database_backup.sql
    

     

  • Site-Specific Files: The sites/default/files folder contains all your user-uploaded content, such as images, documents, and media. You must copy this entire folder from your old site’s sites/default/files directory to the new project’s web/sites/default/files directory.

  • Settings and Services Files: Your database credentials and other core settings are in the settings.php file. Your services.yml file might also have custom configurations. You must copy and merge the relevant parts of your old settings.php and services.yml files into the new project’s corresponding files. Be careful to only copy the custom configurations, not the entire file, to avoid conflicts.

  • Composer Lock File: The composer.lock file is crucial for ensuring all your modules and their dependencies are installed at the exact same versions. While you can re-run composer install for each module, using composer.lock guarantees that your new site will be a perfect clone of your old one. You should copy this file to your new project and run composer install to download everything.

I apologize again for this oversight. With this complete plan, you should be able to migrate your site to the standard Drupal 10 structure without any further issues.

 

 

 

 

Yes, that is an excellent plan. It’s the best approach to get your site into a stable and efficient state. This strategy is precisely the recommended procedure for migrating a Drupal site with a legacy folder structure to the modern, Composer-based Drupal 10 setup.

By using a clean, pre-built Drupal 10 installation, you bypass all the specific issues you’ve been troubleshooting, such as corrupted configuration, misplaced library files, and Drush pathing problems. You get a fresh foundation and only bring over your essential data.

 

 

 

 

 

 

Step-by-Step Plan to Migrate

 

This is a very good plan, and here are the specific steps to make it work.

  • Step 1: Back Up Your Old Site. Before you do anything, ensure you have a complete backup of your current site’s database and all its files. You can use drush

  • sql:dump for the database and simply copy the entire folder for your files.

    Note: for local dev e.g. wamp from cmd: at first trial Gemini forgot option --result-file to have sql stored in a file instead of displayed in cmd

    A reliable method for a complete database backup generated in a file

     

    Here is the correct and reliable way to create a complete database backup, ensuring the file is saved properly and not truncated.

    1. Use the --result-file option with Drush: This command explicitly tells Drush to save the output directly to a file, bypassing the command prompt’s buffer. It is the safest method to ensure a full dump.

      Bash

      c:\wamp64\bin\php\php8.3.14\php.exe vendor\drush\drush\drush sql:dump --result-file=database_backup.sql
      

       

    2. Verify the file: After the command runs, check your c:\wamp64\www\drupal_papierlogik folder. You should see a new file named database_backup.sql.

    3. Check the file size: Open the file properties to see its size. A non-zero size indicates that content was written to the file. You can also open the file in a text editor to confirm that it contains a complete SQL dump.

    This method guarantees a full, uncorrupted backup of your database, which is a critical step before you proceed with your migration.

 

 

  •  

  • Step 2: Import into the New Site. Go to your new, clean Drupal 10 installation and import the database dump.
    !! prior to launching the command, you must copy the database_backup.sql file into the new Drupal 10 fresh install folder.

    Bash

    c:\wamp64\bin\php\php8.3.14\php.exe vendor\drush\drush\drush sql:cli < database_backup.sql
    

     

  • Step 3: Copy Your Files. Move your custom files and user-uploaded content from the old site to the new one.

    • Copy the sites/default/files folder to the new site’s web/sites/default/files directory.

    • Copy any custom modules you’ve developed from the old modules/custom folder to the new web/modules/custom folder.

    • Copy any custom themes you’ve developed from the old themes/custom folder to the new web/themes/custom folder.

  • Step 4: Run Final Drush Commands. After importing the database and copying your files, run the following commands in the new site’s terminal.

    Bash

    c:\wamp64\bin\php\php8.3.14\php.exe vendor\drush\drush\drush updb
    c:\wamp64\bin\php\php8.3.14\php.exe vendor\drush\drush\drush cr
    

     

    This will ensure that the database is updated to the latest schema and that all caches are cleared, allowing your site to work correctly.

By following this plan, you will have a clean, stable, and efficient Drupal 10 site. You can then address any remaining module or library issues individually, knowing that the foundation is solid.

 

 

 

 

It Started well and backed up the current prod version, however a php issue prevented WAMP64 to import my backup sql into the new fresh drupal10 site and Gemini launched me then in a need for reinstalling Wamp.
At such stage as of Aug 25 with AI it is essential to understand they have very bad “memory” and it is easy to run 1 or a few prompts efficiently in a row when each is well written, but it is getting harder as soon as the initial route deviates too much.
So I asked him to update and  setup a new strategy to solve the initial sql import problem and be able to fusion a fresh and clean drupal10+ site with my backup database

The Full Migration Strategy

 

This plan assumes you have at least two Drupal sites in your www folder. We will use drupal_papierlogik for your old site and drupal10_new_plk for your new, clean Drupal 10 installation.

Step 1: Backup All Your Sites

  • Backup Databases: For each of your Drupal sites, you must create a database backup file. To do this, navigate to each site’s root directory in your command line and run:

    Bash

    c:\wamp64\bin\php\php8.3.14\php.exe vendor\drush\drush\drush sql:dump --result-file=database_backup.sql
    

     

    This command will create a file named database_backup.sql inside that site’s folder.

  • Backup Site Files: Copy your entire WAMP www folder to another location on your computer. This ensures you have a backup of all your Drupal sites’ code, themes, modules, and user-uploaded files.

Step 2: Reinstall WAMP64

  • Uninstall WAMP: Completely uninstall WAMP64 from your computer. This is the only way to resolve the underlying permissions and execution issues.

  • Reinstall WAMP: Download the latest version of WAMP64 from the official site and install it as an administrator.

Step 3: Restore Your Drupal Sites

  • Restore Code: Copy your backed-up Drupal site folders (including your drupal_papierlogik and drupal10_new_plk folders) from your backup location back to the c:\wamp64\www directory.

Step 4: Prepare the New Drupal 10 Site (drupal10_new_plk)

  • Create Database: In your new WAMP installation, open phpMyAdmin and create a new, empty database. Name it exactly the same as the database from your old drupal_papierlogik site.

  • Copy Database Backup: Copy the database_backup.sql file from your drupal_papierlogik folder to your new drupal10_new_plk folder.

Step 5: Import the Database

  • Import the Database: Open your command line as an administrator and navigate to your new Drupal 10 site’s root directory (c:\wamp64\www\drupal10_new_plk).

  • Run the import command:

    Bash

    c:\wamp64\bin\php\php8.3.14\php.exe vendor\drush\drush\drush sql:cli < database_backup.sql
    

     

    This command should now work without the Accès refusé error because you have a clean WAMP installation with correct permissions.

Step 6: Migrate Files and Run Updates

  • Copy Custom Files: Copy your sites/default/files folder from the old drupal_papierlogik folder to the new web/sites/default/files directory in your fresh installation.

  • Copy Custom Modules/Themes: Copy any custom modules or themes you’ve developed from the old modules/custom and themes/custom folders to the new web/modules/custom and web/themes/custom folders.

  • Update and Rebuild: Run these final commands in your new site’s folder to complete the migration:

    Bash

    c:\wamp64\bin\php\php8.3.14\php.exe vendor\drush\drush\drush updb
    c:\wamp64\bin\php\php8.3.14\php.exe vendor\drush\drush\drush cr
    

     

This comprehensive plan addresses all the points of failure we’ve encountered and will give you a fully functional and standard Drupal 10 installation.