feat(custom-roles): align chatwoot permissions
This commit is contained in:
@@ -84,7 +84,7 @@ CREATE TABLE IF NOT EXISTS custom_roles (
|
||||
account_id INTEGER NOT NULL,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
description TEXT,
|
||||
permissions JSONB NOT NULL DEFAULT '{}',
|
||||
permissions JSONB NOT NULL DEFAULT '[]',
|
||||
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
||||
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
||||
deleted_at TIMESTAMP WITH TIME ZONE
|
||||
@@ -444,4 +444,4 @@ CREATE TABLE IF NOT EXISTS channel_whatsapps (
|
||||
deleted_at TIMESTAMP WITH TIME ZONE
|
||||
);
|
||||
|
||||
CREATE INDEX idx_channel_whatsapps_inbox_id ON channel_whatsapps(inbox_id) WHERE deleted_at IS NULL;
|
||||
CREATE INDEX idx_channel_whatsapps_inbox_id ON channel_whatsapps(inbox_id) WHERE deleted_at IS NULL;
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE custom_roles ALTER COLUMN permissions SET DEFAULT '{}'::jsonb;
|
||||
@@ -0,0 +1,7 @@
|
||||
-- Align custom_roles.permissions with Chatwoot custom-role permission arrays.
|
||||
-- Existing legacy JSON maps remain readable in Go code; new writes use arrays.
|
||||
ALTER TABLE custom_roles ALTER COLUMN permissions SET DEFAULT '[]'::jsonb;
|
||||
|
||||
UPDATE custom_roles
|
||||
SET permissions = '[]'::jsonb
|
||||
WHERE permissions IS NULL OR permissions = '{}'::jsonb;
|
||||
Reference in New Issue
Block a user