Throw error if the removed code_migrations.rs needed to run but didn't (#5723)

* Throw error if the removed code_migrations.rs needed to run but didn't

* support postgresql 15

* improve error message

---------

Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
This commit is contained in:
dullbananas 2025-06-03 08:38:50 -07:00 committed by GitHub
parent 47111a8c6c
commit 9f425b8f42
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 65 additions and 0 deletions

View file

@ -0,0 +1,3 @@
SELECT
;

View file

@ -0,0 +1,62 @@
-- https://github.com/LemmyNet/lemmy/pull/5710
-- Uncomment to test:
-- ALTER TABLE site DROP COLUMN instance_id; INSERT INTO site (name, public_key) VALUES ('', '');
DO $$
BEGIN
IF EXISTS (
SELECT
FROM ((
SELECT
id
FROM
person
WHERE
ap_id LIKE 'http://changeme%'
OR (local
AND public_key = ''))
UNION ALL (
SELECT
id
FROM
community
WHERE
ap_id LIKE 'http://changeme%'
OR (local
AND public_key = ''))
UNION ALL (
SELECT
id
FROM
post
WHERE
thumbnail_url NOT LIKE 'http%'
OR (local
AND ap_id LIKE 'http://changeme%'))
UNION ALL (
SELECT
id
FROM
comment
WHERE
ap_id LIKE 'http://changeme%'
AND local)
UNION ALL (
SELECT
id
FROM
private_message
WHERE
ap_id LIKE 'http://changeme%'
AND local)
UNION ALL (
SELECT
id
FROM
site
WHERE
public_key = '')) AS broken_rows) THEN
RAISE 'Unstable upgrade: Youre on too old a version of lemmy. Upgrade to 0.19.0 first.';
END IF;
END
$$;