db: initdb: rewrite to look and work better
Merge branch 'database-api'