The following worked perfectly for me
Code:
function pMinimap:ADDON_LOADED(event)
pMinimapDB = pMinimapDB or {}
for k,v in pairs(defaults) do
if(type(pMinimapDB[k]) == 'nil') then
pMinimapDB[k] = v
end
end
self:UnregisterEvent(event)
-- rest of the addon here
end