Skip to content

Commit ff11100

Browse files
committed
Add test for duplicate FK constraints
1 parent 42f5f24 commit ff11100

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

persistent-postgresql/test/MigrationSpec.hs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,14 @@ migrateManually = do
128128
, " ADD CONSTRAINT unique_user_id2"
129129
, " UNIQUE(user_id);"
130130
]
131+
-- Add an extra redundant FK constraint on passwords_2.user_id, so that we
132+
-- can test that the migrator ignores it
133+
rawEx $
134+
T.concat
135+
[ "ALTER TABLE passwords_2"
136+
, " ADD CONSTRAINT duplicate_passwords_2_user_id_fkey"
137+
, " FOREIGN KEY (user_id) REFERENCES users(id);"
138+
]
131139
rawEx $
132140
T.concat
133141
[ "CREATE TABLE admin_users("
@@ -371,6 +379,13 @@ spec = describe "MigrationSpec" $ do
371379
}
372380
,
373381
[ ColumnReference
382+
{ crTableName = EntityNameDB{unEntityNameDB = "users"}
383+
, crConstraintName =
384+
ConstraintNameDB{unConstraintNameDB = "duplicate_passwords_2_user_id_fkey"}
385+
, crFieldCascade =
386+
FieldCascade{fcOnUpdate = Just NoAction, fcOnDelete = Just NoAction}
387+
}
388+
, ColumnReference
374389
{ crTableName = EntityNameDB{unEntityNameDB = "users"}
375390
, crConstraintName =
376391
ConstraintNameDB{unConstraintNameDB = "passwords_2_user_id_fkey"}

0 commit comments

Comments
 (0)