Skip to content

Commit

Permalink
test: add a test for FK without index
Browse files Browse the repository at this point in the history
  • Loading branch information
ozum committed May 14, 2024
1 parent ca06e57 commit 0c197a0
Show file tree
Hide file tree
Showing 3 changed files with 811 additions and 176 deletions.
4 changes: 3 additions & 1 deletion test/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ describe("Schema", () => {
"class_registry",
"contact",
"cross_schema_domain",
"game",
"message",
"mv_contact_other_schema_cart",
"Part",
Expand All @@ -64,6 +65,7 @@ describe("Schema", () => {
"price",
"product",
"product_category",
"publisher",
"student",
"type_table",
"udt_composite",
Expand All @@ -73,7 +75,7 @@ describe("Schema", () => {
];

// PostgreSQL added "udt_multirange" types.
if (parseInt(db.serverVersion, 10) >= 14) types.splice(22, 0, "udt_multirange");
if (parseInt(db.serverVersion, 10) >= 14) types.splice(24, 0, "udt_multirange");

expect(schema.typesIncludingEntities.map((t) => t.name)).toEqual(types);
});
Expand Down
37 changes: 36 additions & 1 deletion test/test-helper/ddl/main.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Created: 9/20/2019
Modified: 2/28/2021
Modified: 5/14/2024
Project: pg-structrue-test
Model: Main
Author: Özüm Eldoğan
Expand Down Expand Up @@ -500,6 +500,33 @@ ADD COLUMN field2_c NUMERIC(3);
ALTER TABLE "public"."type_table" ADD CONSTRAINT "type_table_pk" PRIMARY KEY ("id")
;

-- Table game

CREATE TABLE "game"
(
"id" Serial NOT NULL,
"publisher_id" Integer
)
WITH (
autovacuum_enabled=true)
;

ALTER TABLE "game" ADD CONSTRAINT "Key_game" PRIMARY KEY ("id")
;

-- Table publisher

CREATE TABLE "publisher"
(
"id" Serial NOT NULL
)
WITH (
autovacuum_enabled=true)
;

ALTER TABLE "publisher" ADD CONSTRAINT "Key_publisher" PRIMARY KEY ("id")
;

-- Create views section -------------------------------------------------

CREATE VIEW "v_account_primary_contact" AS
Expand Down Expand Up @@ -757,6 +784,14 @@ ALTER TABLE "Part"
ON UPDATE CASCADE
;

ALTER TABLE "game"
ADD CONSTRAINT "gamepublisher"
FOREIGN KEY ("publisher_id")
REFERENCES "publisher" ("id")
ON DELETE RESTRICT
ON UPDATE RESTRICT
;

-- Below tables are generated here, because Toad does not support PostgreSQL partitioned tables.
CREATE TABLE "partitioned_table" (
id SERIAL NOT NULL,
Expand Down
Loading

0 comments on commit 0c197a0

Please sign in to comment.