Browse Source

Remove ap_url from mention (#362)

fix-mobile-margin
fdb-hiroshima 4 years ago
committed by GitHub
parent
commit
ce08346487
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      migrations/postgres/2018-12-17-180104_mention_no_ap_url/down.sql
  2. 2
      migrations/postgres/2018-12-17-180104_mention_no_ap_url/up.sql
  3. 2
      migrations/sqlite/2018-12-17-180104_mention_no_ap_url/down.sql
  4. 11
      migrations/sqlite/2018-12-17-180104_mention_no_ap_url/up.sql
  5. 5
      plume-models/src/mentions.rs
  6. 1
      plume-models/src/schema.rs

2
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 '';

2
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;

2
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 '';

11
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;

5
plume-models/src/mentions.rs

@ -15,7 +15,6 @@ pub struct Mention {
pub mentioned_id: i32,
pub post_id: Option<i32>,
pub comment_id: Option<i32>,
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<i32>,
pub comment_id: Option<i32>,
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 {

1
plume-models/src/schema.rs

@ -115,7 +115,6 @@ table! {
mentioned_id -> Int4,
post_id -> Nullable<Int4>,
comment_id -> Nullable<Int4>,
ap_url -> Varchar,
}
}

Loading…
Cancel
Save