* Fixed a bug in Database->_age_out_data() where, when all records in the history schema would be purged, the most recent record would not be preserved. The result is that nothing was purged, allow tables to grow dramatically. The 'variables' table was also added to this age-out list.
# Find how many records will be left. If it's 0, we'll use an OFFSET 1.
my$query="SELECT history_id FROM history.".$child_table." WHERE ".$uuid_column." = ".$anvil->Database->quote($column_uuid)." AND modified_date > '".$old_timestamp."';";
@ -16781,16 +16782,17 @@ sub _age_out_data
}
else
{
# This would delete everything, reserve at least one record.
my$query="DELETE FROM history.".$child_table." WHERE ".$uuid_column." = ".$anvil->Database->quote($column_uuid)." AND history_id = '".$history_id."';";
my$query="SELECT history_id FROM history.".$child_table." WHERE ".$uuid_column." = ".$anvil->Database->quote($column_uuid)." ORDER BY modified_date DESC LIMIT 1;";
$query="DELETE FROM history.".$child_table." WHERE ".$uuid_column." = ".$anvil->Database->quote($column_uuid)." AND modified_date <= '".$old_timestamp."' AND history_id != '".$history_id."';";