Improving PostgreSQL support

The current implementation does not create the schema on PostgreSQL.
However even if you create the schema by hand, you have issues on a SQL query relative to config because PostgreSQL does not support `ON DUPLICATE KEY UPDATE`

This PR:
* adds the automatic creation of tables and indexes
* fixes the query currently not working on PostgreSQL

The added checks should not add to much overhead since they are done on start and the query for saving config is not executed that often.
However doing check like that may not be the cleanest way, maybe we should introduce an abstraction?
This could also eases the use of other DB backend.