
CREATE DATABASE IF NOT EXISTS fetchmetrics;

GRANT ALL PRIVILEGES ON fetchmetrics.* TO 'teddy'@'%';
FLUSH PRIVILEGES;

USE fetchmetrics;

-- Permanent Temp Tables
DROP TABLE IF EXISTS fetchmetrics.tmp_dog_calc_user_access;
-- DROP TABLE IF EXISTS fetchmetrics.tmp_core_Msg_Error;
DROP TABLE IF EXISTS fetchmetrics.tmp_dog_User;
DROP TABLE IF EXISTS fetchmetrics.tmp_dog_User_Role_Link;


-- Permanent Tables
DROP TABLE IF EXISTS fetchmetrics.PH_Apply_Founding_Partner_Form_Temp;
DROP TABLE IF EXISTS fetchmetrics.PH_Apply_Founding_Partner_Form_Audit;
DROP TABLE IF EXISTS fetchmetrics.PH_Apply_Founding_Partner_Form;

DROP TABLE IF EXISTS fetchmetrics.PH_Contact_Form_Temp;
DROP TABLE IF EXISTS fetchmetrics.PH_Contact_Form_Audit;
DROP TABLE IF EXISTS fetchmetrics.PH_Contact_Form;

DROP TABLE IF EXISTS fetchmetrics.PH_Contact_Form_Change_Set;

DROP TABLE IF EXISTS fetchmetrics.DOG_Assessment_Response_Temp;
DROP TABLE IF EXISTS fetchmetrics.DOG_Assessment_Response_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_Assessment_Response;

DROP TABLE IF EXISTS fetchmetrics.DOG_Obedience_Level_User_Link_Temp;
DROP TABLE IF EXISTS fetchmetrics.DOG_Obedience_Level_User_Link_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_Obedience_Level_User_Link;

DROP TABLE IF EXISTS fetchmetrics.DOG_Obedience_Level_Temp;
DROP TABLE IF EXISTS fetchmetrics.DOG_Obedience_Level_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_Obedience_Level;

DROP TABLE IF EXISTS fetchmetrics.DOG_Response_Quality_Metric_User_Link_Temp;
DROP TABLE IF EXISTS fetchmetrics.DOG_Response_Quality_Metric_User_Link_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_Response_Quality_Metric_User_Link;

DROP TABLE IF EXISTS fetchmetrics.DOG_Response_Quality_Metric_Temp;
DROP TABLE IF EXISTS fetchmetrics.DOG_Response_Quality_Metric_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_Response_Quality_Metric;

DROP TABLE IF EXISTS fetchmetrics.DOG_Distraction_Temp;
DROP TABLE IF EXISTS fetchmetrics.DOG_Distraction_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_Distraction;

DROP TABLE IF EXISTS fetchmetrics.DOG_Assessment_Command_Technique_Link_Temp;
DROP TABLE IF EXISTS fetchmetrics.DOG_Assessment_Command_Technique_Link_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_Assessment_Command_Technique_Link;

DROP TABLE IF EXISTS fetchmetrics.DOG_Assessment_Command_Modality_Link_Temp;
DROP TABLE IF EXISTS fetchmetrics.DOG_Assessment_Command_Modality_Link_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_Assessment_Command_Modality_Link;

DROP TABLE IF EXISTS fetchmetrics.DOG_Training_Technique_Temp;
DROP TABLE IF EXISTS fetchmetrics.DOG_Training_Technique_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_Training_Technique;

DROP TABLE IF EXISTS fetchmetrics.DOG_Assessment_Command_Link_Temp;
DROP TABLE IF EXISTS fetchmetrics.DOG_Assessment_Command_Link_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_Assessment_Command_Link;

DROP TABLE IF EXISTS fetchmetrics.DOG_Reinforcement_Schedule_Temp;
DROP TABLE IF EXISTS fetchmetrics.DOG_Reinforcement_Schedule_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_Reinforcement_Schedule;

DROP TABLE IF EXISTS fetchmetrics.DOG_Distraction_Intensity_Level_User_Link_Temp;
DROP TABLE IF EXISTS fetchmetrics.DOG_Distraction_Intensity_Level_User_Link_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_Distraction_Intensity_Level_User_Link;

DROP TABLE IF EXISTS fetchmetrics.DOG_Distraction_Intensity_Level_Temp;
DROP TABLE IF EXISTS fetchmetrics.DOG_Distraction_Intensity_Level_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_Distraction_Intensity_Level;

DROP TABLE IF EXISTS fetchmetrics.DOG_Distraction_Type_User_Link_Temp;
DROP TABLE IF EXISTS fetchmetrics.DOG_Distraction_Type_User_Link_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_Distraction_Type_User_Link;

DROP TABLE IF EXISTS fetchmetrics.DOG_Distraction_Type_Temp;
DROP TABLE IF EXISTS fetchmetrics.DOG_Distraction_Type_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_Distraction_Type;

