48 lines
937 B
SQL
48 lines
937 B
SQL
-- name: InsertLeague :exec
|
|
INSERT INTO leagues (
|
|
id,
|
|
name,
|
|
country_code,
|
|
bet365_id,
|
|
is_active
|
|
) VALUES (
|
|
$1, $2, $3, $4, $5
|
|
)
|
|
ON CONFLICT (id) DO UPDATE
|
|
SET name = EXCLUDED.name,
|
|
country_code = EXCLUDED.country_code,
|
|
bet365_id = EXCLUDED.bet365_id,
|
|
is_active = EXCLUDED.is_active;
|
|
-- name: GetSupportedLeagues :many
|
|
SELECT id,
|
|
name,
|
|
country_code,
|
|
bet365_id,
|
|
is_active
|
|
FROM leagues
|
|
WHERE is_active = true;
|
|
-- name: GetAllLeagues :many
|
|
SELECT id,
|
|
name,
|
|
country_code,
|
|
bet365_id,
|
|
is_active
|
|
FROM leagues;
|
|
-- name: CheckLeagueSupport :one
|
|
SELECT EXISTS(
|
|
SELECT 1
|
|
FROM leagues
|
|
WHERE id = $1
|
|
AND is_active = true
|
|
);
|
|
-- name: UpdateLeague :exec
|
|
UPDATE leagues
|
|
SET name = $1,
|
|
country_code = $2,
|
|
bet365_id = $3,
|
|
is_active = $4
|
|
WHERE id = $5;
|
|
-- name: SetLeagueActive :exec
|
|
UPDATE leagues
|
|
SET is_active = true
|
|
WHERE id = $1; |