Migrating H2 to MySQL fails on Copying instances of Field

Here's my terraform snippet responsible for RDS MySQL creation:

resource "aws_db_instance" "metabase_db" {
  identifier        = "metabase-${var.environment}-application-backend-db"
  allocated_storage = var.db_allocated_storage
  instance_class    = var.db_instance_type

  engine                 = "mysql"
  engine_version         = "8.0.32"
  parameter_group_name   = aws_db_parameter_group.mysql_parameter_group.id
  db_subnet_group_name   = aws_db_subnet_group.metabase_subnet_group.id
  vpc_security_group_ids = [aws_security_group.metabase_rds_sg.id]

  db_name  = "metabase"
  username = "metabase"
  password = jsondecode(data.aws_secretsmanager_secret_version.metabase_current.secret_string)["password"]

  backup_retention_period = var.rds_backup_retention_period
  backup_window           = var.rds_backup_window
  maintenance_window      = var.rds_maintenance_window

  publicly_accessible         = false
  copy_tags_to_snapshot       = true
  deletion_protection         = false
  skip_final_snapshot         = true
  storage_encrypted           = true
  allow_major_version_upgrade = true

  apply_immediately = true

  tags = merge(var.default_tags, var.tags)
}

resource "aws_db_parameter_group" "mysql_parameter_group" {
  name   = "mysql8-parameter-group"
  family = "mysql8.0"

  parameter {
    name  = "character_set_server"
    value = "utf8mb4"
  }

  parameter {
    name  = "collation_server"
    value = "utf8mb4_unicode_ci"
  }

  # parameter {
  #   name  = "innodb_large_prefix"
  #   value = "ON"
  # }
}

I try to restore my H2 backup withe the following command:

sudo java -DMB_DB_TYPE=mysql -DMB_DB_CONNECTION_URI="jdbc:mysql://<host>:3306/metabase?user=metabase&password=<password>"  -jar metabase.jar load-from-h2 metabase.db

Here is the full stack trace of the failed migration:

2024-06-24 16:34:16,902 INFO metabase.util :: Maximum memory available to JVM: 230.1 MB
2024-06-24 16:34:23,248 INFO util.encryption :: Saved credentials encryption is DISABLED for this Metabase instance. 🔓 
 For more information, see https://metabase.com/docs/latest/operations-guide/encrypting-database-details-at-rest.html
2024-06-24 16:34:35,004 INFO driver.impl :: Registered abstract driver :sql  🚚
2024-06-24 16:34:35,026 INFO driver.impl :: Registered abstract driver :sql-jdbc (parents: [:sql]) 🚚
2024-06-24 16:34:35,042 INFO metabase.util :: Load driver :sql-jdbc took 116.2 ms
2024-06-24 16:34:35,043 INFO driver.impl :: Registered driver :h2 (parents: [:sql-jdbc]) 🚚
2024-06-24 16:34:35,526 INFO driver.impl :: Registered driver :mysql (parents: [:sql-jdbc]) 🚚
2024-06-24 16:34:35,608 INFO driver.impl :: Registered driver :postgres (parents: [:sql-jdbc]) 🚚
2024-06-24 16:34:38,927 INFO metabase.core :: 
Metabase v0.50.6 (a5fbebf) 

Copyright © 2024 Metabase, Inc. 

