Problem/Motivation
It is currently not possible to import a complete database dump created with the db-tools.php script if the dump in question contains the schema definition for the cache_container table. This is because the cache_container table is automatically created during the normal bootstrap process, and therefore already exists by the time the import command tries to actually import the dump. Therefore, a SchemaObjectExistsException is thrown and db-tools.php dies, assuming that Drupal is already installed.
Steps to reproduce:
- Get you a Drupal, and install it; any profile or database type will do the trick.
- Run
php core/scripts/db-tools.php dump-database-d8-mysql > dump.php - Empty the database by whatever means you prefer.
drush sql:dropworks well. - Try to import the dump:
php core/scripts/db-tools.php import dump.php
You'll get this error: "An existing Drupal installation exists at this location. Try removing all tables or changing the database prefix in your settings.php file."
Proposed resolution
There are a few ways to solve this, but the least invasive solution is for DbImportCommand to destroy the container cache bin just before the import begins. That way, there is no chance of a schema conflict, and the cache bin will either be recreated during the import, or automatically on the next request.
Remaining tasks
Write a patch with tests, review and bikeshed it a bit, then commit it.
User interface changes
None.
API changes
None.
Data model changes
None.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | interdiff-3006038-4-7.txt | 901 bytes | phenaproxima |
| #7 | 3006038-7.patch | 2.17 KB | phenaproxima |
| #4 | 3006038-4.patch | 1.13 KB | phenaproxima |
Comments
Comment #2
phenaproximaComment #3
phenaproximaComment #4
phenaproximaEnjoy you this patch I made.
Comment #5
phenaproximaAh, it turns out there is automated test coverage of db-tools.php. Let's add some of that goodness.
Comment #7
phenaproximaThis should correct the kernel test failure. However, this will still need a full end-to-end functional test, like QuickStartTest.
Comment #8
dawehnerReading up on the different implementations of
removebinthis feels not the right thing to do. Why do we not usedeleteAll()instead?Comment #9
phenaproximaBecause the problem is not that there is data in cache_container; the problem is that the table exists at all. removeBin() is the only way for calling code to remove the table.
Comment #14
quietone commented@phenaproxima, thanks for patch!
Using the steps in the IS I was not able to reproduce this on 8.9.x or 9.2.x.
Therefore, closing as cannot reproduce. If you are experiencing this problem reopen the issue, by setting the status to 'Active', and provide complete steps to reproduce the issue (starting from "Install Drupal core").
Thanks!