Skip to content

Commit 4e479cf

Browse files
committed
Merge remote-tracking branch 'origin' into dump-db-new
2 parents ba3709b + 12c64bc commit 4e479cf

File tree

5 files changed

+8
-2
lines changed

5 files changed

+8
-2
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE badges DROP CONSTRAINT fk_badges_crate_id;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
DELETE FROM badges WHERE crate_id NOT IN (SELECT id FROM crates);
2+
ALTER TABLE badges
3+
ADD CONSTRAINT fk_badges_crate_id FOREIGN KEY (crate_id) REFERENCES crates(id) ON DELETE CASCADE;

src/schema.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ index df884e4..18e08cd 100644
5656
/// Representation of the `reserved_crate_names` table.
5757
///
5858
@@ -881,23 +901,25 @@ table! {
59-
}
6059

6160
joinable!(api_tokens -> users (user_id));
61+
joinable!(badges -> crates (crate_id));
6262
joinable!(crate_owner_invitations -> crates (crate_id));
6363
joinable!(crate_owners -> crates (crate_id));
6464
-joinable!(crate_owners -> users (created_by));

src/schema.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -961,6 +961,7 @@ table! {
961961
}
962962

963963
joinable!(api_tokens -> users (user_id));
964+
joinable!(badges -> crates (crate_id));
964965
joinable!(crate_owner_invitations -> crates (crate_id));
965966
joinable!(crate_owners -> crates (crate_id));
966967
joinable!(crate_owners -> teams (owner_id));

src/tests/load_foreign_key_constraints.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ SELECT relname, conname, pg_get_constraintdef(pg_constraint.oid, true) AS defini
66
LEFT JOIN pg_constraint ON pg_class.oid = conrelid AND ARRAY[attnum] = conkey
77
INNER JOIN pg_namespace ON pg_namespace.oid = pg_class.relnamespace
88
WHERE attname = $1
9-
AND contype = 'f'
9+
AND relkind = 'r'
10+
AND (contype IS NULL OR contype = 'f')
1011
AND nspname = 'public';

0 commit comments

Comments
 (0)