fedimovies/migrations/V0032__actor_profile__add_subscriber_count.sql

6 lines
290 B
MySQL
Raw Normal View History

ALTER TABLE actor_profile ADD COLUMN subscriber_count INTEGER NOT NULL CHECK (subscriber_count >= 0) DEFAULT 0;
UPDATE actor_profile SET subscriber_count = (
SELECT count(*) FROM relationship WHERE relationship.target_id = actor_profile.id
AND relationship.relationship_type = 3
);