wulf-pulse/migrations/045_create_zoom_tables.sql
lorentz c518eefdb2 feat: Morning NOC Summary adaptive card for Teams
- Add MorningSummaryService with Zabbix aggregation and adaptive card builder
- Add webhook delivery system with Teams incoming webhooks
- Add admin UI at /admin/morning-summary for webhook/config management
- Add API routes: /send, /test, /webhooks, /webhooks/[id], /config, /history
- Register morning-summary cron job in SyncScheduler (Mon-Fri 6:30 AM)
- Add outages_only filter (Unavailable triggers only)
- Fix host resolution: use getTriggerEnabledHosts to exclude disabled hosts
- Fix resolved events: event.get value:1 scoped to window with r_eventid filter
- Remove emojis from fact rows and section headers in card
- Remove Open Zabbix button (duplicate of View Problems)
- Add migrations: morning_summary_config + morning_summaries tables
- Add outages_only column to morning_summary_config
2026-03-11 09:34:51 -04:00

58 lines
2.1 KiB
SQL

-- Zoom Phone and Meetings Integration Tables
-- Supports cross-referencing with Autotask contacts/companies
CREATE TABLE IF NOT EXISTS zoom_users (
id SERIAL PRIMARY KEY,
zoom_id VARCHAR(255) UNIQUE NOT NULL,
email VARCHAR(255) UNIQUE,
display_name VARCHAR(255),
is_active BOOLEAN DEFAULT true,
synced_at TIMESTAMPTZ DEFAULT NOW()
);
CREATE TABLE IF NOT EXISTS zoom_calls (
id SERIAL PRIMARY KEY,
zoom_call_id VARCHAR(255) UNIQUE NOT NULL,
resource_email VARCHAR(255),
direction VARCHAR(20),
call_status VARCHAR(20),
other_party_number VARCHAR(50),
other_party_name VARCHAR(255),
start_time TIMESTAMPTZ,
duration_seconds INTEGER,
matched_contact_id BIGINT REFERENCES contacts(id),
matched_company_id BIGINT REFERENCES companies(id),
synced_at TIMESTAMPTZ DEFAULT NOW()
);
CREATE TABLE IF NOT EXISTS zoom_meetings (
id SERIAL PRIMARY KEY,
zoom_meeting_id VARCHAR(255) UNIQUE NOT NULL,
zoom_meeting_uuid VARCHAR(500),
host_email VARCHAR(255),
topic VARCHAR(500),
start_time TIMESTAMPTZ,
end_time TIMESTAMPTZ,
duration_minutes INTEGER,
participant_count INTEGER DEFAULT 0,
client_participant_count INTEGER DEFAULT 0,
has_client_attendees BOOLEAN DEFAULT false,
synced_at TIMESTAMPTZ DEFAULT NOW()
);
CREATE TABLE IF NOT EXISTS zoom_meeting_participants (
id SERIAL PRIMARY KEY,
meeting_id INTEGER NOT NULL REFERENCES zoom_meetings(id) ON DELETE CASCADE,
participant_email VARCHAR(255),
participant_name VARCHAR(255),
duration_seconds INTEGER,
matched_contact_id BIGINT REFERENCES contacts(id),
matched_company_id BIGINT REFERENCES companies(id),
is_internal BOOLEAN DEFAULT false,
created_at TIMESTAMPTZ DEFAULT NOW()
);
CREATE INDEX IF NOT EXISTS idx_zoom_calls_resource_email_time ON zoom_calls(resource_email, start_time);
CREATE INDEX IF NOT EXISTS idx_zoom_calls_matched_company ON zoom_calls(matched_company_id);
CREATE INDEX IF NOT EXISTS idx_zoom_meetings_host_email_time ON zoom_meetings(host_email, start_time);
CREATE INDEX IF NOT EXISTS idx_zoom_meeting_participants_email ON zoom_meeting_participants(participant_email);