Hello,
i have problems migrating my old database (3.4.3) to the current version. Im starting the keycloak container with the old database and then the migrating scripts fails with:
17:12:35,203 ERROR [org.keycloak.connections.jpa.updater.liquibase.conn.DefaultLiquibaseConnectionProvider] (ServerService Thread Pool -- 68)
Change Set META-INF/jpa-changelog-4.0.0.xml::4.0.0-KEYCLOAK-5579-fixed::mposolda@redhat.com failed.
Error: (conn=176273) Can't create table `keycloak`.`CLIENT_SCOPE_CLIENT` (errno: 150 "Foreign key constraint is incorrectly formed")
[Failed SQL: ALTER TABLE keycloak.CLIENT_SCOPE_CLIENT ADD CONSTRAINT FK_C_CLI_SCOPE_CLIENT FOREIGN KEY (CLIENT_ID) REFERENCES keycloak.CLIENT (ID)]
I can’t find the problem because the tables look good for me.
Table CLIENT_SCOPE_CLIENT:
CLIENT_ID | varchar(36) | NO | PRI | NULL | |
Table CLIENT:
ID | varchar(36) | NO | PRI | NULL | |
show create tables:
CREATE TABLE `CLIENT` (
`ID` varchar(36) COLLATE utf8_unicode_ci NOT NULL,
<cutted>
`USE_TEMPLATE_MAPPERS` bit(1) NOT NULL DEFAULT b'0',
PRIMARY KEY (`ID`),
UNIQUE KEY `UK_<cutted>` (`REALM_ID`,`CLIENT_ID`),
CONSTRAINT `FK_<cutted>` FOREIGN KEY (`REALM_ID`) REFERENCES `REALM` (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
CREATE TABLE `CLIENT_SCOPE_CLIENT` (
`CLIENT_ID` varchar(36) NOT NULL,
`SCOPE_ID` varchar(36) NOT NULL,
`DEFAULT_SCOPE` bit(1) NOT NULL DEFAULT b'0',
PRIMARY KEY (`CLIENT_ID`,`SCOPE_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
Im using following mariadb:
mariadb Ver 15.1 Distrib 10.4.11-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
Im starting from keycloak db version 3.4.3 and a few changesets succeed. The last one is:
| 4.0.0-KEYCLOAK-6228 | bburke@redhat.com | META-INF/jpa-changelog-4.0.0.xml | 2020-11-30 17:12:34 | 60 | EXECUTED | 7:c6538c29b9c9a08f9e9ea2de5c2b6375 | dropUniqueConstraint constraintName=UK_JKUWUVD56ONTGSUHOGM8UEWRT, tableName=USER_CONSENT; dropNotNullConstraint columnName=CLIENT_ID, tableName=USER_CONSENT; addColumn tableName=USER_CONSENT; addUniqueConstraint constraintName=UK_JKUWUVD56ONTGSUHO... | | NULL | 3.5.4 | NULL | NULL | 6756353405 |
Is there a possibilty to ignore this error maybe?
If someone give me a hint to find a solution i would be very thankful