-- Depopulate-RM7_5.sql
/*
2022-04-15 Tom Holden, ve3meo
 adapted from CustomDatabaseShell.sql
  -2011-12-09 ve3meo

 Prepares a parent RM7.5 database to import a
 GEDCOM from its child RM8 database to reunite
 the data with the custom reports and book publishing
 not available in RM8 along with the group definitions
 in place at the time the RM7 database was superseded 
 by the RM8 child database.   

 DELETES all records from the .RMGC database file
 except for Addresses, Config, standard FactTypes, 
 Group definitions, 
 built-in Places, built-in Roles, built-in Source Templates

*/

REINDEX ; -- N.B. After this script, REBUILD INDEXES in RM7 before importing
BEGIN TRANSACTION ;
DELETE FROM AddressLinkTable ;
DELETE FROM AddressTable ;
DELETE FROM ChildTable ;
DELETE FROM CitationTable ;
--DELETE FROM ConfigTable ; -- leaving custom reports and book settings intact
DELETE FROM EventTable ;
DELETE FROM ExclusionTable ;
DELETE FROM FactTypeTable WHERE FactTypeID >999 ; -- delete custom FactTypes
DELETE FROM FamilyTable ;
--DELETE FROM GroupTable ; -- leaving group defs in place
--DELETE FROM LabelTable ; -- leaving group names in place
DELETE FROM LinkAncestryTable ;
DELETE FROM LinkTable ;
DELETE FROM MediaLinkTable ;
DELETE FROM MultimediaTable ;
DELETE FROM NameTable ;
DELETE FROM PersonTable ;
DELETE FROM PlaceTable WHERE PlaceType <>1 ; -- delete all but LDS Temples
DELETE FROM ResearchItemTable ;
DELETE FROM ResearchTable ;
DELETE FROM RoleTable WHERE RoleID>57 ; -- delete custom roles
DELETE FROM SourceTable ;
DELETE FROM SourceTemplateTable WHERE TemplateID >9999 ; -- delete custom source templates
DELETE FROM URLTable ;
DELETE FROM WitnessTable ;
COMMIT TRANSACTION ;