DROP TABLE IF EXISTS fetchmetrics.DOG_Assessment_Temp;
DROP TABLE IF EXISTS fetchmetrics.DOG_Assessment_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_Assessment;

DROP TABLE IF EXISTS fetchmetrics.DOG_Assessment_Type_Temp;
DROP TABLE IF EXISTS fetchmetrics.DOG_Assessment_Type_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_Assessment_Type;

DROP TABLE IF EXISTS fetchmetrics.DOG_Lighting_Level_Temp;
DROP TABLE IF EXISTS fetchmetrics.DOG_Lighting_Level_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_Lighting_Level;

DROP TABLE IF EXISTS fetchmetrics.DOG_Weather_Temp;
DROP TABLE IF EXISTS fetchmetrics.DOG_Weather_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_Weather;

DROP TABLE IF EXISTS fetchmetrics.DOG_Command_Button_Link_Temp;
DROP TABLE IF EXISTS fetchmetrics.DOG_Command_Button_Link_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_Command_Button_Link;

DROP TABLE IF EXISTS fetchmetrics.DOG_Button_Icon_Temp;
DROP TABLE IF EXISTS fetchmetrics.DOG_Button_Icon_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_Button_Icon;

DROP TABLE IF EXISTS fetchmetrics.DOG_Image_User_Link_Temp;
DROP TABLE IF EXISTS fetchmetrics.DOG_Image_User_Link_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_Image_User_Link;

DROP TABLE IF EXISTS fetchmetrics.DOG_Image_Temp;
DROP TABLE IF EXISTS fetchmetrics.DOG_Image_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_Image;

DROP TABLE IF EXISTS fetchmetrics.DOG_Colour_Temp;
DROP TABLE IF EXISTS fetchmetrics.DOG_Colour_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_Colour;

DROP TABLE IF EXISTS fetchmetrics.DOG_Button_Shape_User_Link_Temp;
DROP TABLE IF EXISTS fetchmetrics.DOG_Button_Shape_User_Link_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_Button_Shape_User_Link;

DROP TABLE IF EXISTS fetchmetrics.DOG_Button_Shape_Temp;
DROP TABLE IF EXISTS fetchmetrics.DOG_Button_Shape_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_Button_Shape;

DROP TABLE IF EXISTS fetchmetrics.DOG_Location_Link_Temp;
DROP TABLE IF EXISTS fetchmetrics.DOG_Location_Link_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_Location_Link;

DROP TABLE IF EXISTS fetchmetrics.DOG_Location_User_Link_Temp;
DROP TABLE IF EXISTS fetchmetrics.DOG_Location_User_Link_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_Location_User_Link;

DROP TABLE IF EXISTS fetchmetrics.DOG_Location_Temp;
DROP TABLE IF EXISTS fetchmetrics.DOG_Location_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_Location;

DROP TABLE IF EXISTS fetchmetrics.DOG_Command_Modality_Temp;
DROP TABLE IF EXISTS fetchmetrics.DOG_Command_Modality_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_Command_Modality;

/* Start of remove section */
DROP TABLE IF EXISTS fetchmetrics.DOG_Personal_Best_Temp;
DROP TABLE IF EXISTS fetchmetrics.DOG_Personal_Best_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_Personal_Best;
/* End of remove section */

DROP TABLE IF EXISTS fetchmetrics.DOG_Dog_Command_Link_Temp;
DROP TABLE IF EXISTS fetchmetrics.DOG_Dog_Command_Link_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_Dog_Command_Link;

DROP TABLE IF EXISTS fetchmetrics.DOG_Command_Temp;
DROP TABLE IF EXISTS fetchmetrics.DOG_Command_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_Command;

DROP TABLE IF EXISTS fetchmetrics.DOG_Command_Category_User_Link_Temp;
DROP TABLE IF EXISTS fetchmetrics.DOG_Command_Category_User_Link_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_Command_Category_User_Link;

DROP TABLE IF EXISTS fetchmetrics.DOG_Command_Category_Temp;
DROP TABLE IF EXISTS fetchmetrics.DOG_Command_Category_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_Command_Category;

/* Start of remove section */
DROP TABLE IF EXISTS fetchmetrics.DOG_Understanding_Level_Temp;
DROP TABLE IF EXISTS fetchmetrics.DOG_Understanding_Level_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_Understanding_Level;

DROP TABLE IF EXISTS fetchmetrics.DOG_Competency_Level_Temp;
DROP TABLE IF EXISTS fetchmetrics.DOG_Competency_Level_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_Competency_Level;
/* End of remove section */

DROP TABLE IF EXISTS fetchmetrics.DOG_Dog_Drive_Link_Temp;
DROP TABLE IF EXISTS fetchmetrics.DOG_Dog_Drive_Link_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_Dog_Drive_Link;

DROP TABLE IF EXISTS fetchmetrics.DOG_Drive_Temp;
DROP TABLE IF EXISTS fetchmetrics.DOG_Drive_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_Drive;

