Error importing database from MariaDB 10.3.34 to 10.5.15 - Foreign key constraint #1312

Closed
opened 2026-02-05 00:35:57 +03:00 by OVERLORD · 0 comments
Owner

Originally created by @jbuggie on GitHub (Jul 6, 2022).

I have a simple script to back up the production db to a standby db via mysql-dump and import. Recently, one of the back up servers has been upgraded to a new MariaDB version 10.5.15 and it gives the following error trying to import the database:

ERROR 1005 (HY000) at line 75: Can't create table bitwarden.ciphers (errno: 150 "Foreign key constraint is incorrectly formed")

Line #75 of the dump :

CREATE TABLE ciphers (
uuid char(36) NOT NULL,
created_at datetime NOT NULL,
updated_at datetime NOT NULL,
user_uuid char(36) DEFAULT NULL,
organization_uuid char(36) DEFAULT NULL,
atype int(11) NOT NULL,
name text NOT NULL,
notes text DEFAULT NULL,
fields text DEFAULT NULL,
data text NOT NULL,
password_history text DEFAULT NULL,
deleted_at datetime DEFAULT NULL,
reprompt int(11) DEFAULT NULL,
PRIMARY KEY (uuid)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

Further log info:

LATEST FOREIGN KEY ERROR

2022-07-06 15:49:12 0x7f06682ab700 Error in foreign key constraint of table bitwarden/ciphers_collections:
there is no index in referenced table which would contain
the columns as the first columns, or the data types in the
referenced table do not match the ones in table. Constraint:
,
CONSTRAINT ciphers_collections_ibfk_1 FOREIGN KEY (cipher_uuid) REFERENCES ciphers (uuid)
The index in the foreign key in table is PRIMARY
Please refer to https://mariadb.com/kb/en/library/foreign-keys/ for correct foreign key definition.

Any suggestion for resolving this? Thanks.

Originally created by @jbuggie on GitHub (Jul 6, 2022). I have a simple script to back up the production db to a standby db via mysql-dump and import. Recently, one of the back up servers has been upgraded to a new MariaDB version 10.5.15 and it gives the following error trying to import the database: ERROR 1005 (HY000) at line 75: Can't create table `bitwarden`.`ciphers` (errno: 150 "Foreign key constraint is incorrectly formed") Line #75 of the dump : CREATE TABLE `ciphers` ( `uuid` char(36) NOT NULL, `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL, `user_uuid` char(36) DEFAULT NULL, `organization_uuid` char(36) DEFAULT NULL, `atype` int(11) NOT NULL, `name` text NOT NULL, `notes` text DEFAULT NULL, `fields` text DEFAULT NULL, `data` text NOT NULL, `password_history` text DEFAULT NULL, `deleted_at` datetime DEFAULT NULL, `reprompt` int(11) DEFAULT NULL, PRIMARY KEY (`uuid`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; Further log info: ============= LATEST FOREIGN KEY ERROR ------------------------ 2022-07-06 15:49:12 0x7f06682ab700 Error in foreign key constraint of table bitwarden/ciphers_collections: there is no index in referenced table which would contain the columns as the first columns, or the data types in the referenced table do not match the ones in table. Constraint: , CONSTRAINT `ciphers_collections_ibfk_1` FOREIGN KEY (`cipher_uuid`) REFERENCES `ciphers` (`uuid`) The index in the foreign key in table is PRIMARY Please refer to https://mariadb.com/kb/en/library/foreign-keys/ for correct foreign key definition. Any suggestion for resolving this? Thanks.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/vaultwarden#1312