Ok Dan, I've emailed you everything you need but it's getting late in the UK and I may need to leave this with you.
Here's my two step method.
1) First of all, query the leads_audit table to find out when your update started.
2) Once you got that, you can undo the changes.
This would be really easy if you could access the database thru phpMyAdmin, but as you can't the easiest thing is to knock up a quick bit of code to do it.
So, you're going to need to create files in the <sugar root>/modules/Leads folder. The first one is called temp_dump_leads.php
And it contains this:
Code:
<?php
//Connect using default database settings
$this->db = & PearDatabase::getInstance();
$this->dbManager = DBManagerFactory::getInstance();
//Dump what's in the lead_audit table for today to find out the time this happened
$result=$this->dbManager->query("
SELECT *
FROM `leads_audit`
WHERE date_created > '2008-08-20'
ORDER BY date_created desc
;");
while ($row = $result->fetch_row()) {
foreach($row as $field){
echo $field.", ";
}
echo '<br>';
}
?> To run that code, load Sugar and then change the url to read index.php?module=Leads&action=temp_dump_leads
It will print on the screen a few thousand records showing the before and after values and dates changed. Scroll down till you find the start of your update and note the date time (it's in yyyy-mm-dd hh:mm format).
Ok, now step 2 the update....
Create a second file called temp_restore_leads.php which looks like this:
Code:
<?php
//Connect using default database settings
$this->db = & PearDatabase::getInstance();
$this->dbManager = DBManagerFactory::getInstance();
//Restore the data $result=$this->dbManager->query("
update leads, leads_audit
set leads.assigned_user_id = leads_audit.before_value_string
where leads_audit.date_created > '2008-08-20 19:13'
and leads.id=leads_audit.parent_id
;");
echo "DONE! DATA RESTORED";
echo '<br>';
?> But change the line where leads_audit.date_created > '2008-08-20 19:13' to match the date and time you noted in step 1.
Run the code in the same way as before - change the url to read index.php?module=Leads&action=temp_restore_leads
That will undo your change.
Now delete those two temp files.
I've tested this on my system. I've got to hit the sack but hopefully if you're having problems finding your Sugar root directory or creating the files, someone else can guide you now.
Good luck
Nick
Bookmarks