MCPcopy Create free account
hub / github.com/PostHog/duckgres / UpsertManagedWarehouse

Method UpsertManagedWarehouse

controlplane/admin/api.go:330–352  ·  view source on GitHub ↗
(orgID string, warehouse *configstore.ManagedWarehouse)

Source from the content-addressed store, hash-verified

328 err := s.db().Transaction(func(tx *gorm.DB) error {
329 // Serialize with org connection admission (request-owned leases read
330 // org limits under this lock) — see LockOrgConnectionAdmissionTx.
331 if err := configstore.LockOrgConnectionAdmissionTx(tx, name); err != nil {
332 return err
333 }
334 result := tx.Model(&configstore.Org{}).Where("name = ?", name).Updates(fields)
335 if result.Error != nil {
336 return result.Error
337 }
338 found = result.RowsAffected > 0
339 return nil
340 })
341 if err != nil {
342 return nil, false, err
343 }
344 if !found {
345 return nil, false, nil
346 }
347 org, err := s.GetOrg(name)
348 if err != nil {
349 return nil, true, err
350 }
351 return org, true, nil
352}
353
354func (s *gormAPIStore) DeleteOrg(name string) (bool, error) {
355 returnRows := int64(0)

Callers

nothing calls this directly

Calls 6

dbMethod · 0.95
GetManagedWarehouseMethod · 0.95
NowMethod · 0.80
CountMethod · 0.45
CreateMethod · 0.45

Tested by

no test coverage detected