From 678716856517d699d95f741d34b84ee389cedece Mon Sep 17 00:00:00 2001 From: Mia Date: Sat, 5 Jul 2025 19:35:54 +0100 Subject: [PATCH] fix!: finally fix the dodgy postgate/threadgate foreign keys --- diesel.toml | 1 + fk.patch | 18 ++++++++++++++++++ migrations/2025-02-16-142357_posts/up.sql | 4 ++-- 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 fk.patch diff --git a/diesel.toml b/diesel.toml index 8e54f04e..ab40166b 100644 --- a/diesel.toml +++ b/diesel.toml @@ -4,6 +4,7 @@ [print_schema] file = "parakeet-db/src/schema.rs" custom_type_derives = ["diesel::query_builder::QueryId"] +patch_file = "fk.patch" [migrations_directory] dir = "migrations" diff --git a/fk.patch b/fk.patch new file mode 100644 index 00000000..6ab63ef4 --- /dev/null +++ b/fk.patch @@ -0,0 +1,18 @@ +diff --git a/parakeet-db/src/schema.rs b/parakeet-db/src/schema.rs +index 59f65d9..a4219d5 100644 +--- a/parakeet-db/src/schema.rs ++++ b/parakeet-db/src/schema.rs +@@ -364,11 +364,13 @@ diesel::joinable!(post_embed_images -> posts (post_uri)); + diesel::joinable!(post_embed_record -> posts (post_uri)); + diesel::joinable!(post_embed_video -> posts (post_uri)); + diesel::joinable!(post_embed_video_captions -> posts (post_uri)); ++diesel::joinable!(postgates -> posts (post_uri)); + diesel::joinable!(posts -> actors (did)); + diesel::joinable!(profiles -> actors (did)); + diesel::joinable!(reposts -> actors (did)); + diesel::joinable!(starterpacks -> actors (owner)); + diesel::joinable!(statuses -> actors (did)); ++diesel::joinable!(threadgates -> posts (post_uri)); + diesel::joinable!(verification -> actors (verifier)); + + diesel::allow_tables_to_appear_in_same_query!( diff --git a/migrations/2025-02-16-142357_posts/up.sql b/migrations/2025-02-16-142357_posts/up.sql index 116ec2ac..3cbae560 100644 --- a/migrations/2025-02-16-142357_posts/up.sql +++ b/migrations/2025-02-16-142357_posts/up.sql @@ -103,7 +103,7 @@ create table postgates ( at_uri text primary key, cid text not null, - post_uri text not null references posts (at_uri) on delete cascade deferrable, + post_uri text not null, detached text[] not null, rules text[] not null, @@ -120,7 +120,7 @@ create table threadgates ( at_uri text primary key, cid text not null, - post_uri text not null references posts (at_uri) on delete cascade deferrable, + post_uri text not null, hidden_replies text[] not null, allow text[] not null, -- 2.51.2