Problem/Motivation

Migration IDs are more limited than other configuration IDs, because they are used in map table names with a prefix, and in queries with a table.

My migration crashed like this:

Migration failed with source plugin exception: SQLSTATE[42000]: Syntax[error]
error or access violation: 1059 Identifier name
'my-d8-drupal-db.migrate_map_my_migration_id'

because the combination of { my D8 database name } + 'migrate_map_' + { my migration's ID } was more that 64 characters.

It would be nice if Migrate checked for this and refused to install migrations that will cause this problem.

Proposed resolution

Add a hash of the migration_id at the end of the name and truncated it to be < 64 characters. This approach is from Wim Leers in #15.

Document somewhere that the table name is of the form

  • { my D8 database name } + 'migrate_map_' + { my migration's ID } + {__bundle_name}+ {hash of migration_id}
  • { my D8 database name } + 'migrate_message_' + { my migration's ID } + {__bundle_name}+ {hash of migration_id}

Remaining tasks

See #65 and #47 decide what to do in this situation
Test
Review
Commit

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Release notes snippet

The migrate module creates database tables migrate_map_[migration_name] and migrate_message_[migration_name]. Previously, if [migration_name] was too long, it was truncated. Now, it is truncated and a hash is added.

Existing database tables will be renamed by an update function.

If you have ongoing migrations with long names, and you have custom code that hard-codes the database tables, then you will need to update that code.

Issue fork drupal-2845340

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

joachim created an issue. See original summary.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

quietone’s picture

Status: Active » Needs review
StatusFileSize
new2.07 KB

I guess we could throw an exception.

Status: Needs review » Needs work

The last submitted patch, 7: 2845340-2.patch, failed testing. View results

joachim’s picture

Thanks for the patch!

+++ b/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php
@@ -170,8 +170,15 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition
+      throw new MigrateException(sprintf("Migrate map table name greater than 64 characters."));

This should maybe also state the problem in terms that the developer can actually fix -- we should say that the migration ID can only be (64 - SOMETHING) long. With the current message, the developer encountering this would have to find the code that threw the exception, and read back a few lines to find where the table name is constructed. Let's save them that work :)

quietone’s picture

Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new2.17 KB

Yes, more information is needed I was mostly curious to know what tests which fail, which I should have mentioned. There are two challenges here, 1) decide on the message and 2) changing the ids on existing migrations needs to have this fixed first, #3039240: Create a way to declare a plugin as deprecated.
For the first, since we have to explain about bundles and extra characters such as '__', I wonder if the best thing is to point to a doc page with examples. For the later this, needs to be postponed.

And for fun I made a patch anyway, this time including the migration_id.

Status: Needs review » Needs work

The last submitted patch, 10: 2845340-10.patch, failed testing. View results

quietone’s picture

Issue summary: View changes
Status: Needs work » Postponed

I'm thinking this needs to check for length as well as duplicate tables names. For example, when bundle names are added to they table name, they are the uniquely defining part of the string but they are at the end of the string.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

wim leers’s picture

Priority: Normal » Major
Status: Postponed » Needs review
StatusFileSize
new1.19 KB

or length as well as duplicate tables names

Indeed!

For example, when bundle names are added to they table name, they are the uniquely defining part of the string but they are at the end of the string.

Exactly — if we don't guarantee uniqueness, then we risk wrongly counting things. For example, multiple derived migration plugin definitions can have their source plugins returning a lower count than what the ID Map plugin will return, because all of the derived migration plugin definitions end up reading the same mapping table… 😨🤯

(Ask me how I know.)

wim leers’s picture

Title: migrate should warn if a migration ID is too long » migrate
StatusFileSize
new1.19 KB

Interesting, I didn't realize *.PATCH would disable testing!

wim leers’s picture

Title: migrate » migrate mapping & messages table names are truncated, can lead to incorrect mapping lookups

Status: Needs review » Needs work

The last submitted patch, 16: 2845340-16.patch, failed testing. View results

wim leers’s picture

Status: Needs work » Needs review
StatusFileSize
new7.97 KB
new9.11 KB

Updated test expectations.

quietone’s picture

Glad to see progress here. I don't recall anything that would cause the map table name to vary between 9.0 and 9.1. And I just tested locally on 9.0 and MigrateLookupTest::testInvalidIdLookup passed. Retesting because, well, why not?

Not retesting. I see the failure is with SqlLite.

wim leers’s picture

Queued a 9.0.x test with MariaDB. #20 sounds like SQLite is known to not pass migration tests?

quietone’s picture

Sorry, no I meant I wasn't testing with SqlLite.

mikelutz’s picture

Status: Needs review » Needs work
+++ b/core/modules/migrate/tests/src/Kernel/MigrateLookupTest.php
@@ -72,7 +72,7 @@ public function testSingleLookup() {
-    $this->expectExceptionMessage("Extra unknown items for map migrate_map_sample_lookup_migration in source IDs: array (\n  'invalid_id' => 25,\n)");
+    $this->expectExceptionMessage("Extra unknown items for map migrate_map_sample_lookup_migra11fefc51977839762138 in source IDs: array (\n  'invalid_id' => 25,\n)");

This assumes a table prefix of 12 characters. By default on testbot, mysql and postgre, prefixes are 'test12345678' (well random 8 numbers), but on sqllite they add a period 'test12345678.' making them 13 characters, and dropping the last 'a' in migrate_map_sample_lookup_migra11fefc51977839762138.

I'm not certain that the test should rely on any specific prefix length, I think that is technically configurable within phpunit settings.

benjifisher’s picture

Issue tags: +Bug Smash Initiative

This issue is a Major bug, and from the comments it looks as though it is pretty close to being resolved. If I understand correctly, we just need to update the tests so that they do not rely on a specific prefix length, and then they should pass for SQLite.

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new1.15 KB
new9.06 KB

This modifies the test to handle the different prefix length used by SQLite.

mikelutz’s picture

Status: Needs review » Needs work
+++ b/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php
@@ -171,9 +171,9 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition
     $prefix_length = strlen($this->database->tablePrefix());
     $this->mapTableName = 'migrate_map_' . mb_strtolower($machine_name);
-    $this->mapTableName = mb_substr($this->mapTableName, 0, 63 - $prefix_length);
+    $this->mapTableName = mb_substr($this->mapTableName, 0, 43 - $prefix_length) . substr(md5($machine_name), 0, 20);
     $this->messageTableName = 'migrate_message_' . mb_strtolower($machine_name);
-    $this->messageTableName = mb_substr($this->messageTableName, 0, 63 - $prefix_length);
+    $this->messageTableName = mb_substr($this->messageTableName, 0, 43 - $prefix_length) . substr(md5($machine_name), 0, 20);

+++ b/core/modules/migrate/tests/src/Kernel/MigrateLookupTest.php
@@ -72,8 +72,13 @@ public function testSingleLookup() {
+    $table_name = 'migrate_map_sample_lookup_migra11fefc51977839762138';
+    // The table prefix length used by SQLite is one character longer so adjust
+    // the table name.
+    if (\Drupal::database()->driver() === 'sqlite') {
+      $table_name = 'migrate_map_sample_lookup_migr11fefc51977839762138';
+    }
+    $this->expectExceptionMessage("Extra unknown items for map $table_name in source IDs: array (\n  'invalid_id' => 25,\n)");

I think we need to do more. It's a balancing act, and I hate to have the test just redo the string concatation in the method, as it kills some of what we are testing for, but the test can't assume the prefix length based on the assumed prefix that testbot uses. In this case, we do need to retrieve the prefix length from \Drupal::database->tablePrefix() in the test and calculate what the table name should be, I think.

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new1.36 KB
new9.06 KB

I can't decided which method I prefer. In this patch the test re-calculates the table name.

mikelutz’s picture

Status: Needs review » Reviewed & tested by the community

I like this better.

huzooka’s picture

Fyi I just released a contrib ID map plugin that copies this solution with some small difference:

  1. That plugin adds the hash only when the table names would be truncated. (And i think that this behaviour provides better DX.)
  2. There are three tests: one for a short plugin ID, one for a longer one, and one for a very long one with a DERIVATE_SEPARATOR

The code is here: Smart SQL ID Map.

catch’s picture

Status: Reviewed & tested by the community » Needs work

The postgres failure in #27 looks real.

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new1008 bytes
new9.06 KB

The test didn't account for the new table name, which is not specific to Postgres, The test was committed in #3098282: [backport] SQL error if migration has too many ID fields on Sep 27. The mysql test was run on 18 Sep, sqlite on 19 Sep whereas postgres was run on 30 sep, after the new test was added.

This gets the correct table name for the test.

Status: Needs review » Needs work

The last submitted patch, 31: 2845340-27.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new757 bytes
new9.95 KB

Silly me, I uploaded the old patch not the new one. This should be better.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

mikelutz’s picture

Status: Needs review » Reviewed & tested by the community

Looks like this fixes Postgres, back to RTBC, thanks @catch for the um... catch.

quietone’s picture

StatusFileSize
new9.95 KB

Uploading the patch from #33 so that testing is against 9.2.x

quietone’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Needs review

The original IS includes adding documentation explaining the format of the table names. That documentation doesn't already exist, that I can find, so maybe add it to the property description in Sql.php?

The IS has this postponed on #3039240: Create a way to declare a plugin as deprecated which I think still stands because, for example, changing the table names will cause existing migration lookups to fail.

Setting to NR for the above.

quietone’s picture

Issue summary: View changes
Status: Needs review » Needs work

I've changed my mind, this doesn't need to be postponed on #3039240: Create a way to declare a plugin as deprecated. What is needs is a way to handle the changing of migrate tables in a BC friendly way. Setting NW for that piece of work and updated the IS.

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new10.95 KB
new24.74 KB

Here is a first attempt at the update hook and test.

This will update the table names for all discovered migrations and it assumes that if there is map table there is a message table.

Status: Needs review » Needs work

The last submitted patch, 39: 2845340-39.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new10.21 KB
new22.51 KB

Ignore that patch.

This is the same idea, it will update migrate table names for discovered migrations.

daffie’s picture

Related issues: +#571548: Identifiers longer than 63 characters are truncated, causing Views to break on Postgres

They have the same problem in the views module.

wim leers’s picture

+++ b/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php
@@ -171,9 +171,9 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition
-    $this->mapTableName = mb_substr($this->mapTableName, 0, 63 - $prefix_length);
+    $this->mapTableName = mb_substr($this->mapTableName, 0, 43 - $prefix_length) . substr(md5($machine_name), 0, 20);
     $this->messageTableName = 'migrate_message_' . mb_strtolower($machine_name);
-    $this->messageTableName = mb_substr($this->messageTableName, 0, 63 - $prefix_length);
+    $this->messageTableName = mb_substr($this->messageTableName, 0, 43 - $prefix_length) . substr(md5($machine_name), 0, 20);

I was just chatting with @huzooka about this issue and the https://www.drupal.org/project/smart_sql_idmap contrib module he released to allow e.g. the https://www.drupal.org/project/media_migration to work today (i.e. without this issue having been solved).

He pointed out that it'd be far better for the Developer Experience if we'd:

  1. put an underscore before the MD5 hash
  2. not add an MD5 hash if the table name is short

WDYT, @quietone & @mikelutz?

EDIT: LOL I just realized that @huzooka already wrote exactly this at #29 😂🙈

quietone’s picture

StatusFileSize
new18.96 KB
new15.98 KB

@Wim Leers, thanks, I had forgotten about #29.

Yes, I think it is a good idea. It would be much better for the developer if the table names matched the migration id. This patch will only change the table name if the table name was truncated. That means less changes to tests, which is a good thing. I've add testing MigrateSqlIdMapTest and reworked the entire Update test as well.

I am not sure how useful the interdiff will be because it is bigger than the patch now.

huzooka’s picture

@quietone, and you also add an underscore before the hash :)

Thanks!!!

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

danflanagan8’s picture

Status: Needs review » Needs work

I had problems running the update.

Here's what I did before the update. I ran a couple migrations with very long names that would get truncated to the same table names. The migration ids were:

  • horizontal_horizontal_horizontal_horizontal_horizontal_posts
  • horizontal_horizontal_horizontal_horizontal_horizontal_images

These both end up pointing at the same migrate tables:

  • migrate_map_horizontal_horizontal_horizontal_horizontal_horizon
  • migrate_message_horizontal_horizontal_horizontal_horizontal_hor

It turns out in my case the shared table doesn't cause any problems because posts and images never have the same id.

When I run migrate:status, the status is indeed confused because of the shared tables.

 ------------------- --------------------- -------- ------- ---------- 
  Group               Migration ID          Status   Total   Imported   Unprocessed    
 ------------------- --------------------- -------- ------- ---------- 
Default (default)   horizontal_horizont   Idle     1116    1491       -381        
                      al_horizontal_horiz                                                                  
                      ontal_horizontal_im                                                                  
                      ages                                                                                 
  
Default (default)   horizontal_horizont   Idle     381     1491       -1116       
                      al_horizontal_horiz                                                                  
                      ontal_horizontal_po                                                                  
                      sts  

Then I applied the patch in #44 and ran updb. I received the following output:

>  [notice] Update started: migrate_update_9201
>  [error]  Cannot rename 'migrate_map_horizontal_horizontal_horizontal_horizontal_horizon' to 'migrate_map_horizontal_horizontal_horizontal__6bea8c6829a77901b': table 'migrate_map_horizontal_horizontal_horizontal_horizontal_horizon' doesn't exist. 
>  [error]  Update failed: migrate_update_9201 
 [error]  Update aborted by: migrate_update_9201 
 [error]  Finished performing updates. 

The shared migrate map table got updated to migrate_map_horizontal_horizontal_horizontal__fbe14d486cb1d9888. But then the update hook tried to update the table name a second time for the second migration that used that (shared) table. By that point migrate_map_horizontal_horizontal_horizontal_horizontal_horizon had a different name.

This situation with shared table names (described somewhat in #15) is ugly, but I don't think the update should fail. I think the best thing may be to duplicate the shared table in this situation. Otherwise we guarantee data loss. The migrate:status output would still be confusing, but I don't think there's any way we can unscramble that egg.

wim leers’s picture

Nice find! 😱

Also: that is the most absurd migration ID (or plug-in ID) I’ve ever seen 🤣👏

quietone’s picture

@danflanagan8, thanks for the thorough testing!

Part of me wonders if it is necessary to handle the case discovered by the testing in #47. While it certainly can happen, I think the developer would discover the problem of a map and/or message table being used by two or more migrations. It seems to me that just looking at the data in a 'shared' map table a developer would see that source / destination pairing were a jumble. Or course, that may be harder to see if the source/destination are both just an ID.

If this does need to be done then a single table needs to be copied to more than one new tables. I do not see any 'copy' method in the Database API. So, would this need a unique solution for each database type?

Also, a question. This patch gets a list of current map tables by finding tables with a name like 'migrate_map%'. Or should this get the map tables names from each migration ($migration->getIdMap()->mapTableName) and thus cover custom id_map plugins?

danflanagan8’s picture

@quietone, it's certainly a reasonable question as to how far we should go to handle the case in #47 and #15. I was thinking at the very least, we should make sure the update doesn't fail by doing a check with tableExists():

if ($legacy_table_names[0] != $id_map->mapTableName()) {
  if ($this->database->schema()->tableExists($legacy_table_names[0])) {
    $this->database->schema()
        ->renameTable($legacy_table_names[0], $id_map->mapTableName());
  }
  else {
    // Print some message saying maybe data loss has occurred due to truncated table names and point to a helpful url?
  } 
}

Would that be good enough?

danflanagan8’s picture

I do not see any 'copy' method in the Database API. So, would this need a unique solution for each database type?

It looks like the API used to have a copy function, but it was removed mostly due to it not supporting PostrgeSQL: #2061879: Remove Schema::copyTable

Multiple times in that issue there are comments like "this could be added back." (5, 11) It's pretty far out of my wheelhouse to try to manage something like that though.

karishmaamin’s picture

StatusFileSize
new15.87 KB

Re-rolled patch for 9.3.x

suresh prabhu parkala’s picture

StatusFileSize
new16.07 KB
new1.21 KB

Tried to fix custom failures of patch #52.

yogeshmpawar’s picture

Status: Needs work » Needs review

Triggering bots to check the custom commands failures.

quietone’s picture

@yogeshmpawar, to check the custom command failure just run commit-code-check locally. Have a look at the instructions for running the coding standard checks locally. It also has the advantage of saving resources, including money, for the Drupal association. There are real costs for running the tests.

@karishmaamin, I do not understand why you made a reroll the patch, it still applies to 9.3.x and the issue is not tagged for a reroll. If you read the latest comments there is a question asked in #49 which needs to be resolved before work continues.

quietone’s picture

Status: Needs review » Needs work

Settings to NW for #47

yogeshmpawar’s picture

Thanks @quietone - for the information. seems like link posted in your comment gives me 404. I will check this custom command failures on local first onwords.
I got the correct link - https://www.drupal.org/docs/develop/development-tools/running-core-devel...

danflanagan8’s picture

I was thinking about this one again and thought I throw out an idea. The blocker here is that copying a db table is ridiculously painful. I wonder if there's a way we could handle this where we avoid needing an update hook. What I mean is this:

Could we somehow continue supporting the legacy table names for existing migration maps, but use the new naming scheme for new migration maps?

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

joachim’s picture

+++ b/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php
@@ -171,9 +171,17 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition
+    $this->mapTableName = mb_substr($map_table_name, 0, 63 - $prefix_length) === $map_table_name

This really needs comments to explain what is being done and why.

Why do we use 18 characters from the md5?

> Could we somehow continue supporting the legacy table names for existing migration maps, but use the new naming scheme for new migration maps?

In general, I think that the one-off pain of an update is far better than the ongoing pain of supporting 2 systems in parallel.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

wim leers’s picture

StatusFileSize
new1.35 KB

In general, I think that the one-off pain of an update is far better than the ongoing pain of supporting 2 systems in parallel.

Hear hear.

#2919158: Add the MigrationPluginManager to Drupal\migrate\Plugin\migrate\id_map\Sql broke this patch.

2.5 years later, we're still using #16, so rebasing that, since it's less likely to fail to apply, unlike #53.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Status: Needs work » Needs review
Issue tags: +Needs architectural review, +no-needs-review-bot

I was thinking about #47, where two migrations are sharing a map table name. While it is rare, it is possible. If a site is in such a situation then changing the tables names could break their migrations. In fact, it would if they are using migration_lookup. A migration using a 'shared' table would start using a new table and thus not have access to the older data. If this was detected we could copy the data to the two new tables and everything should be fine.

But, maybe a simpler way is to not modify the table names when it is detected that 'shared' tables are in use. When 'shared' tables are detected a flag could be set, in key/value, to indicate that the older method for computing table name should be used. And if that flag is not set then the new method is used.

Setting to NR for comment on this idea.

mikelutz’s picture

Status: Needs review » Needs work

BAck to NW since there is still work to do and no comments for a month

quietone’s picture

Issue summary: View changes
Status: Needs work » Needs review

@mikelutz, before work continues I think we should have direction on how to handle #47. I proposed an idea in #65.

duaelfr’s picture

@quietone on #65:
I think I'd like to have two copies of the same table more than having to maintain that legacy way of handling migrate tables.
If we decided to follow the flag way, one day we would certainly like to deprecate that and prepare a new upgrade path that would be the same as the one we would code today, isn't it?

duaelfr’s picture

Rerolled #53 on HEAD in a MR.
Fixed phpcs and phpstan issues.
Updated the upgrade path to clone tables instead of renaming them. (I wish I could use a Merge query for this but... #3486134: Merge queries should allow setting the conditionTable)

catch’s picture

In other situations like this (cache IDs in the database backend, maybe field/bundle names), we hash the end of the ID if the entire thing is too long. It's not great for readability but it doesn't require an update path.

duaelfr’s picture

@catch #71: This is exactly what this issue is about. The original issue was caused by the fact the tables names were only truncated. Now we hash the end but we still have to handle the existing values, hence the upgrade path.

benjifisher’s picture

Issue summary: View changes
Issue tags: +Needs change record

I am worried about how disruptive this change could be. Since both @catch and @daffie have commented on this issue, and neither seems concerned about that, I guess it is OK. But I am adding the tag for a change record (NW for that) and I am adding a release-notes snippet to the issue summary.

benjifisher’s picture

Status: Needs review » Needs work
duaelfr’s picture

Status: Needs work » Needs review
StatusFileSize
new49.77 KB

Rerolled MR.
Patch attached for composer.

oily’s picture

Issue summary: View changes

Edited view summary, completed most of the empty fields.

mondrake’s picture

smustgrave’s picture

Status: Needs review » Needs work

Appears current MR has test failures and merge conflicts.

prudloff made their first commit to this issue’s fork.

quietone’s picture

Status: Needs work » Needs review

I went to just fixed the test but then did more.

  • The tables for a migration are treated as a pair, that is, if the message table name needs to be hashed then both are.
  • If more that one migration shares the same table name(s), then the new name is hashed and the data copied to all the new tables.
  • If only one migration has a map/message pair that needs to be hashed, then the tables are renamed.
  • If the table names do not need to be hashed, the table names are left as is.
  • Tests improved by adding tables to cover the case when more than one migrate shares that same table name.
  • The test tables have data to ensure the copy works.

This should mean that it is only in the case of more than one migration having the same tables names that tables will be copied. I think I left it copying all the duplicates instead of doing a rename for one migration and copying for the others.

smustgrave’s picture

With migrate_drupal being deprecated that impact the solution?

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

duaelfr’s picture

StatusFileSize
new36.21 KB

MR rerolled on main
Patch attached for composer

smustgrave’s picture

This one has multiple migrate maintainers wonder if it still needs architectural review?

smustgrave’s picture

Status: Needs review » Needs work

Unfortunately this one does need a rebase now.