Metabase Enterprise Edition extensions are NOT PRESENT.
2024-06-24 16:34:39,059 INFO driver.impl :: Registered abstract driver :metabase.driver.sql-jdbc.execute.legacy-impl/use-legacy-classes-for-read-and-set  🚚
2024-06-24 16:34:39,075 INFO driver.impl :: Registered abstract driver :metabase.driver.sql.query-processor.empty-string-is-null/empty-string-is-null  🚚
2024-06-24 16:34:39,851 INFO cmd.copy :: Set up h2 source database and run migrations... 
2024-06-24 16:34:39,853 INFO db.setup :: Verifying h2 Database Connection ...
2024-06-24 16:34:40,918 INFO db.setup :: Successfully verified H2 2.1.214 (2022-06-13) application database connection. ✅
2024-06-24 16:34:40,937 INFO db.setup :: Checking if a database downgrade is required...
2024-06-24 16:34:42,674 INFO db.setup :: Running Database Migrations...
2024-06-24 16:34:42,678 INFO db.setup :: Setting up Liquibase...
2024-06-24 16:34:43,134 INFO db.liquibase :: Updating liquibase table to reflect consolidated changeset filenames
2024-06-24 16:34:43,205 INFO db.liquibase :: No migration lock found.
2024-06-24 16:34:43,211 INFO db.liquibase :: Migration lock acquired.
2024-06-24 16:34:43,394 INFO db.setup :: Liquibase is ready.
2024-06-24 16:34:43,398 INFO db.liquibase :: Checking if Database has unrun migrations...
2024-06-24 16:34:44,480 INFO db.liquibase :: No unrun migrations found.
2024-06-24 16:34:44,481 INFO db.setup :: Database Migrations Current ... ✅
2024-06-24 16:34:44,483 INFO metabase.util :: Database setup took 4.6 s
2024-06-24 16:34:44,483 INFO cmd.copy :: [OK]
2024-06-24 16:34:44,484 INFO cmd.copy :: Set up mysql target database and run migrations... 
2024-06-24 16:34:44,484 INFO db.setup :: Verifying mysql Database Connection ...
2024-06-24 16:34:44,679 INFO db.setup :: Successfully verified MySQL 8.0.32 application database connection. ✅
2024-06-24 16:34:44,691 INFO db.setup :: Checking if a database downgrade is required...
2024-06-24 16:34:45,269 INFO db.setup :: Running Database Migrations...
2024-06-24 16:34:45,270 INFO db.setup :: Setting up Liquibase...
2024-06-24 16:34:45,739 INFO db.liquibase :: Updating liquibase table to reflect consolidated changeset filenames
2024-06-24 16:34:45,760 INFO db.liquibase :: No migration lock found.
2024-06-24 16:34:45,761 INFO db.liquibase :: Migration lock acquired.
2024-06-24 16:34:45,780 INFO db.setup :: Liquibase is ready.
2024-06-24 16:34:45,780 INFO db.liquibase :: Checking if Database has unrun migrations...
2024-06-24 16:34:47,344 INFO db.liquibase :: Database has unrun migrations. Checking if migration lock is taken...
2024-06-24 16:34:47,363 INFO db.liquibase :: No migration lock found.
2024-06-24 16:34:47,364 INFO db.liquibase :: Migration lock acquired.
2024-06-24 16:34:47,908 INFO db.liquibase :: Running 380 migrations ...
2024-06-24 16:35:01,069 INFO impl.StdSchedulerFactory :: Using default implementation for ThreadExecutor
2024-06-24 16:35:01,102 INFO core.SchedulerSignalerImpl :: Initialized Scheduler Signaller of type: class org.quartz.core.SchedulerSignalerImpl
2024-06-24 16:35:01,102 INFO core.QuartzScheduler :: Quartz Scheduler v.2.3.2 created.
2024-06-24 16:35:01,103 INFO jdbcjobstore.JobStoreTX :: Using db table-based data access locking (synchronization).
2024-06-24 16:35:01,106 INFO jdbcjobstore.JobStoreTX :: JobStoreTX initialized.
2024-06-24 16:35:01,107 INFO core.QuartzScheduler :: Scheduler meta-data: Quartz Scheduler (v2.3.2) 'MetabaseScheduler' with instanceId 'ip-10-4-1-28.eu-west-1.compute.internal1719246901081'
  Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally.
  NOT STARTED.
  Currently in standby mode.
  Number of jobs executed: 0
  Using thread pool 'org.quartz.simpl.SimpleThreadPool' - with 10 threads.
  Using job-store 'org.quartz.impl.jdbcjobstore.JobStoreTX' - which supports persistence. and is clustered.

