mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 01:10:23 +08:00
fix: align management token oauth permissions and jsonb schema
This commit is contained in:
@@ -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)
|
||||
);
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
ALTER TABLE public.management_tokens
|
||||
DROP CONSTRAINT IF EXISTS check_allowed_ips_not_empty;
|
||||
|
||||
ALTER TABLE public.management_tokens
|
||||
ADD COLUMN IF NOT EXISTS permissions jsonb;
|
||||
|
||||
ALTER TABLE public.management_tokens
|
||||
ALTER COLUMN allowed_ips TYPE jsonb USING allowed_ips::jsonb,
|
||||
ALTER COLUMN permissions TYPE jsonb USING permissions::jsonb;
|
||||
|
||||
ALTER TABLE public.management_tokens
|
||||
ADD 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' THEN jsonb_array_length(allowed_ips) > 0
|
||||
ELSE FALSE
|
||||
END
|
||||
);
|
||||
Reference in New Issue
Block a user