I’m facing the same issue described by @BaptisteGelez while applying this migration, and I cannot afford to reset my instance. Is there anything to do to manually fix the issue? I can run SQL by hand if needed :)
@EliotBerriot try to find user with empty followers_endpoint with SELECT id, username FROM users WHERE followers_endpoint = ''; and if anything is returned, edit the follower endpoint so that it has a value (it can be anything as long as it is not null, nor already used by another user). If I remember correctly, that’s how I fixed it on fediverse.blog. Sorry for the bug… 😕
If it still doesn’t work, try to check users.ap_url, user.inbox_url and user.outbox_url too.
Okay, so maybe try to reset the post covers (it will not impact your articles as you didn’t used them for Funkwhale’s blog), with UPDATE posts SET cover_id = null;. I don’t know if it will fix the issue, but it is worth a try.
I made this script that should delete comments with invalid ActivityPub URLs, and their replies.
CREATE OR REPLACE FUNCTION delete_comment (id int) RETURNS comments
FOR r IN (SELECT id FROM comments WHERE in_response_to_id = id) LOOP
DELETE FROM comments WHERE id = id;
END $$ LANGUAGE plpgsql;
SELECT delete_comment(id) FROM comments WHERE ap_url = '';
I didn’t tested it, but it should only delete broken comments (and hopefully fix the migrations).
eliotberriot@peeters:/srv/Plume$ docker-compose exec postgres psql -U plume
psql (10.5 (Debian 10.5-2.pgdg90+1))
Type "help" for help.
plume=# CREATE OR REPLACE FUNCTION delete_comment (id int) RETURNS comments
plume-# AS $$
plume$# r int;
plume$# FOR r IN (SELECT id FROM comments WHERE in_response_to_id = id) LOOP
plume$# SELECT delete_comment(r);
plume$# END LOOP;
plume$# DELETE FROM comments WHERE id = id;
plume$# END $$ LANGUAGE plpgsql;
plume=# SELECT delete_comment(id) FROM comments WHERE ap_url = '';
eliotberriot@peeters:/srv/Plume$ docker-compose run --rm plume diesel migration run --migration-dir migrations/postgres/
Starting plume_postgres_1 ... done
Running migration 2018-12-08-175515_constraints
update or delete on table "comments" violates foreign key constraint "comments_in_response_to_id_fkey" on table "comments"