feat(copilot): complete runtime provider configuration
This commit is contained in:
@@ -77,6 +77,26 @@ func (r *InstallationConfigRepo) UpsertByName(ctx context.Context, name, value s
|
||||
return r.db.WithContext(ctx).Create(&model.InstallationConfig{Name: name, Value: value}).Error
|
||||
}
|
||||
|
||||
// UpsertValues atomically updates a set of stable installation config keys.
|
||||
func (r *InstallationConfigRepo) UpsertValues(ctx context.Context, values map[string]string) error {
|
||||
return r.db.WithContext(ctx).Transaction(func(tx *gorm.DB) error {
|
||||
for name, value := range values {
|
||||
result := tx.Model(&model.InstallationConfig{}).
|
||||
Where("name = ?", name).
|
||||
Update("value", value)
|
||||
if result.Error != nil {
|
||||
return result.Error
|
||||
}
|
||||
if result.RowsAffected == 0 {
|
||||
if err := tx.Create(&model.InstallationConfig{Name: name, Value: value}).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// Delete removes an InstallationConfig record by primary key (soft-delete via Base.DeletedAt).
|
||||
func (r *InstallationConfigRepo) Delete(ctx context.Context, id uint) error {
|
||||
return r.db.WithContext(ctx).Delete(&model.InstallationConfig{}, id).Error
|
||||
|
||||
Reference in New Issue
Block a user