schemacrawler / SchemaCrawler

Free database schema discovery and comprehension tool
http://www.schemacrawler.com/
Other
1.58k stars 200 forks source link

Add test for foreign keys to unique indexes #1434

Closed sualeh closed 5 months ago

sualeh commented 5 months ago

Description

Add a unit test for foreign keys that reference unique keys. See https://github.com/schemaspy/schemaspy/issues/1342

CREATE TABLE communication
(
  id NUMBER(11) NOT NULL,
  communication_code VARCHAR2(3) NOT NULL,
  description VARCHAR2(100) NOT NULL
);

ALTER TABLE communication
ADD CONSTRAINT communication_uq
  UNIQUE (communication_code);

CREATE TABLE channel
(
  id NUMBER(11) NOT NULL,
  channel_code VARCHAR2(2) NOT NULL,
  description VARCHAR2(20),
  communication_code_fk VARCHAR2(3) NOT NULL
);

ALTER TABLE channel
ADD CONSTRAINT channel_fk1
  FOREIGN KEY (communication_code_fk)
  REFERENCES communication (communication_code);