reconstruct the structure of dirs, and add the sql structure