lemmy/migrations/2023-08-01-101826_admin_flag_local_user/down.sql
Nutomic 6047257bfc
Move admin flag from person to local_user (fixes #3060) (#3403)
* Move admin flag from person to local_user (fixes #3060)

The person table is for federated data, but admin flag can only
apply to local users. Thats why it really belongs in the local_user
table. This will also prevent the federation code from accidentally
overwriting the admin flag

* fmt

* try to fix api tests

* lint

* fix person view

* ci

* ci

---------

Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
2023-08-24 05:40:08 -04:00

16 lines
249 B
SQL

ALTER TABLE person
ADD COLUMN admin boolean DEFAULT FALSE NOT NULL;
UPDATE
person
SET
admin = TRUE
FROM
local_user
WHERE
local_user.person_id = person.id
AND local_user.admin;
ALTER TABLE local_user
DROP COLUMN admin;