2024-06-24 16:35:01,108 INFO impl.StdSchedulerFactory :: Quartz scheduler 'MetabaseScheduler' initialized from default resource file in Quartz package: 'quartz.properties'
2024-06-24 16:35:01,108 INFO impl.StdSchedulerFactory :: Quartz scheduler version: 2.3.2
2024-06-24 16:35:01,181 INFO core.QuartzScheduler :: Scheduler MetabaseScheduler_$_ip-10-4-1-28.eu-west-1.compute.internal1719246901081 started.
2024-06-24 16:35:01,237 INFO core.QuartzScheduler :: Scheduler MetabaseScheduler_$_ip-10-4-1-28.eu-west-1.compute.internal1719246901081 shutting down.
2024-06-24 16:35:01,238 INFO core.QuartzScheduler :: Scheduler MetabaseScheduler_$_ip-10-4-1-28.eu-west-1.compute.internal1719246901081 paused.
2024-06-24 16:35:01,240 INFO core.QuartzScheduler :: Scheduler MetabaseScheduler_$_ip-10-4-1-28.eu-west-1.compute.internal1719246901081 shutdown complete.
2024-06-24 16:35:03,868 INFO db.custom-migrations :: No forward migration for DowngradeDashboardTab
2024-06-24 16:35:18,758 INFO impl.StdSchedulerFactory :: Using default implementation for ThreadExecutor
2024-06-24 16:35:18,791 INFO core.SchedulerSignalerImpl :: Initialized Scheduler Signaller of type: class org.quartz.core.SchedulerSignalerImpl
2024-06-24 16:35:18,791 INFO core.QuartzScheduler :: Quartz Scheduler v.2.3.2 created.
2024-06-24 16:35:18,792 INFO jdbcjobstore.JobStoreTX :: Using db table-based data access locking (synchronization).
2024-06-24 16:35:18,792 INFO jdbcjobstore.JobStoreTX :: JobStoreTX initialized.
2024-06-24 16:35:18,792 INFO core.QuartzScheduler :: Scheduler meta-data: Quartz Scheduler (v2.3.2) 'MetabaseScheduler' with instanceId 'ip-10-4-1-28.eu-west-1.compute.internal1719246918761'
  Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally.
  NOT STARTED.
  Currently in standby mode.
  Number of jobs executed: 0
  Using thread pool 'org.quartz.simpl.SimpleThreadPool' - with 10 threads.
  Using job-store 'org.quartz.impl.jdbcjobstore.JobStoreTX' - which supports persistence. and is clustered.

2024-06-24 16:35:18,792 INFO impl.StdSchedulerFactory :: Quartz scheduler 'MetabaseScheduler' initialized from default resource file in Quartz package: 'quartz.properties'
2024-06-24 16:35:18,792 INFO impl.StdSchedulerFactory :: Quartz scheduler version: 2.3.2
2024-06-24 16:35:18,801 INFO jdbcjobstore.JobStoreTX :: ClusterManager: detected 1 failed or restarted instances.
2024-06-24 16:35:18,802 INFO jdbcjobstore.JobStoreTX :: ClusterManager: Scanning for instance "ip-10-4-1-28.eu-west-1.compute.internal1719246901081"'s failed in-progress jobs.
2024-06-24 16:35:18,821 INFO core.QuartzScheduler :: Scheduler MetabaseScheduler_$_ip-10-4-1-28.eu-west-1.compute.internal1719246918761 started.
2024-06-24 16:35:18,851 INFO core.QuartzScheduler :: Scheduler MetabaseScheduler_$_ip-10-4-1-28.eu-west-1.compute.internal1719246918761 shutting down.
2024-06-24 16:35:18,852 INFO core.QuartzScheduler :: Scheduler MetabaseScheduler_$_ip-10-4-1-28.eu-west-1.compute.internal1719246918761 paused.
2024-06-24 16:35:18,853 INFO core.QuartzScheduler :: Scheduler MetabaseScheduler_$_ip-10-4-1-28.eu-west-1.compute.internal1719246918761 shutdown complete.
2024-06-24 16:35:24,503 INFO impl.StdSchedulerFactory :: Using default implementation for ThreadExecutor
2024-06-24 16:35:24,520 INFO core.SchedulerSignalerImpl :: Initialized Scheduler Signaller of type: class org.quartz.core.SchedulerSignalerImpl
2024-06-24 16:35:24,523 INFO core.QuartzScheduler :: Quartz Scheduler v.2.3.2 created.
2024-06-24 16:35:24,523 INFO jdbcjobstore.JobStoreTX :: Using db table-based data access locking (synchronization).
2024-06-24 16:35:24,525 INFO jdbcjobstore.JobStoreTX :: JobStoreTX initialized.
2024-06-24 16:35:24,526 INFO core.QuartzScheduler :: Scheduler meta-data: Quartz Scheduler (v2.3.2) 'MetabaseScheduler' with instanceId 'ip-10-4-1-28.eu-west-1.compute.internal1719246924512'
  Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally.
  NOT STARTED.
  Currently in standby mode.
  Number of jobs executed: 0
  Using thread pool 'org.quartz.simpl.SimpleThreadPool' - with 10 threads.
  Using job-store 'org.quartz.impl.jdbcjobstore.JobStoreTX' - which supports persistence. and is clustered.

