CountServerVersions counts the number of versions for a server
(ctx context.Context, tx pgx.Tx, serverName string)
| 847 | |
| 848 | // CountServerVersions counts the number of versions for a server |
| 849 | func (db *PostgreSQL) CountServerVersions(ctx context.Context, tx pgx.Tx, serverName string) (int, error) { |
| 850 | if ctx.Err() != nil { |
| 851 | return 0, ctx.Err() |
| 852 | } |
| 853 | |
| 854 | executor := db.getExecutor(tx) |
| 855 | |
| 856 | query := `SELECT COUNT(*) FROM servers WHERE server_name = $1` |
| 857 | |
| 858 | var count int |
| 859 | err := executor.QueryRow(ctx, query, serverName).Scan(&count) |
| 860 | if err != nil { |
| 861 | return 0, fmt.Errorf("failed to count server versions: %w", err) |
| 862 | } |
| 863 | |
| 864 | return count, nil |
| 865 | } |
| 866 | |
| 867 | // CheckVersionExists checks if a specific version exists for a server |
| 868 | func (db *PostgreSQL) CheckVersionExists(ctx context.Context, tx pgx.Tx, serverName, version string) (bool, error) { |
nothing calls this directly
no test coverage detected