DROP TABLE IF EXISTS fetchmetrics.DOG_Dog_Breed_Link_Temp;
DROP TABLE IF EXISTS fetchmetrics.DOG_Dog_Breed_Link_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_Dog_Breed_Link;

DROP TABLE IF EXISTS fetchmetrics.DOG_Breed_Temp;
DROP TABLE IF EXISTS fetchmetrics.DOG_Breed_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_Breed;

DROP TABLE IF EXISTS fetchmetrics.DOG_Dog_Temp;
DROP TABLE IF EXISTS fetchmetrics.DOG_Dog_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_Dog;

DROP TABLE IF EXISTS fetchmetrics.DOG_Dog_Change_Set;

-- Core tables
DROP TABLE IF EXISTS fetchmetrics.DOG_Unit_Measurement_Conversion_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_Unit_Measurement_Conversion;

DROP TABLE IF EXISTS fetchmetrics.DOG_Unit_Measurement_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_Unit_Measurement;

DROP TABLE IF EXISTS fetchmetrics.DOG_Calc_User_Access_Temp;

DROP TABLE IF EXISTS fetchmetrics.DOG_User_Role_Link_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_User_Role_Link;

DROP TABLE IF EXISTS fetchmetrics.DOG_Role_Permission_Link_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_Role_Permission_Link;

DROP TABLE IF EXISTS fetchmetrics.DOG_Role_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_Role;

DROP TABLE IF EXISTS fetchmetrics.DOG_User_Temp;
DROP TABLE IF EXISTS fetchmetrics.DOG_User_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_User;

DROP TABLE IF EXISTS fetchmetrics.DOG_Permission_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_Permission;

DROP TABLE IF EXISTS fetchmetrics.DOG_Permission_Group_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_Permission_Group;

DROP TABLE IF EXISTS fetchmetrics.DOG_Access_Level_Audit;
DROP TABLE IF EXISTS fetchmetrics.DOG_Access_Level;

DROP TABLE IF EXISTS fetchmetrics.DOG_User_Change_Set;


DROP TABLE IF EXISTS fetchmetrics.CORE_Split_Key_Value_Pair_Csv_Temp;
DROP TABLE IF EXISTS fetchmetrics.CORE_Split_Temp;

DROP TABLE IF EXISTS fetchmetrics.CORE_File_Type;
DROP TABLE IF EXISTS fetchmetrics.CORE_Msg_Error_Type;

-- Stored Procedures
DROP PROCEDURE IF EXISTS fetchmetrics.p_ph_test_get_many_contact_form;
DROP PROCEDURE IF EXISTS fetchmetrics.p_ph_get_many_contact_form;
DROP PROCEDURE IF EXISTS fetchmetrics.p_ph_test_save_contact_form;
DROP PROCEDURE IF EXISTS fetchmetrics.p_ph_save_contact_form;

DROP PROCEDURE IF EXISTS fetchmetrics.p_dog_test_get_many_dog_command;
DROP PROCEDURE IF EXISTS fetchmetrics.p_dog_test_get_many_command;
DROP PROCEDURE IF EXISTS fetchmetrics.p_dog_get_many_command;
DROP PROCEDURE IF EXISTS fetchmetrics.p_dog_get_many_dog_command;
DROP PROCEDURE IF EXISTS fetchmetrics.p_dog_get_many_dog_command_link;
DROP PROCEDURE IF EXISTS fetchmetrics.p_dog_test_save_command;
DROP PROCEDURE IF EXISTS fetchmetrics.p_dog_save_command;
DROP PROCEDURE IF EXISTS fetchmetrics.p_command_clear_calc_command;

DROP PROCEDURE IF EXISTS fetchmetrics.p_dog_clear_calc_user_access;
DROP PROCEDURE IF EXISTS fetchmetrics.p_dog_calc_user_access;
DROP PROCEDURE IF EXISTS fetchmetrics.p_core_clear_split;

/*
DROP PROCEDURE IF EXISTS fetchmetrics.p_core_clear_split_key_value_pair_csv;
DROP PROCEDURE IF EXISTS fetchmetrics.p_core_split_key_value_pair_csv;
DROP PROCEDURE IF EXISTS fetchmetrics.p_core_clear_split;
DROP PROCEDURE IF EXISTS fetchmetrics.p_core_split;
DROP PROCEDURE IF EXISTS fetchmetrics.p_clear_split_key_value_pair_csv;
DROP PROCEDURE IF EXISTS fetchmetrics.p_core_split_key_value_pair_csv;
DROP PROCEDURE IF EXISTS fetchmetrics.p_clear_split;
DROP PROCEDURE IF EXISTS fetchmetrics.p_core_split;

DROP PROCEDURE IF EXISTS fetchmetrics.p_core_debug_timing_reporting;
DROP PROCEDURE IF EXISTS fetchmetrics.p_debug_timing_reporting;
DROP PROCEDURE IF EXISTS fetchmetrics.p_core_validate_guid;
DROP PROCEDURE IF EXISTS fetchmetrics.p_core_validate_guid_test;
*/