2024-06-24 16:35:24,526 INFO impl.StdSchedulerFactory :: Quartz scheduler 'MetabaseScheduler' initialized from default resource file in Quartz package: 'quartz.properties'
2024-06-24 16:35:24,526 INFO impl.StdSchedulerFactory :: Quartz scheduler version: 2.3.2
2024-06-24 16:35:24,544 INFO core.QuartzScheduler :: Scheduler MetabaseScheduler_$_ip-10-4-1-28.eu-west-1.compute.internal1719246924512 started.
2024-06-24 16:35:24,567 INFO core.QuartzScheduler :: Scheduler MetabaseScheduler_$_ip-10-4-1-28.eu-west-1.compute.internal1719246924512 shutting down.
2024-06-24 16:35:24,567 INFO core.QuartzScheduler :: Scheduler MetabaseScheduler_$_ip-10-4-1-28.eu-west-1.compute.internal1719246924512 paused.
2024-06-24 16:35:24,569 INFO core.QuartzScheduler :: Scheduler MetabaseScheduler_$_ip-10-4-1-28.eu-west-1.compute.internal1719246924512 shutdown complete.
2024-06-24 16:35:24,582 INFO db.custom-migrations :: No forward migration for DeleteSendPulseTaskOnDowngrade
2024-06-24 16:35:24,597 INFO db.custom-migrations :: No forward migration for DeleteInitSendPulseTriggersOnDowngrade

UPDATE SUMMARY
Run:                        380
Previously run:               0
Filtered out:                 5
-------------------------------
Total change sets:          385


FILTERED CHANGE SETS SUMMARY
DBMS mismatch:                5

2024-06-24 16:35:26,568 INFO db.liquibase :: Migration complete in 38.7 s
2024-06-24 16:35:26,582 INFO db.setup :: Database Migrations Current ... ✅
2024-06-24 16:35:26,585 INFO metabase.util :: Database setup took 42.1 s
2024-06-24 16:35:26,592 INFO cmd.copy :: [OK]
2024-06-24 16:35:26,593 INFO cmd.copy :: Testing if target mysql database is already populated... 
2024-06-24 16:35:26,595 INFO cmd.copy :: [OK]
2024-06-24 16:35:26,596 INFO cmd.copy :: Clearing default entries created by Liquibase migrations... 
2024-06-24 16:35:26,598 INFO cmd.copy :: Temporarily disabling DB constraints... 
2024-06-24 16:35:26,603 INFO cmd.copy :: [OK]
2024-06-24 16:35:30,378 INFO cmd.copy :: Re-enabling DB constraints... 
2024-06-24 16:35:30,382 INFO cmd.copy :: [OK]
2024-06-24 16:35:30,383 INFO cmd.copy :: [OK]
2024-06-24 16:35:30,387 INFO cmd.copy :: Temporarily disabling DB constraints... 
2024-06-24 16:35:30,388 INFO cmd.copy :: [OK]
2024-06-24 16:35:30,449 INFO cmd.copy :: Copying instances of Database...
2024-06-24 16:35:30,481 INFO cmd.copy ::  copied 9 instances.
2024-06-24 16:35:30,484 INFO cmd.copy :: Copying instances of User...
2024-06-24 16:35:30,521 INFO cmd.copy ::  copied 23 instances.
2024-06-24 16:35:30,555 INFO cmd.copy :: Copying instances of Setting...
2024-06-24 16:35:30,657 INFO cmd.copy ::  copied 19 instances.
2024-06-24 16:35:30,692 INFO cmd.copy :: Copying instances of Table...
2024-06-24 16:35:31,233 INFO cmd.copy ::  copied 907 instances.
2024-06-24 16:35:31,702 INFO cmd.copy :: Copying instances of Field...
2024-06-24 16:35:35,509 ERROR cmd.copy :: BatchUpdateException:
 Message: (conn=13) Duplicate entry '321-6836-Totally wrong' for key 'metabase_field.idx_uniq_field_table_id_parent_id_name'
 SQLState: 23000
 Error Code: 1062

