Description:
After creating a new table with this:
create table core_mony
(
sys_key int unsigned not null,
mony_key int unsigned not null,
mony_type char(1) not null,
primary key(mony_key, sys_key),
constraint
foreign key(sys_key)
references system_sys(sys_key),
constraint
foreign key(mony_key, mony_type)
references system_mony(mony_key, mony_type)
);
And refreshing the schemas it only shows core_mony_ibfk_1 in foreign keys of core_mony. The second foreign key (core_mony_ibfk_2) does not show up.
show create table core_mony shows this:
CREATE TABLE `core_mony` (
`sys_key` int(10) unsigned NOT NULL,
`mony_key` int(10) unsigned NOT NULL,
`mony_type` char(1) NOT NULL,
PRIMARY KEY (`mony_key`,`sys_key`),
KEY `sys_key` (`sys_key`),
KEY `mony_key` (`mony_key`,`mony_type`),
CONSTRAINT `core_mony_ibfk_1` FOREIGN KEY (`sys_key`) REFERENCES `system_sys` (`sys_key`),
CONSTRAINT `core_mony_ibfk_2` FOREIGN KEY (`mony_key`, `mony_type`) REFERENCES `system_mony` (`mony_key`, `mony_type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
How to repeat:
drop database test;
create database test;
use test;
create table system_sys
(
sys_key int unsigned not null auto_increment,
sys_code char(3) not null,
sys_desc char(40) not null,
sys_type char(1) not null,
sys_rcpt_no int not null,
primary key(sys_key),
unique index(sys_code),
unique index(sys_desc)
);
create table system_mony
(
mony_key int unsigned not null auto_increment,
mony_type char(1) not null,entry,
mony_code char(3) not null,
mony_desc char(40) not null,
primary key(mony_key),
unique index(mony_key, mony_type),
unique index(mony_code),
unique index(mony_desc)
);
create table core_mony
(
sys_key int unsigned not null,
mony_key int unsigned not null,
mony_type char(1) not null,
primary key(mony_key, sys_key),
constraint
foreign key(sys_key)
references system_sys(sys_key),
constraint
foreign key(mony_key, mony_type)
references system_mony(mony_key, mony_type)
);
Suggested fix:
Make the foreign key show up in schemas.