mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-12-01 22:01:49 +00:00
parent
3f2a689edf
commit
eacd4e44cd
3 changed files with 25 additions and 0 deletions
|
@ -0,0 +1 @@
|
||||||
|
drop function drop_ccnew_indexes;
|
|
@ -0,0 +1,13 @@
|
||||||
|
CREATE OR REPLACE FUNCTION drop_ccnew_indexes() RETURNS INTEGER AS $$
|
||||||
|
DECLARE
|
||||||
|
i RECORD;
|
||||||
|
BEGIN
|
||||||
|
FOR i IN
|
||||||
|
(SELECT relname FROM pg_class WHERE relname like '%ccnew%')
|
||||||
|
LOOP
|
||||||
|
EXECUTE 'DROP INDEX ' || i.relname;
|
||||||
|
END LOOP;
|
||||||
|
RETURN 1;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE plpgsql;
|
||||||
|
|
|
@ -22,6 +22,7 @@ pub fn setup(pool: DbPool) -> Result<(), LemmyError> {
|
||||||
active_counts(&conn);
|
active_counts(&conn);
|
||||||
update_banned_when_expired(&conn);
|
update_banned_when_expired(&conn);
|
||||||
reindex_aggregates_tables(&conn, true);
|
reindex_aggregates_tables(&conn, true);
|
||||||
|
drop_ccnew_indexes(&conn);
|
||||||
});
|
});
|
||||||
|
|
||||||
let conn = pool.get()?;
|
let conn = pool.get()?;
|
||||||
|
@ -103,3 +104,13 @@ fn update_banned_when_expired(conn: &PgConnection) {
|
||||||
.execute(conn)
|
.execute(conn)
|
||||||
.expect("update banned when expires");
|
.expect("update banned when expires");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Drops the phantom CCNEW indexes created by postgres
|
||||||
|
/// https://github.com/LemmyNet/lemmy/issues/2431
|
||||||
|
fn drop_ccnew_indexes(conn: &PgConnection) {
|
||||||
|
info!("Dropping phantom ccnew indexes...");
|
||||||
|
let drop_stmt = "select drop_ccnew_indexes()";
|
||||||
|
sql_query(drop_stmt)
|
||||||
|
.execute(conn)
|
||||||
|
.expect("drop ccnew indexes");
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue