fix initprovider exit code for MySQL and PostgreSQL

This commit is contained in:
Nicola Murino 2020-08-30 14:00:45 +02:00
parent 600a107699
commit 91a4c64390
2 changed files with 8 additions and 0 deletions

View file

@ -172,6 +172,10 @@ func (p MySQLProvider) reloadConfig() error {
// initializeDatabase creates the initial database structure
func (p MySQLProvider) initializeDatabase() error {
dbVersion, err := sqlCommonGetDatabaseVersion(p.dbHandle, false)
if err == nil && dbVersion.Version > 0 {
return ErrNoInitRequired
}
sqlUsers := strings.Replace(mysqlUsersTableSQL, "{{users}}", sqlTableUsers, 1)
tx, err := p.dbHandle.Begin()
if err != nil {

View file

@ -171,6 +171,10 @@ func (p PGSQLProvider) reloadConfig() error {
// initializeDatabase creates the initial database structure
func (p PGSQLProvider) initializeDatabase() error {
dbVersion, err := sqlCommonGetDatabaseVersion(p.dbHandle, false)
if err == nil && dbVersion.Version > 0 {
return ErrNoInitRequired
}
sqlUsers := strings.Replace(pgsqlUsersTableSQL, "{{users}}", sqlTableUsers, 1)
tx, err := p.dbHandle.Begin()
if err != nil {