Duplicate entries in user migration

Created on 16 September 2022, about 2 years ago
Updated 19 April 2023, over 1 year ago

Problem/Motivation

Migrating the users from D7 to D9 throws Integrity constraint violations:

[error]  Drupal\Core\Database\IntegrityConstraintViolationException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'UserName' for key 'user__name': INSERT INTO "users_field_data" ("uid", "langcode", "preferred_langcode", "preferred_admin_langcode", "name", "pass", "mail", "timezone", "status", "created", "changed", "access", "login", "init", "default_langcode", "drupal_id") VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9, :db_insert_placeholder_10, :db_insert_placeholder_11, :db_insert_placeholder_12, :db_insert_placeholder_13, :db_insert_placeholder_14, :db_insert_placeholder_15); Array
(
    [:db_insert_placeholder_0] => 367758
    [:db_insert_placeholder_1] => 
    [:db_insert_placeholder_2] => 
    [:db_insert_placeholder_3] => 
    [:db_insert_placeholder_4] => UserName
    [:db_insert_placeholder_5] => nope
    [:db_insert_placeholder_6] => d49b2d3bce8b711a1b50703140968e35@sanitized.invalid
    [:db_insert_placeholder_7] => Europe/Berlin
    [:db_insert_placeholder_8] => 1
    [:db_insert_placeholder_9] => 1348182251
    [:db_insert_placeholder_10] => 1348182251
    [:db_insert_placeholder_11] => 280299600
    [:db_insert_placeholder_12] => 1396454944
    [:db_insert_placeholder_13] => www.staging.devdrupal.org/user/2301392/edit
    [:db_insert_placeholder_14] => 1
    [:db_insert_placeholder_15] => 
)
 in Drupal\mysql\Driver\Database\mysql\ExceptionHandler->handleExecutionException() (line 50 of /var/www/html/web/core/modules/mysql/src/Driver/Database/mysql/ExceptionHandler.php).

Apparently D7 had a different collation on the username field than D9 has now.
Looking at the datasets in D7 the following usernames were allowed and handled as different users:
* username
* Username
* UserName
* USERNAME

Migrating those to D9 is not possible, unless we change the collation of the field users_field_data.name to allow these variations.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

๐Ÿ› Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

๐Ÿ‡ฉ๐Ÿ‡ชGermany sanduhrs ๐Ÿ‡ช๐Ÿ‡บ Heidelberg, Germany, Europe

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