fix: align management token oauth permissions and jsonb schema

This commit is contained in:
Entropy.Xu
2026-05-10 01:47:48 +08:00
parent 4a64d078f3
commit 545299fc62
11 changed files with 308 additions and 21 deletions

View File

@@ -352,7 +352,8 @@ CREATE TABLE IF NOT EXISTS public.management_tokens (
token_prefix character varying(12),
name character varying(100) NOT NULL,
description text,
allowed_ips json,
allowed_ips jsonb,
permissions jsonb,
expires_at timestamp with time zone,
last_used_at timestamp with time zone,
last_used_ip character varying(45),
@@ -360,7 +361,7 @@ CREATE TABLE IF NOT EXISTS public.management_tokens (
is_active boolean DEFAULT true NOT NULL,
created_at timestamp with time zone DEFAULT now() NOT NULL,
updated_at timestamp with time zone DEFAULT now() NOT NULL,
CONSTRAINT check_allowed_ips_not_empty CHECK (((allowed_ips IS NULL) OR ((allowed_ips)::text = 'null'::text) OR (json_array_length(allowed_ips) > 0)))
CONSTRAINT check_allowed_ips_not_empty CHECK (CASE WHEN ((allowed_ips IS NULL) OR (allowed_ips = 'null'::jsonb)) THEN true WHEN (jsonb_typeof(allowed_ips) = 'array'::text) THEN (jsonb_array_length(allowed_ips) > 0) ELSE false END)
);

View File

@@ -351,7 +351,8 @@ CREATE TABLE IF NOT EXISTS public.management_tokens (
token_prefix character varying(12),
name character varying(100) NOT NULL,
description text,
allowed_ips json,
allowed_ips jsonb,
permissions jsonb,
expires_at timestamp with time zone,
last_used_at timestamp with time zone,
last_used_ip character varying(45),
@@ -359,7 +360,7 @@ CREATE TABLE IF NOT EXISTS public.management_tokens (
is_active boolean DEFAULT true NOT NULL,
created_at timestamp with time zone DEFAULT now() NOT NULL,
updated_at timestamp with time zone DEFAULT now() NOT NULL,
CONSTRAINT check_allowed_ips_not_empty CHECK (((allowed_ips IS NULL) OR ((allowed_ips)::text = 'null'::text) OR (json_array_length(allowed_ips) > 0)))
CONSTRAINT check_allowed_ips_not_empty CHECK (CASE WHEN ((allowed_ips IS NULL) OR (allowed_ips = 'null'::jsonb)) THEN true WHEN (jsonb_typeof(allowed_ips) = 'array'::text) THEN (jsonb_array_length(allowed_ips) > 0) ELSE false END)
);