Migration tests fail with fixture created from DbDumpCommand on PostgreSQL and SQLite

Created on 28 September 2021, about 3 years ago
Updated 11 March 2023, almost 2 years ago

Problem/Motivation

All migration tests using the Drupal 7 database fixture are are failing on PostgreSQL and SQLite. This was discovered in #3199578-19: Fix EntityReferenceTranslationDeriver process pipeline when I used the script to generate the dump file.

It fails because of the extra lines added to the database dump file in The db dump command was changed in #838992: Change the uid field from integer to serial by leveraging NO_AUTO_VALUE_ON_ZERO on MySQL Introduced changes to the \Drupal\Core\Command\DbDumpCommand which adds code to the exported database file.

Here are the lines, removing these and the tests pass with PostgreSQL and SQLite.

// Ensure any tables with a serial column with a value of 0 are created as
// expected.
$sql_mode = $connection->query("SELECT @@sql_mode;")->fetchField();
$connection->query("SET sql_mode = '$sql_mode,NO_AUTO_VALUE_ON_ZERO'");

and

// Reset the SQL mode.
$connection->query("SET sql_mode = '$sql_mode'");

Steps to reproduce

Generate a new dump

php core/scripts/db-tools.php export --database=legacy > core/modules/migrate_drupal/tests/
fixtures/drupal7.php 

Then, using PostgreSQL or SQLlite for testing, run any migration test that needs to install the database fixture. One such test would be Drupal\Tests\system\Kernel\Migrate\d7\MigrateSystemConfigurationTest.

Proposed resolution

Remaining tasks

Write a patch
review
commit

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Closed: duplicate

Version

10.1

Component
Database 

Last updated 2 days ago

  • Maintained by
  • 🇳🇱Netherlands @daffie
Created by

🇳🇿New Zealand quietone

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024