| 400 | } |
| 401 | |
| 402 | func (ds *SQLStore) RemoveApp(ctx context.Context, appID string) error { |
| 403 | return ds.Tx(func(tx *sqlx.Tx) error { |
| 404 | res, err := tx.ExecContext(ctx, tx.Rebind(`DELETE FROM apps WHERE id=?`), appID) |
| 405 | if err != nil { |
| 406 | return err |
| 407 | } |
| 408 | n, err := res.RowsAffected() |
| 409 | if err != nil { |
| 410 | return err |
| 411 | } |
| 412 | if n == 0 { |
| 413 | return models.ErrAppsNotFound |
| 414 | } |
| 415 | |
| 416 | deletes := []string{ |
| 417 | `DELETE FROM fns WHERE app_id=?`, |
| 418 | `DELETE FROM triggers WHERE app_id=?`, |
| 419 | } |
| 420 | for _, stmt := range deletes { |
| 421 | _, err := tx.ExecContext(ctx, tx.Rebind(stmt), appID) |
| 422 | if err != nil { |
| 423 | return err |
| 424 | } |
| 425 | } |
| 426 | |
| 427 | return nil |
| 428 | }) |
| 429 | } |
| 430 | |
| 431 | func (ds *SQLStore) GetAppByID(ctx context.Context, appID string) (*models.App, error) { |
| 432 | var app models.App |