From ce083464872f012b89f997db783493cdea3f8ed7 Mon Sep 17 00:00:00 2001 From: fdb-hiroshima <35889323+fdb-hiroshima@users.noreply.github.com> Date: Tue, 18 Dec 2018 15:03:47 +0100 Subject: [PATCH] Remove ap_url from mention (#362) --- .../2018-12-17-180104_mention_no_ap_url/down.sql | 2 ++ .../2018-12-17-180104_mention_no_ap_url/up.sql | 2 ++ .../2018-12-17-180104_mention_no_ap_url/down.sql | 2 ++ .../sqlite/2018-12-17-180104_mention_no_ap_url/up.sql | 11 +++++++++++ plume-models/src/mentions.rs | 5 ----- plume-models/src/schema.rs | 1 - 6 files changed, 17 insertions(+), 6 deletions(-) create mode 100644 migrations/postgres/2018-12-17-180104_mention_no_ap_url/down.sql create mode 100644 migrations/postgres/2018-12-17-180104_mention_no_ap_url/up.sql create mode 100644 migrations/sqlite/2018-12-17-180104_mention_no_ap_url/down.sql create mode 100644 migrations/sqlite/2018-12-17-180104_mention_no_ap_url/up.sql diff --git a/migrations/postgres/2018-12-17-180104_mention_no_ap_url/down.sql b/migrations/postgres/2018-12-17-180104_mention_no_ap_url/down.sql new file mode 100644 index 0000000..9ba08b0 --- /dev/null +++ b/migrations/postgres/2018-12-17-180104_mention_no_ap_url/down.sql @@ -0,0 +1,2 @@ +-- This file should undo anything in `up.sql` +ALTER TABLE mentions ADD COLUMN ap_url VARCHAR NOT NULL DEFAULT ''; diff --git a/migrations/postgres/2018-12-17-180104_mention_no_ap_url/up.sql b/migrations/postgres/2018-12-17-180104_mention_no_ap_url/up.sql new file mode 100644 index 0000000..b56c118 --- /dev/null +++ b/migrations/postgres/2018-12-17-180104_mention_no_ap_url/up.sql @@ -0,0 +1,2 @@ +-- Your SQL goes here +ALTER TABLE mentions DROP COLUMN ap_url; diff --git a/migrations/sqlite/2018-12-17-180104_mention_no_ap_url/down.sql b/migrations/sqlite/2018-12-17-180104_mention_no_ap_url/down.sql new file mode 100644 index 0000000..9ba08b0 --- /dev/null +++ b/migrations/sqlite/2018-12-17-180104_mention_no_ap_url/down.sql @@ -0,0 +1,2 @@ +-- This file should undo anything in `up.sql` +ALTER TABLE mentions ADD COLUMN ap_url VARCHAR NOT NULL DEFAULT ''; diff --git a/migrations/sqlite/2018-12-17-180104_mention_no_ap_url/up.sql b/migrations/sqlite/2018-12-17-180104_mention_no_ap_url/up.sql new file mode 100644 index 0000000..a748bc9 --- /dev/null +++ b/migrations/sqlite/2018-12-17-180104_mention_no_ap_url/up.sql @@ -0,0 +1,11 @@ +-- Your SQL goes here +CREATE TABLE mentions2 ( + id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + mentioned_id INTEGER REFERENCES users(id) ON DELETE CASCADE NOT NULL, + post_id INTEGER REFERENCES posts(id) ON DELETE CASCADE, + comment_id INTEGER REFERENCES comments(id) ON DELETE CASCADE +); + +INSERT INTO mentions2 SELECT id,mentioned_id,post_id,comment_id FROM mentions; +DROP TABLE mentions; +ALTER TABLE mentions2 RENAME TO mentions; diff --git a/plume-models/src/mentions.rs b/plume-models/src/mentions.rs index c424819..c18ae6e 100644 --- a/plume-models/src/mentions.rs +++ b/plume-models/src/mentions.rs @@ -15,7 +15,6 @@ pub struct Mention { pub mentioned_id: i32, pub post_id: Option, pub comment_id: Option, - pub ap_url: String, // TODO: remove, since mentions don't have an AP URL actually, this field was added by mistake } #[derive(Insertable)] @@ -24,13 +23,11 @@ pub struct NewMention { pub mentioned_id: i32, pub post_id: Option, pub comment_id: Option, - pub ap_url: String, } impl Mention { insert!(mentions, NewMention); get!(mentions); - find_by!(mentions, find_by_ap_url, ap_url as &str); list_by!(mentions, list_for_user, mentioned_id as i32); list_by!(mentions, list_for_post, post_id as i32); list_by!(mentions, list_for_comment, comment_id as i32); @@ -103,7 +100,6 @@ impl Mention { mentioned_id: mentioned.id, post_id: Some(post.id), comment_id: None, - ap_url: ment.link_props.href_string().unwrap_or_default(), }, ); if notify { @@ -119,7 +115,6 @@ impl Mention { mentioned_id: mentioned.id, post_id: None, comment_id: Some(comment.id), - ap_url: ment.link_props.href_string().unwrap_or_default(), }, ); if notify { diff --git a/plume-models/src/schema.rs b/plume-models/src/schema.rs index 7d9e39e..bd36365 100644 --- a/plume-models/src/schema.rs +++ b/plume-models/src/schema.rs @@ -115,7 +115,6 @@ table! { mentioned_id -> Int4, post_id -> Nullable, comment_id -> Nullable, - ap_url -> Varchar, } }