feat(ui): add message cache management page and dashboard enhancements
- Introduced MessageCachePage for browsing and managing cached webhook events. - Enhanced DashboardPage to display runtime stats and message cache information. - Added new API types for message cache events and system stats. - Integrated SwaggerPage for API documentation and live request testing.
This commit is contained in:
@@ -51,7 +51,7 @@ CREATE TABLE IF NOT EXISTS public.hooks (
|
||||
user_id varchar(36) NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public.whatsapp_accounts (
|
||||
CREATE TABLE IF NOT EXISTS public.whatsapp_account (
|
||||
account_type varchar(50) NOT NULL,
|
||||
active boolean NOT NULL DEFAULT true,
|
||||
config text,
|
||||
@@ -94,15 +94,18 @@ CREATE TABLE IF NOT EXISTS public.sessions (
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public.message_cache (
|
||||
account_id varchar(36) NOT NULL,
|
||||
chat_id varchar(255) NOT NULL,
|
||||
content text NOT NULL,
|
||||
created_at timestamp NOT NULL DEFAULT now(),
|
||||
from_me boolean NOT NULL,
|
||||
id varchar(36) NOT NULL,
|
||||
message_id varchar(255) NOT NULL,
|
||||
message_type varchar(50) NOT NULL,
|
||||
timestamp timestamp NOT NULL
|
||||
id varchar(128) NOT NULL,
|
||||
account_id varchar(64) NOT NULL DEFAULT '',
|
||||
event_type varchar(100) NOT NULL,
|
||||
event_data jsonb NOT NULL DEFAULT '{}'::jsonb,
|
||||
message_id varchar(255) NOT NULL DEFAULT '',
|
||||
from_number varchar(64) NOT NULL DEFAULT '',
|
||||
to_number varchar(64) NOT NULL DEFAULT '',
|
||||
reason text NOT NULL DEFAULT '',
|
||||
attempts integer NOT NULL DEFAULT 0,
|
||||
timestamp timestamptz NOT NULL DEFAULT now(),
|
||||
last_attempt timestamptz,
|
||||
created_at timestamptz NOT NULL DEFAULT now()
|
||||
);
|
||||
|
||||
-- Add missing columns for schema: public
|
||||
@@ -592,10 +595,10 @@ BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'public'
|
||||
AND table_name = 'whatsapp_accounts'
|
||||
AND table_name = 'whatsapp_account'
|
||||
AND column_name = 'account_type'
|
||||
) THEN
|
||||
ALTER TABLE public.whatsapp_accounts ADD COLUMN account_type varchar(50) NOT NULL;
|
||||
ALTER TABLE public.whatsapp_account ADD COLUMN account_type varchar(50) NOT NULL;
|
||||
END IF;
|
||||
END;
|
||||
$$;
|
||||
@@ -605,10 +608,10 @@ BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'public'
|
||||
AND table_name = 'whatsapp_accounts'
|
||||
AND table_name = 'whatsapp_account'
|
||||
AND column_name = 'active'
|
||||
) THEN
|
||||
ALTER TABLE public.whatsapp_accounts ADD COLUMN active boolean NOT NULL DEFAULT true;
|
||||
ALTER TABLE public.whatsapp_account ADD COLUMN active boolean NOT NULL DEFAULT true;
|
||||
END IF;
|
||||
END;
|
||||
$$;
|
||||
@@ -618,10 +621,10 @@ BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'public'
|
||||
AND table_name = 'whatsapp_accounts'
|
||||
AND table_name = 'whatsapp_account'
|
||||
AND column_name = 'config'
|
||||
) THEN
|
||||
ALTER TABLE public.whatsapp_accounts ADD COLUMN config text;
|
||||
ALTER TABLE public.whatsapp_account ADD COLUMN config text;
|
||||
END IF;
|
||||
END;
|
||||
$$;
|
||||
@@ -631,10 +634,10 @@ BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'public'
|
||||
AND table_name = 'whatsapp_accounts'
|
||||
AND table_name = 'whatsapp_account'
|
||||
AND column_name = 'created_at'
|
||||
) THEN
|
||||
ALTER TABLE public.whatsapp_accounts ADD COLUMN created_at timestamp NOT NULL DEFAULT now();
|
||||
ALTER TABLE public.whatsapp_account ADD COLUMN created_at timestamp NOT NULL DEFAULT now();
|
||||
END IF;
|
||||
END;
|
||||
$$;
|
||||
@@ -644,10 +647,10 @@ BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'public'
|
||||
AND table_name = 'whatsapp_accounts'
|
||||
AND table_name = 'whatsapp_account'
|
||||
AND column_name = 'deleted_at'
|
||||
) THEN
|
||||
ALTER TABLE public.whatsapp_accounts ADD COLUMN deleted_at timestamp;
|
||||
ALTER TABLE public.whatsapp_account ADD COLUMN deleted_at timestamp;
|
||||
END IF;
|
||||
END;
|
||||
$$;
|
||||
@@ -657,10 +660,10 @@ BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'public'
|
||||
AND table_name = 'whatsapp_accounts'
|
||||
AND table_name = 'whatsapp_account'
|
||||
AND column_name = 'display_name'
|
||||
) THEN
|
||||
ALTER TABLE public.whatsapp_accounts ADD COLUMN display_name varchar(255);
|
||||
ALTER TABLE public.whatsapp_account ADD COLUMN display_name varchar(255);
|
||||
END IF;
|
||||
END;
|
||||
$$;
|
||||
@@ -670,10 +673,10 @@ BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'public'
|
||||
AND table_name = 'whatsapp_accounts'
|
||||
AND table_name = 'whatsapp_account'
|
||||
AND column_name = 'id'
|
||||
) THEN
|
||||
ALTER TABLE public.whatsapp_accounts ADD COLUMN id varchar(36) NOT NULL;
|
||||
ALTER TABLE public.whatsapp_account ADD COLUMN id varchar(36) NOT NULL;
|
||||
END IF;
|
||||
END;
|
||||
$$;
|
||||
@@ -683,10 +686,10 @@ BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'public'
|
||||
AND table_name = 'whatsapp_accounts'
|
||||
AND table_name = 'whatsapp_account'
|
||||
AND column_name = 'last_connected_at'
|
||||
) THEN
|
||||
ALTER TABLE public.whatsapp_accounts ADD COLUMN last_connected_at timestamp;
|
||||
ALTER TABLE public.whatsapp_account ADD COLUMN last_connected_at timestamp;
|
||||
END IF;
|
||||
END;
|
||||
$$;
|
||||
@@ -696,10 +699,10 @@ BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'public'
|
||||
AND table_name = 'whatsapp_accounts'
|
||||
AND table_name = 'whatsapp_account'
|
||||
AND column_name = 'phone_number'
|
||||
) THEN
|
||||
ALTER TABLE public.whatsapp_accounts ADD COLUMN phone_number varchar(50) NOT NULL;
|
||||
ALTER TABLE public.whatsapp_account ADD COLUMN phone_number varchar(50) NOT NULL;
|
||||
END IF;
|
||||
END;
|
||||
$$;
|
||||
@@ -709,10 +712,10 @@ BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'public'
|
||||
AND table_name = 'whatsapp_accounts'
|
||||
AND table_name = 'whatsapp_account'
|
||||
AND column_name = 'session_path'
|
||||
) THEN
|
||||
ALTER TABLE public.whatsapp_accounts ADD COLUMN session_path text;
|
||||
ALTER TABLE public.whatsapp_account ADD COLUMN session_path text;
|
||||
END IF;
|
||||
END;
|
||||
$$;
|
||||
@@ -722,10 +725,10 @@ BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'public'
|
||||
AND table_name = 'whatsapp_accounts'
|
||||
AND table_name = 'whatsapp_account'
|
||||
AND column_name = 'status'
|
||||
) THEN
|
||||
ALTER TABLE public.whatsapp_accounts ADD COLUMN status varchar(50) NOT NULL DEFAULT 'disconnected';
|
||||
ALTER TABLE public.whatsapp_account ADD COLUMN status varchar(50) NOT NULL DEFAULT 'disconnected';
|
||||
END IF;
|
||||
END;
|
||||
$$;
|
||||
@@ -735,10 +738,10 @@ BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'public'
|
||||
AND table_name = 'whatsapp_accounts'
|
||||
AND table_name = 'whatsapp_account'
|
||||
AND column_name = 'updated_at'
|
||||
) THEN
|
||||
ALTER TABLE public.whatsapp_accounts ADD COLUMN updated_at timestamp NOT NULL DEFAULT now();
|
||||
ALTER TABLE public.whatsapp_account ADD COLUMN updated_at timestamp NOT NULL DEFAULT now();
|
||||
END IF;
|
||||
END;
|
||||
$$;
|
||||
@@ -748,10 +751,10 @@ BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'public'
|
||||
AND table_name = 'whatsapp_accounts'
|
||||
AND table_name = 'whatsapp_account'
|
||||
AND column_name = 'user_id'
|
||||
) THEN
|
||||
ALTER TABLE public.whatsapp_accounts ADD COLUMN user_id varchar(36) NOT NULL;
|
||||
ALTER TABLE public.whatsapp_account ADD COLUMN user_id varchar(36) NOT NULL;
|
||||
END IF;
|
||||
END;
|
||||
$$;
|
||||
@@ -1016,71 +1019,6 @@ BEGIN
|
||||
END;
|
||||
$$;
|
||||
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'public'
|
||||
AND table_name = 'message_cache'
|
||||
AND column_name = 'account_id'
|
||||
) THEN
|
||||
ALTER TABLE public.message_cache ADD COLUMN account_id varchar(36) NOT NULL;
|
||||
END IF;
|
||||
END;
|
||||
$$;
|
||||
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'public'
|
||||
AND table_name = 'message_cache'
|
||||
AND column_name = 'chat_id'
|
||||
) THEN
|
||||
ALTER TABLE public.message_cache ADD COLUMN chat_id varchar(255) NOT NULL;
|
||||
END IF;
|
||||
END;
|
||||
$$;
|
||||
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'public'
|
||||
AND table_name = 'message_cache'
|
||||
AND column_name = 'content'
|
||||
) THEN
|
||||
ALTER TABLE public.message_cache ADD COLUMN content text NOT NULL;
|
||||
END IF;
|
||||
END;
|
||||
$$;
|
||||
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'public'
|
||||
AND table_name = 'message_cache'
|
||||
AND column_name = 'created_at'
|
||||
) THEN
|
||||
ALTER TABLE public.message_cache ADD COLUMN created_at timestamp NOT NULL DEFAULT now();
|
||||
END IF;
|
||||
END;
|
||||
$$;
|
||||
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'public'
|
||||
AND table_name = 'message_cache'
|
||||
AND column_name = 'from_me'
|
||||
) THEN
|
||||
ALTER TABLE public.message_cache ADD COLUMN from_me boolean NOT NULL;
|
||||
END IF;
|
||||
END;
|
||||
$$;
|
||||
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
@@ -1089,7 +1027,46 @@ BEGIN
|
||||
AND table_name = 'message_cache'
|
||||
AND column_name = 'id'
|
||||
) THEN
|
||||
ALTER TABLE public.message_cache ADD COLUMN id varchar(36) NOT NULL;
|
||||
ALTER TABLE public.message_cache ADD COLUMN id varchar(128) NOT NULL;
|
||||
END IF;
|
||||
END;
|
||||
$$;
|
||||
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'public'
|
||||
AND table_name = 'message_cache'
|
||||
AND column_name = 'account_id'
|
||||
) THEN
|
||||
ALTER TABLE public.message_cache ADD COLUMN account_id varchar(64) NOT NULL DEFAULT '';
|
||||
END IF;
|
||||
END;
|
||||
$$;
|
||||
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'public'
|
||||
AND table_name = 'message_cache'
|
||||
AND column_name = 'event_type'
|
||||
) THEN
|
||||
ALTER TABLE public.message_cache ADD COLUMN event_type varchar(100) NOT NULL DEFAULT '';
|
||||
END IF;
|
||||
END;
|
||||
$$;
|
||||
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'public'
|
||||
AND table_name = 'message_cache'
|
||||
AND column_name = 'event_data'
|
||||
) THEN
|
||||
ALTER TABLE public.message_cache ADD COLUMN event_data jsonb NOT NULL DEFAULT '{}'::jsonb;
|
||||
END IF;
|
||||
END;
|
||||
$$;
|
||||
@@ -1102,7 +1079,7 @@ BEGIN
|
||||
AND table_name = 'message_cache'
|
||||
AND column_name = 'message_id'
|
||||
) THEN
|
||||
ALTER TABLE public.message_cache ADD COLUMN message_id varchar(255) NOT NULL;
|
||||
ALTER TABLE public.message_cache ADD COLUMN message_id varchar(255) NOT NULL DEFAULT '';
|
||||
END IF;
|
||||
END;
|
||||
$$;
|
||||
@@ -1113,9 +1090,48 @@ BEGIN
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'public'
|
||||
AND table_name = 'message_cache'
|
||||
AND column_name = 'message_type'
|
||||
AND column_name = 'from_number'
|
||||
) THEN
|
||||
ALTER TABLE public.message_cache ADD COLUMN message_type varchar(50) NOT NULL;
|
||||
ALTER TABLE public.message_cache ADD COLUMN from_number varchar(64) NOT NULL DEFAULT '';
|
||||
END IF;
|
||||
END;
|
||||
$$;
|
||||
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'public'
|
||||
AND table_name = 'message_cache'
|
||||
AND column_name = 'to_number'
|
||||
) THEN
|
||||
ALTER TABLE public.message_cache ADD COLUMN to_number varchar(64) NOT NULL DEFAULT '';
|
||||
END IF;
|
||||
END;
|
||||
$$;
|
||||
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'public'
|
||||
AND table_name = 'message_cache'
|
||||
AND column_name = 'reason'
|
||||
) THEN
|
||||
ALTER TABLE public.message_cache ADD COLUMN reason text NOT NULL DEFAULT '';
|
||||
END IF;
|
||||
END;
|
||||
$$;
|
||||
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'public'
|
||||
AND table_name = 'message_cache'
|
||||
AND column_name = 'attempts'
|
||||
) THEN
|
||||
ALTER TABLE public.message_cache ADD COLUMN attempts integer NOT NULL DEFAULT 0;
|
||||
END IF;
|
||||
END;
|
||||
$$;
|
||||
@@ -1128,7 +1144,33 @@ BEGIN
|
||||
AND table_name = 'message_cache'
|
||||
AND column_name = 'timestamp'
|
||||
) THEN
|
||||
ALTER TABLE public.message_cache ADD COLUMN timestamp timestamp NOT NULL;
|
||||
ALTER TABLE public.message_cache ADD COLUMN timestamp timestamptz NOT NULL DEFAULT now();
|
||||
END IF;
|
||||
END;
|
||||
$$;
|
||||
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'public'
|
||||
AND table_name = 'message_cache'
|
||||
AND column_name = 'last_attempt'
|
||||
) THEN
|
||||
ALTER TABLE public.message_cache ADD COLUMN last_attempt timestamptz;
|
||||
END IF;
|
||||
END;
|
||||
$$;
|
||||
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'public'
|
||||
AND table_name = 'message_cache'
|
||||
AND column_name = 'created_at'
|
||||
) THEN
|
||||
ALTER TABLE public.message_cache ADD COLUMN created_at timestamptz NOT NULL DEFAULT now();
|
||||
END IF;
|
||||
END;
|
||||
$$;
|
||||
@@ -1226,22 +1268,22 @@ BEGIN
|
||||
SELECT constraint_name INTO auto_pk_name
|
||||
FROM information_schema.table_constraints
|
||||
WHERE table_schema = 'public'
|
||||
AND table_name = 'whatsapp_accounts'
|
||||
AND table_name = 'whatsapp_account'
|
||||
AND constraint_type = 'PRIMARY KEY'
|
||||
AND constraint_name IN ('whatsapp_accounts_pkey', 'public_whatsapp_accounts_pkey');
|
||||
AND constraint_name IN ('whatsapp_account_pkey', 'public_whatsapp_account_pkey');
|
||||
|
||||
IF auto_pk_name IS NOT NULL THEN
|
||||
EXECUTE 'ALTER TABLE public.whatsapp_accounts DROP CONSTRAINT ' || quote_ident(auto_pk_name);
|
||||
EXECUTE 'ALTER TABLE public.whatsapp_account DROP CONSTRAINT ' || quote_ident(auto_pk_name);
|
||||
END IF;
|
||||
|
||||
-- Add named primary key if it doesn't exist
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.table_constraints
|
||||
WHERE table_schema = 'public'
|
||||
AND table_name = 'whatsapp_accounts'
|
||||
AND constraint_name = 'pk_public_whatsapp_accounts'
|
||||
AND table_name = 'whatsapp_account'
|
||||
AND constraint_name = 'pk_public_whatsapp_account'
|
||||
) THEN
|
||||
ALTER TABLE public.whatsapp_accounts ADD CONSTRAINT pk_public_whatsapp_accounts PRIMARY KEY (id);
|
||||
ALTER TABLE public.whatsapp_account ADD CONSTRAINT pk_public_whatsapp_account PRIMARY KEY (id);
|
||||
END IF;
|
||||
END;
|
||||
$$;
|
||||
@@ -1346,11 +1388,11 @@ CREATE INDEX IF NOT EXISTS idx_hooks_deleted_at
|
||||
CREATE INDEX IF NOT EXISTS idx_hooks_user_id
|
||||
ON public.hooks USING btree (user_id);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_whatsapp_accounts_deleted_at
|
||||
ON public.whatsapp_accounts USING btree (deleted_at);
|
||||
CREATE INDEX IF NOT EXISTS idx_whatsapp_account_deleted_at
|
||||
ON public.whatsapp_account USING btree (deleted_at);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_whatsapp_accounts_user_id
|
||||
ON public.whatsapp_accounts USING btree (user_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_whatsapp_account_user_id
|
||||
ON public.whatsapp_account USING btree (user_id);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_event_logs_created_at
|
||||
ON public.event_logs USING btree (created_at);
|
||||
@@ -1373,17 +1415,11 @@ CREATE INDEX IF NOT EXISTS idx_sessions_expires_at
|
||||
CREATE INDEX IF NOT EXISTS idx_sessions_user_id
|
||||
ON public.sessions USING btree (user_id);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_message_cache_account_id
|
||||
ON public.message_cache USING btree (account_id);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_message_cache_chat_id
|
||||
ON public.message_cache USING btree (chat_id);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_message_cache_from_me
|
||||
ON public.message_cache USING btree (from_me);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_message_cache_timestamp
|
||||
ON public.message_cache USING btree (timestamp);
|
||||
ON public.message_cache USING btree (timestamp DESC);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_message_cache_event_type
|
||||
ON public.message_cache USING btree (event_type);
|
||||
|
||||
-- Unique constraints for schema: public
|
||||
DO $$
|
||||
@@ -1430,10 +1466,10 @@ BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.table_constraints
|
||||
WHERE table_schema = 'public'
|
||||
AND table_name = 'whatsapp_accounts'
|
||||
AND constraint_name = 'ukey_whatsapp_accounts_phone_number'
|
||||
AND table_name = 'whatsapp_account'
|
||||
AND constraint_name = 'ukey_whatsapp_account_phone_number'
|
||||
) THEN
|
||||
ALTER TABLE public.whatsapp_accounts ADD CONSTRAINT ukey_whatsapp_accounts_phone_number UNIQUE (phone_number);
|
||||
ALTER TABLE public.whatsapp_account ADD CONSTRAINT ukey_whatsapp_account_phone_number UNIQUE (phone_number);
|
||||
END IF;
|
||||
END;
|
||||
$$;
|
||||
@@ -1451,19 +1487,6 @@ BEGIN
|
||||
END;
|
||||
$$;
|
||||
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.table_constraints
|
||||
WHERE table_schema = 'public'
|
||||
AND table_name = 'message_cache'
|
||||
AND constraint_name = 'ukey_message_cache_message_id'
|
||||
) THEN
|
||||
ALTER TABLE public.message_cache ADD CONSTRAINT ukey_message_cache_message_id UNIQUE (message_id);
|
||||
END IF;
|
||||
END;
|
||||
$$;
|
||||
|
||||
-- Check constraints for schema: public
|
||||
-- Foreign keys for schema: public
|
||||
DO $$
|
||||
@@ -1503,11 +1526,11 @@ BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.table_constraints
|
||||
WHERE table_schema = 'public'
|
||||
AND table_name = 'whatsapp_accounts'
|
||||
AND constraint_name = 'fk_whatsapp_accounts_user_id'
|
||||
AND table_name = 'whatsapp_account'
|
||||
AND constraint_name = 'fk_whatsapp_account_user_id'
|
||||
) THEN
|
||||
ALTER TABLE public.whatsapp_accounts
|
||||
ADD CONSTRAINT fk_whatsapp_accounts_user_id
|
||||
ALTER TABLE public.whatsapp_account
|
||||
ADD CONSTRAINT fk_whatsapp_account_user_id
|
||||
FOREIGN KEY (user_id)
|
||||
REFERENCES public.users (id)
|
||||
ON DELETE NO ACTION
|
||||
@@ -1554,4 +1577,3 @@ $$;-- Set sequence values for schema: public
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user