6 How To Turn Adults Into Children Again Shared by Gerry Miller, LCBC Church 4 years ago 9.4 General Advanced A few of our younger kids were marked as adults, even though they were only born last year. Wouldn't it be amazing if we could turn adults into kids again! Now you can. Two quick disclaimers: This recipe uses SQL to modify the database. Please remember when running SQL with great power comes great responsibility.This recipe will only work in the database and will not actually make you younger.Now to turn Adults into Children Again....Create A Data ViewFirst, create a data view of people less than 18 years old and classified as an adult. Persist this for 1440 minutes. If something happens, you will want to be able to find these people. Persisting the data view will make the values available for SQL queries.Update Family Group RoleNext, you may need to update the family group role from Adult to Child.Run the following SQL to see if any roles need to be updated. If all the roles show as Child, you can move on to the Age Classification Step. SELECT gm.GroupRoleId ,gtr.Name ,p.Id FROM Person AS p JOIN [GroupMember] as gm on gm.GroupId=p.PrimaryFamilyId and gm.PersonId=p.Id JOIN [GroupTypeRole] as gtr on gtr.Id=gm.GroupRoleId WHERE p.Id in (SELECT EntityId FROM DataViewPersistedValue WHERE DataViewId=XXXXX) AND gm.GroupId in (SELECT Id FROM [Group] WHERE GroupTypeId=10); If you need to update family roles run the following command. Replace the XXXXX with the person id of one person who needs to be corrected. I always test on one person first because it is easier to fix one record than a few hundred. UPDATE GroupMember SET GroupRoleId=4 WHERE PersonId=XXXXX AND GroupMember.GroupId in (SELECT Id FROM [Group] WHERE GroupTypeId=10); Next, verify that the change worked as expected. Replace the XXXXX with the person id of your test person.SELECT gm.GroupRoleId ,gtr.Name ,p.Id FROM Person AS p JOIN [GroupMember] as gm on gm.GroupId=p.PrimaryFamilyId and gm.PersonId=p.Id JOIN [GroupTypeRole] as gtr on gtr.Id=gm.GroupRoleId WHERE p.Id in (SELECT EntityId FROM DataViewPersistedValue WHERE PersonId=XXXXX) AND gm.GroupId in (SELECT Id FROM [Group] WHERE GroupTypeId=10); If everything seemed to work as expected, run the following command to update everyone in the data view. UPDATE GroupMember SET GroupRoleId=4 WHERE GroupMember.PersonId in (SELECT EntityId FROM DataViewPersistedValue WHERE DataViewId=XXXXX)AND GroupMember.GroupId in (SELECT Id FROM [Group] WHERE GroupTypeId=10); Then run the same SQL as step 1 to verify all of your changes. SELECT gm.GroupRoleId ,gtr.Name ,p.Id FROM Person AS p JOIN [GroupMember] as gm on gm.GroupId=p.PrimaryFamilyId and gm.PersonId=p.Id JOIN [GroupTypeRole] as gtr on gtr.Id=gm.GroupRoleId WHERE p.Id in (SELECT EntityId FROM DataViewPersistedValue WHERE DataViewId=XXXX) AND gm.GroupId in (SELECT Id FROM [Group] WHERE GroupTypeId=10); Update Age Classification Run the following SQL to see if any age classifications need to be updated. SELECT Id ,AgeClassification FROM Person WHERE ID in (SELECT EntityId FROM DataViewPersistedValue WHERE DataViewId=XXXXX) AND AgeClassification=2; If you need to update any age classifications run the following command. Replace the XXXXX with the person id of one person who needs to be corrected. I always test on one person first because it is easier to fix one record than a few hundred. UPDATE Person SET AgeClassification=2 WHERE Person.Id=XXXXX; Next, verify that the change worked as expected. Replace the XXXXX with the person id of your test person. SELECT Id,AgeClassificationFROM Person WHERE ID=XXXXX; If everything seemed to work as expected, run the following command to update everyone in the data view. UPDATE Person SET AgeClassification=2 WHERE Person.Id IN (Select EntityId from DataViewPersistedValue where DataViewId=XXXXX); Then run the same SQL as step 1 to verify all of your changes. SELECT Id ,AgeClassification FROM Person WHERE ID in (SELECT EntityId FROM DataViewPersistedValue WHERE DataViewId=XXXXX) AND AgeClassification=2;