fix: keep setup available without active DingTalk app
This commit is contained in:
@@ -237,14 +237,17 @@ func (r *SettingsRepository) PrepareDingTalkRuntimeStart(ctx context.Context, te
|
||||
return true, tx.Commit(ctx)
|
||||
case "runtime_starting":
|
||||
var oldID string
|
||||
if err = tx.QueryRow(ctx, `SELECT id FROM system_config_revisions WHERE tenant_key=$1 AND kind='dingtalk_app' AND state='retired' AND validation_status='ok' ORDER BY revision DESC LIMIT 1 FOR UPDATE`, tenant).Scan(&oldID); err != nil {
|
||||
err = tx.QueryRow(ctx, `SELECT id FROM system_config_revisions WHERE tenant_key=$1 AND kind='dingtalk_app' AND state='retired' AND validation_status='ok' ORDER BY revision DESC LIMIT 1 FOR UPDATE`, tenant).Scan(&oldID)
|
||||
if err != nil && !errors.Is(err, pgx.ErrNoRows) {
|
||||
return false, err
|
||||
}
|
||||
if _, err = tx.Exec(ctx, `UPDATE system_config_revisions SET state='failed',validation_status='failed',validation_code='runtime_start_failed' WHERE id=$1`, activeID); err != nil {
|
||||
return false, err
|
||||
}
|
||||
if _, err = tx.Exec(ctx, `UPDATE system_config_revisions SET state='active',validation_code='rollback_restored',activated_at=NOW() WHERE id=$1`, oldID); err != nil {
|
||||
return false, err
|
||||
if oldID != "" {
|
||||
if _, err = tx.Exec(ctx, `UPDATE system_config_revisions SET state='active',validation_code='rollback_restored',activated_at=NOW() WHERE id=$1`, oldID); err != nil {
|
||||
return false, err
|
||||
}
|
||||
}
|
||||
return false, tx.Commit(ctx)
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user