31 lines
1.4 KiB
MySQL
31 lines
1.4 KiB
MySQL
|
|
-- Central, encrypted configuration for the mailbox BMC Hub reads and sends from.
|
||
|
|
-- Secrets are stored as a Fernet-encrypted JSON blob and are never returned by the API.
|
||
|
|
CREATE TABLE IF NOT EXISTS email_connection_configurations (
|
||
|
|
id SERIAL PRIMARY KEY,
|
||
|
|
provider VARCHAR(30) NOT NULL CHECK (provider IN ('microsoft365_graph', 'imap_smtp')),
|
||
|
|
is_enabled BOOLEAN NOT NULL DEFAULT false,
|
||
|
|
mailbox_address VARCHAR(320) NOT NULL,
|
||
|
|
sender_name VARCHAR(255) NOT NULL DEFAULT 'BMC Hub',
|
||
|
|
imap_host VARCHAR(255),
|
||
|
|
imap_port INTEGER NOT NULL DEFAULT 993,
|
||
|
|
imap_folder VARCHAR(255) NOT NULL DEFAULT 'INBOX',
|
||
|
|
imap_use_ssl BOOLEAN NOT NULL DEFAULT true,
|
||
|
|
smtp_host VARCHAR(255),
|
||
|
|
smtp_port INTEGER NOT NULL DEFAULT 587,
|
||
|
|
smtp_use_tls BOOLEAN NOT NULL DEFAULT true,
|
||
|
|
graph_tenant_id VARCHAR(255),
|
||
|
|
graph_client_id VARCHAR(255),
|
||
|
|
secrets_encrypted TEXT,
|
||
|
|
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||
|
|
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||
|
|
updated_by_user_id INTEGER
|
||
|
|
);
|
||
|
|
|
||
|
|
CREATE UNIQUE INDEX IF NOT EXISTS idx_email_connection_singleton
|
||
|
|
ON email_connection_configurations ((1));
|
||
|
|
|
||
|
|
DROP TRIGGER IF EXISTS email_connection_configurations_updated_at_trigger ON email_connection_configurations;
|
||
|
|
CREATE TRIGGER email_connection_configurations_updated_at_trigger
|
||
|
|
BEFORE UPDATE ON email_connection_configurations
|
||
|
|
FOR EACH ROW EXECUTE FUNCTION update_settings_updated_at();
|