2024-06-24 16:35:35,512 INFO cmd.copy :: Re-enabling DB constraints... 
2024-06-24 16:35:35,513 INFO cmd.copy :: [OK]
clojure.lang.ExceptionInfo: Error copying instances of Field {:model "Field"}
	at metabase.cmd.copy$copy_data_BANG_$fn__99760$fn__99761.invoke(copy.clj:196)
	at metabase.cmd.copy$copy_data_BANG_$fn__99760.invoke(copy.clj:193)
	at clojure.core$partition_all$fn__8625$fn__8626.invoke(core.clj:7333)
	at clojure.java.jdbc$init_reduce_rs.invokeStatic(jdbc.clj:1205)
	at clojure.java.jdbc$init_reduce_rs.invoke(jdbc.clj:1197)
	at clojure.java.jdbc$reducible_result_set_STAR_$reify__41980.reduce(jdbc.clj:1227)
	at clojure.core$reduce.invokeStatic(core.clj:6886)
	at clojure.core$reduce.invoke(core.clj:6869)
	at clojure.java.jdbc$query_reducer$fn__41986$fn__41989.invoke(jdbc.clj:1262)
	at clojure.java.jdbc$execute_query_with_params.invokeStatic(jdbc.clj:1091)
	at clojure.java.jdbc$execute_query_with_params.invoke(jdbc.clj:1084)
	at clojure.java.jdbc$db_query_with_resultset_STAR_.invokeStatic(jdbc.clj:1106)
	at clojure.java.jdbc$db_query_with_resultset_STAR_.invoke(jdbc.clj:1093)
	at clojure.java.jdbc$reducible_query$reify__42003.reduce(jdbc.clj:1357)
	at clojure.core$transduce.invokeStatic(core.clj:6947)
	at clojure.core$transduce.invoke(core.clj:6934)
	at metabase.cmd.copy$copy_data_BANG_.invokeStatic(copy.clj:180)
	at metabase.cmd.copy$copy_data_BANG_.invoke(copy.clj:174)
	at metabase.cmd.copy$copy_BANG_$fn__99895$fn__99896$fn__99897.invoke(copy.clj:411)
	at metabase.cmd.copy$do_with_disabled_db_constraints.invokeStatic(copy.clj:275)
	at metabase.cmd.copy$do_with_disabled_db_constraints.invoke(copy.clj:271)
	at metabase.cmd.copy$copy_BANG_$fn__99895$fn__99896.invoke(copy.clj:410)
	at metabase.cmd.copy$do_with_connection_rollback_only.invokeStatic(copy.clj:217)
	at metabase.cmd.copy$do_with_connection_rollback_only.invoke(copy.clj:215)
	at metabase.cmd.copy$copy_BANG_$fn__99895.invoke(copy.clj:408)
	at clojure.java.jdbc$db_transaction_STAR_.invokeStatic(jdbc.clj:807)
	at clojure.java.jdbc$db_transaction_STAR_.invoke(jdbc.clj:776)
	at clojure.java.jdbc$db_transaction_STAR_.invokeStatic(jdbc.clj:852)
	at clojure.java.jdbc$db_transaction_STAR_.invoke(jdbc.clj:776)
	at clojure.java.jdbc$db_transaction_STAR_.invokeStatic(jdbc.clj:789)
	at clojure.java.jdbc$db_transaction_STAR_.invoke(jdbc.clj:776)
	at metabase.cmd.copy$copy_BANG_.invokeStatic(copy.clj:405)
	at metabase.cmd.copy$copy_BANG_.invoke(copy.clj:380)
	at metabase.cmd.load_from_h2$load_from_h2_BANG_.invokeStatic(load_from_h2.clj:35)
	at metabase.cmd.load_from_h2$load_from_h2_BANG_.invoke(load_from_h2.clj:25)
	at clojure.lang.Var.invoke(Var.java:384)
	at metabase.cmd$load_from_h2.invokeStatic(cmd.clj:74)
	at metabase.cmd$load_from_h2.invoke(cmd.clj:68)
	at clojure.lang.AFn.applyToHelper(AFn.java:154)
	at clojure.lang.AFn.applyTo(AFn.java:144)
	at clojure.core$apply.invokeStatic(core.clj:667)
	at clojure.core$apply.invoke(core.clj:662)
	at metabase.cmd$run_cmd$fn__106476.invoke(cmd.clj:301)
	at metabase.cmd$run_cmd.invokeStatic(cmd.clj:300)
	at metabase.cmd$run_cmd.invoke(cmd.clj:290)
	at clojure.lang.Var.invoke(Var.java:388)
	at metabase.core$run_cmd.invokeStatic(core.clj:192)
	at metabase.core$run_cmd.invoke(core.clj:190)
	at metabase.core$entrypoint.invokeStatic(core.clj:214)
	at metabase.core$entrypoint.doInvoke(core.clj:209)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.lang.Var.applyTo(Var.java:705)
	at clojure.core$apply.invokeStatic(core.clj:667)
	at clojure.core$apply.invoke(core.clj:662)
	at metabase.bootstrap$_main.invokeStatic(bootstrap.clj:31)
	at metabase.bootstrap$_main.doInvoke(bootstrap.clj:28)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at metabase.bootstrap.main(Unknown Source)
