addSql('ALTER TABLE chat_channel ADD member_count INT NOT NULL DEFAULT 0'); // Update existing channels with correct member count $this->addSql(' UPDATE chat_channel c SET member_count = ( SELECT COUNT(*) FROM chat_channel_member m WHERE m.channel_id = c.id AND m.is_active = 1 ) '); } public function down(Schema $schema): void { $this->addSql('ALTER TABLE chat_channel DROP member_count'); } }