-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: upload supabase migration (#389)
- 更新函数
- Loading branch information
Showing
1 changed file
with
20 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
migrations/supabase/migrations/20240913114522_remote_schema.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
alter table "public"."bots" alter column "token_id" set default ''::text; | ||
|
||
set check_function_bodies = off; | ||
|
||
CREATE OR REPLACE FUNCTION public.get_bot_stats(filter_bot_id text) | ||
RETURNS TABLE(call_cnt bigint) | ||
LANGUAGE plpgsql | ||
AS $function$ | ||
BEGIN | ||
RETURN QUERY | ||
SELECT | ||
COUNT(1)::BIGINT AS call_cnt | ||
FROM user_token_usage u | ||
WHERE u.bot_id = filter_bot_id -- 使用别名来引用参数 | ||
GROUP BY u.bot_id; | ||
END; | ||
$function$ | ||
; | ||
|
||
|