Initial commit of Descrybe v2 without local scratch artifacts.
Drop one-shot tmp/axe scripts and agent i18n scratch so the Gitea tree is deployable.
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
-- +goose Up
|
||||
-- Support desk: resolver attribution, CSAT storage (ratings API by sibling agent),
|
||||
-- unassigned queue index, expanded notification kinds.
|
||||
-- Staff capability uses users.staff_role=support_staff (029_staff_roles).
|
||||
|
||||
ALTER TABLE support_tickets
|
||||
ADD COLUMN IF NOT EXISTS resolved_by_user_id UUID REFERENCES users(id) ON DELETE SET NULL,
|
||||
ADD COLUMN IF NOT EXISTS csat_token_hash BYTEA,
|
||||
ADD COLUMN IF NOT EXISTS csat_invite_sent_at TIMESTAMPTZ;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS support_tickets_unassigned_queue_idx
|
||||
ON support_tickets (status, last_message_at DESC NULLS LAST)
|
||||
WHERE assignee_admin_user_id IS NULL;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS support_tickets_resolved_by_idx
|
||||
ON support_tickets (resolved_by_user_id)
|
||||
WHERE resolved_by_user_id IS NOT NULL;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS support_csat_ratings (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
ticket_id UUID NOT NULL UNIQUE REFERENCES support_tickets(id) ON DELETE CASCADE,
|
||||
company_id UUID NOT NULL REFERENCES companies(id) ON DELETE CASCADE,
|
||||
user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||
score SMALLINT NOT NULL CHECK (score BETWEEN 1 AND 5),
|
||||
comment TEXT NOT NULL DEFAULT '',
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS support_csat_ratings_created_idx
|
||||
ON support_csat_ratings (created_at DESC);
|
||||
|
||||
ALTER TABLE support_notifications
|
||||
DROP CONSTRAINT IF EXISTS support_notifications_kind_check;
|
||||
|
||||
ALTER TABLE support_notifications
|
||||
ADD CONSTRAINT support_notifications_kind_check
|
||||
CHECK (kind IN (
|
||||
'ticket_created',
|
||||
'agent_reply',
|
||||
'status_changed',
|
||||
'user_reply',
|
||||
'ticket_claimed',
|
||||
'csat_requested'
|
||||
));
|
||||
|
||||
-- +goose Down
|
||||
ALTER TABLE support_notifications DROP CONSTRAINT IF EXISTS support_notifications_kind_check;
|
||||
ALTER TABLE support_notifications
|
||||
ADD CONSTRAINT support_notifications_kind_check
|
||||
CHECK (kind IN ('ticket_created', 'agent_reply', 'status_changed', 'user_reply'));
|
||||
|
||||
DROP INDEX IF EXISTS support_csat_ratings_created_idx;
|
||||
DROP TABLE IF EXISTS support_csat_ratings;
|
||||
DROP INDEX IF EXISTS support_tickets_resolved_by_idx;
|
||||
DROP INDEX IF EXISTS support_tickets_unassigned_queue_idx;
|
||||
|
||||
ALTER TABLE support_tickets
|
||||
DROP COLUMN IF EXISTS csat_invite_sent_at,
|
||||
DROP COLUMN IF EXISTS csat_token_hash,
|
||||
DROP COLUMN IF EXISTS resolved_by_user_id;
|
||||
Reference in New Issue
Block a user