Complete 7e79d9139f931e45f732de9a39cc54bedd95bd6f's changes

7e79d9139f931e45f732de9a39cc54bedd95bd6f changes was missing the given chanegs in lib/database. This patch fix it.