Caused by: java.sql.BatchUpdateException: (conn=13) Duplicate entry '321-6836-Totally wrong' for key 'metabase_field.idx_uniq_field_table_id_parent_id_name'
	at org.mariadb.jdbc.MariaDbStatement.executeBatchExceptionEpilogue(MariaDbStatement.java:323)
	at org.mariadb.jdbc.ClientSidePreparedStatement.executeBatch(ClientSidePreparedStatement.java:299)
	at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:2544)
	at clojure.java.jdbc$execute_batch.invokeStatic(jdbc.clj:598)
	at clojure.java.jdbc$execute_batch.invoke(jdbc.clj:591)
	at clojure.java.jdbc$db_do_execute_prepared_statement.invokeStatic(jdbc.clj:1058)
	at clojure.java.jdbc$db_do_execute_prepared_statement.invoke(jdbc.clj:1042)
	at clojure.java.jdbc$db_do_prepared.invokeStatic(jdbc.clj:1080)
	at clojure.java.jdbc$db_do_prepared.invoke(jdbc.clj:1060)
	at clojure.java.jdbc$insert_cols_BANG_.invokeStatic(jdbc.clj:1594)
	at clojure.java.jdbc$insert_cols_BANG_.invoke(jdbc.clj:1585)
	at clojure.java.jdbc$insert_multi_BANG_.invokeStatic(jdbc.clj:1653)
	at clojure.java.jdbc$insert_multi_BANG_.invoke(jdbc.clj:1619)
	at metabase.cmd.copy$insert_chunk_BANG_.invokeStatic(copy.clj:129)
	at metabase.cmd.copy$insert_chunk_BANG_.invoke(copy.clj:123)
	at metabase.cmd.copy$copy_data_BANG_$fn__99760$fn__99761.invoke(copy.clj:194)
	... 57 more
Caused by: java.sql.SQLIntegrityConstraintViolationException: (conn=13) Duplicate entry '321-6836-Totally wrong' for key 'metabase_field.idx_uniq_field_table_id_parent_id_name'
	at org.mariadb.jdbc.internal.util.exceptions.ExceptionFactory.createException(ExceptionFactory.java:70)
	at org.mariadb.jdbc.internal.util.exceptions.ExceptionFactory.create(ExceptionFactory.java:158)
	at org.mariadb.jdbc.MariaDbStatement.executeBatchExceptionEpilogue(MariaDbStatement.java:319)
	... 72 more
Caused by: org.mariadb.jdbc.internal.util.exceptions.MariaDbSqlException: Duplicate entry '321-6836-Totally wrong' for key 'metabase_field.idx_uniq_field_table_id_parent_id_name'
	at org.mariadb.jdbc.internal.util.exceptions.MariaDbSqlException.of(MariaDbSqlException.java:34)
	at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.exceptionWithQuery(AbstractQueryProtocol.java:195)
	at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.access$000(AbstractQueryProtocol.java:108)
	at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol$1.handleResultException(AbstractQueryProtocol.java:690)
	at org.mariadb.jdbc.internal.protocol.AsyncMultiRead.call(AsyncMultiRead.java:141)
	at org.mariadb.jdbc.internal.protocol.AsyncMultiRead.call(AsyncMultiRead.java:67)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.sql.SQLException: Duplicate entry '321-6836-Totally wrong' for key 'metabase_field.idx_uniq_field_table_id_parent_id_name'
	at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.readErrorPacket(AbstractQueryProtocol.java:1693)
	at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.readPacket(AbstractQueryProtocol.java:1555)
	at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.getResult(AbstractQueryProtocol.java:1518)
	at org.mariadb.jdbc.internal.protocol.AsyncMultiRead.call(AsyncMultiRead.java:132)
	... 5 more
