Make tls_enabled key migratin idempotent.

This commit is contained in:
Kailash Nadh 2022-01-04 22:30:43 +05:30
parent 583dab4bc6
commit d8ed40422e

View file

@ -29,7 +29,7 @@ func V2_1_0(db *sqlx.DB, fs stuffbin.FileSystem, ko *koanf.Koanf) error {
SELECT JSONB_AGG( SELECT JSONB_AGG(
JSONB_SET(v - 'tls_enabled', '{tls_type}', (CASE WHEN v->>'tls_enabled' = 'true' THEN '"STARTTLS"' ELSE '"none"' END)::JSONB) JSONB_SET(v - 'tls_enabled', '{tls_type}', (CASE WHEN v->>'tls_enabled' = 'true' THEN '"STARTTLS"' ELSE '"none"' END)::JSONB)
) AS updated FROM settings, JSONB_ARRAY_ELEMENTS(value) v WHERE key = 'smtp' ) AS updated FROM settings, JSONB_ARRAY_ELEMENTS(value) v WHERE key = 'smtp'
) s WHERE key = 'smtp'; ) s WHERE key = 'smtp' AND value::TEXT LIKE '%tls_enabled%';
`); err != nil { `); err != nil {
return err return err
} }