ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / lint (pull_request) Successful in 7m0s
ci / test (pull_request) Successful in 12m1s
ci / build (pull_request) Successful in 18m14s
ci / image (pull_request) Successful in 5m9s
Accounts open tickets under Support and admins answer them under Admin → Support tickets. - A ticket is open while it waits for the admins and answered while it waits for the account. Either side can close or reopen it, and a reply reopens it. - The admins are mailed about new tickets and replies, and the account about answers. - A ticket can name the active organization and point at a monitor, notification channel, alert group, status page or incident in it. Each must be something the account can read. - Next to the conversation, admins see the account at a glance: state, sign-in, organizations with their limits and usage, and open tickets. - Admins switch support off and limit how many tickets an account has open at once. - Suspended accounts and those yet to accept the terms reach support too; a suspended account opens one ticket. - Tickets are part of the account export and are deleted with the account. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
52 lines
2.7 KiB
SQL
52 lines
2.7 KiB
SQL
-- +goose Up
|
|
-- Accounts ask the platform's admins for help. A ticket belongs to the
|
|
-- account that opened it, even a suspended one; deleting the account
|
|
-- deletes its tickets. It may point at an organization and things in it
|
|
-- the question is about; deleting those leaves the ticket.
|
|
CREATE TABLE support_tickets (
|
|
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
user_id uuid NOT NULL REFERENCES users (id) ON DELETE CASCADE,
|
|
org_id uuid REFERENCES orgs (id) ON DELETE SET NULL,
|
|
monitor_id uuid REFERENCES monitors (id) ON DELETE SET NULL,
|
|
channel_id uuid REFERENCES notification_channels (id) ON DELETE SET NULL,
|
|
alert_group_id uuid REFERENCES alert_groups (id) ON DELETE SET NULL,
|
|
status_page_id uuid REFERENCES status_pages (id) ON DELETE SET NULL,
|
|
incident_id uuid REFERENCES incidents (id) ON DELETE SET NULL,
|
|
subject text NOT NULL CHECK (length(subject) BETWEEN 1 AND 200),
|
|
-- open waits for the admins, answered for the account.
|
|
status text NOT NULL DEFAULT 'open' CHECK (status IN ('open', 'answered', 'closed')),
|
|
created_at timestamptz NOT NULL DEFAULT now(),
|
|
updated_at timestamptz NOT NULL DEFAULT now()
|
|
);
|
|
CREATE INDEX support_tickets_user_idx ON support_tickets (user_id, updated_at DESC);
|
|
CREATE INDEX support_tickets_status_idx ON support_tickets (status, updated_at DESC);
|
|
|
|
CREATE TABLE support_messages (
|
|
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
ticket_id uuid NOT NULL REFERENCES support_tickets (id) ON DELETE CASCADE,
|
|
-- author_id is empty once the admin who wrote it is deleted.
|
|
author_id uuid REFERENCES users (id) ON DELETE SET NULL,
|
|
from_staff boolean NOT NULL,
|
|
body text NOT NULL CHECK (length(body) BETWEEN 1 AND 10000),
|
|
created_at timestamptz NOT NULL DEFAULT now()
|
|
);
|
|
CREATE INDEX support_messages_ticket_idx ON support_messages (ticket_id, created_at);
|
|
|
|
ALTER TABLE support_tickets ENABLE ROW LEVEL SECURITY;
|
|
ALTER TABLE support_tickets FORCE ROW LEVEL SECURITY;
|
|
CREATE POLICY support_tickets_own ON support_tickets FOR ALL
|
|
USING (app_scope_system() OR user_id = app_user_id())
|
|
WITH CHECK (app_scope_system() OR user_id = app_user_id());
|
|
|
|
ALTER TABLE support_messages ENABLE ROW LEVEL SECURITY;
|
|
ALTER TABLE support_messages FORCE ROW LEVEL SECURITY;
|
|
CREATE POLICY support_messages_own ON support_messages FOR ALL
|
|
USING (app_scope_system() OR EXISTS (
|
|
SELECT 1 FROM support_tickets t WHERE t.id = ticket_id AND t.user_id = app_user_id()))
|
|
WITH CHECK (app_scope_system() OR (NOT from_staff AND EXISTS (
|
|
SELECT 1 FROM support_tickets t WHERE t.id = ticket_id AND t.user_id = app_user_id())));
|
|
|
|
-- +goose Down
|
|
DROP TABLE support_messages;
|
|
DROP TABLE support_tickets;
|