Command failed with exception: Error copying instances of Field

Any help on resolving

2024-06-24 16:35:31,702 INFO cmd.copy :: Copying instances of Field...
2024-06-24 16:35:35,509 ERROR cmd.copy :: BatchUpdateException:
 Message: (conn=13) Duplicate entry '321-6836-Totally wrong' for key 'metabase_field.idx_uniq_field_table_id_parent_id_name'
 SQLState: 23000
 Error Code: 1062

would be appreciated

I connected to the db instance and dropped manually the unique key constraint

alter table metabase_field drop index idx_uniq_field_table_id_parent_id_name;

And the migration happened successfully. IDK, sounds like a bad approach to me

What version of Metabase? I assume you migrating to/from the same version?

Well, I don't understand what role metabase version plays here. I was restoring H2 backup to a single MySQL RDS instance. There were no production-grade metabase yet running and connecting to it

You shouldn't drop the unique like that, it's there for a reason.

Could you run this query and show us the duplicated fields?

SELECT table_id, name, parent_id
FROM metabase_field
GROUP BY table_id, name, parent_id
HAVING COUNT(*) > 1;

feel free to redact the field name

+----------+---------------------+-----------+----------+
| table_id | name                | parent_id | count(*) |
+----------+---------------------+-----------+----------+
|      321 | UnDisplayableFIelds |      NULL |        2 |
|      321 | Totally Wrong       |      6836 |        2 |
|      324 | timeframe           |      7058 |        2 |
|      375 | timeframe           |      8403 |        2 |
|      381 | UnDisplayableFields |      NULL |        2 |
+----------+---------------------+-----------+----------+

any chance you dropped that index on h2 as well?

Well, no. But can I connect to the H2 database within the docker container running metabase to run the same query? Just to double check

Ok, I read a bit about this database and I'm not a java person to quickly look into this. Data is definitely goes from this db, so I assume there's no problem with this data

+------+----------------------------+----------------------------+---------------+--------------+---------------+--------+-------------+-----------------+----------+----------+-----------+---------------+-----------------+--------------------+---------------+--------------------+---------+-------------+---------------------+-------------------+------------------+----------+-------------------+-----------------+----------------+-------------------+----------+-------------------+----------------+----------------------------+------------------+----------------------+
| id   | created_at                 | updated_at                 | name          | base_type    | semantic_type | active | description | preview_display | position | table_id | parent_id | display_name  | visibility_type | fk_target_field_id | last_analyzed | points_of_interest | caveats | fingerprint | fingerprint_version | database_type     | has_field_values | settings | database_position | custom_position | effective_type | coercion_strategy | nfc_path | database_required | json_unfolding | database_is_auto_increment | database_indexed | database_partitioned |
+------+----------------------------+----------------------------+---------------+--------------+---------------+--------+-------------+-----------------+----------+----------+-----------+---------------+-----------------+--------------------+---------------+--------------------+---------+-------------+---------------------+-------------------+------------------+----------+-------------------+-----------------+----------------+-------------------+----------+-------------------+----------------+----------------------------+------------------+----------------------+
| 6841 | 2024-03-01 11:56:11.008397 | 2024-03-01 11:56:11.008397 | Totally Wrong | type/Integer | NULL          |       | NULL        |                |       98 |      321 |      6836 | Totally Wrong | normal          |               NULL | NULL          | NULL               | NULL    | NULL        |                   0 | java.lang.Integer | NULL             | NULL     |                98 |               0 | type/Integer   | NULL              | NULL     |                   |                |                            | NULL             | NULL                 |
| 6861 | 2024-03-01 11:56:11.008397 | 2024-03-01 11:56:11.008397 | Totally wrong | type/Integer | NULL          |       | NULL        |                |      109 |      321 |      6836 | Totally Wrong | normal          |               NULL | NULL          | NULL               | NULL    | NULL        |                   0 | java.lang.Integer | NULL             | NULL     |               109 |               0 | type/Integer   | NULL              | NULL     |                   |                |                            | NULL             | NULL                 |
+------+----------------------------+----------------------------+---------------+--------------+---------------+--------+-------------+-----------------+----------+----------+-----------+---------------+-----------------+--------------------+---------------+--------------------+---------+-------------+---------------------+-------------------+------------------+----------+-------------------+-----------------+----------------+-------------------+----------+-------------------+----------------+----------------------------+------------------+----------------------+

what role position and database_position play?