seknox / trasa

Zero Trust Service Access
https://www.trasa.io
Mozilla Public License 2.0
382 stars 71 forks source link

[REF] Implement "insert if not exist" for init database functions in server start. #172

Closed flyinghermit closed 3 years ago

flyinghermit commented 3 years ago

There are few database functions related to global settings which are required to be executed when trasa server starts. Implement "insert if not exist" code to only fire database function if data does not exist already.

Log sample

TRAC[2020-11-11T21:00:55+05:45]initdb/init.go:239 github.com/seknox/trasa/server/initdb.storeGlobalDynamicServiceSetting pq: duplicate key value violates unique constraint "unique_globalsettings" 
TRAC[2020-11-11T21:00:55+05:45]initdb/init.go:125 github.com/seknox/trasa/server/initdb.storeGlobalPasswordPolicy Global Password Policy stored                
TRAC[2020-11-11T21:00:55+05:45]initdb/init.go:320 github.com/seknox/trasa/server/initdb.storeDefaultSecRules pq: duplicate key value violates unique constraint "unique_secrule" 
TRAC[2020-11-11T21:00:55+05:45]initdb/init.go:320 github.com/seknox/trasa/server/initdb.storeDefaultSecRules pq: duplicate key value violates unique constraint "unique_secrule" 
TRAC[2020-11-11T21:00:55+05:45]initdb/init.go:320 github.com/seknox/trasa/server/initdb.storeDefaultSecRules pq: duplicate key value violates unique constraint "unique_secrule" 
TRAC[2020-11-11T21:00:55+05:45]initdb/init.go:320 github.com/seknox/trasa/server/initdb.storeDefaultSecRules pq: duplicate key value violates unique constraint "unique_secrule" 
TRAC[2020-11-11T21:00:55+05:45]initdb/init.go:320 github.com/seknox/trasa/server/initdb.storeDefaultSecRules pq: duplicate key value violates unique constraint "unique_secrule" 
TRAC[2020-11-11T21:00:55+05:45]initdb/init.go:320 github.com/seknox/trasa/server/initdb.storeDefaultSecRules pq: duplicate key value violates unique constraint "unique_secrule" 
TRAC[2020-11-11T21:00:55+05:45]initdb/init.go:320 github.com/seknox/trasa/server/initdb.storeDefaultSecRules pq: duplicate key value violates unique constraint "unique_secrule" 
TRAC[2020-11-11T21:00:55+05:45]initdb/init.go:320 github.com/seknox/trasa/server/initdb.storeDefaultSecRules pq: duplicate key value violates unique constraint "unique_secrule" 
TRAC[2020-11-11T21:00:55+05:45]initdb/init.go:320 github.com/seknox/trasa/server/initdb.storeDefaultSecRules pq: duplicate key value violates unique constraint "unique_secrule" 
TRAC[2020-11-11T21:00:55+05:45]initdb/init.go:320 github.com/seknox/trasa/server/initdb.storeDefaultSecRules pq: duplicate key value violates unique constraint "unique_secrule" 
TRAC[2020-11-11T21:00:55+05:45]initdb/init.go:320 github.com/seknox/trasa/server/initdb.storeDefaultSecRules pq: duplicate key value violates unique constraint "unique_secrule" 
TRAC[2020-11-11T21:00:55+05:45]initdb/init.go:320 github.com/seknox/trasa/server/initdb.storeDefaultSecRules pq: duplicate key value violates unique constraint "unique_secrule" 
TRAC[2020-11-11T21:00:55+05:45]initdb/init.go:320 github.com/seknox/trasa/server/initdb.storeDefaultSecRules pq: duplicate key value violates unique constraint "unique_secrule" 
TRAC[2020-11-11T21:00:55+05:45]initdb/init.go:139 github.com/seknox/trasa/server/initdb.storeDeviceHygieneCheck pq: duplicate key value violates unique constraint "unique_globalsettings"