diff --git a/db/migrations/0001_init.down.sql b/db/migrations/0001_init.down.sql index 8fc9fd22..9c2d3298 100644 --- a/db/migrations/0001_init.down.sql +++ b/db/migrations/0001_init.down.sql @@ -15,6 +15,10 @@ DROP TABLE IF EXISTS bot_preauth_keys; DROP TABLE IF EXISTS bot_channel_configs; DROP TABLE IF EXISTS mcp_connections; DROP TABLE IF EXISTS bot_members; +DROP TABLE IF EXISTS email_outbox; +DROP TABLE IF EXISTS bot_email_bindings; +DROP TABLE IF EXISTS email_oauth_tokens; +DROP TABLE IF EXISTS email_providers; DROP TABLE IF EXISTS bots; DROP TABLE IF EXISTS memory_providers; DROP TABLE IF EXISTS model_variants; diff --git a/db/migrations/0001_init.up.sql b/db/migrations/0001_init.up.sql index 84cd276a..af5a3ad0 100644 --- a/db/migrations/0001_init.up.sql +++ b/db/migrations/0001_init.up.sql @@ -492,6 +492,22 @@ CREATE TABLE IF NOT EXISTS email_providers ( CONSTRAINT email_providers_name_unique UNIQUE (name) ); +-- email_oauth_tokens: stored OAuth2 tokens for Gmail email providers +CREATE TABLE IF NOT EXISTS email_oauth_tokens ( + id UUID PRIMARY KEY DEFAULT gen_random_uuid(), + email_provider_id UUID NOT NULL UNIQUE REFERENCES email_providers(id) ON DELETE CASCADE, + email_address TEXT NOT NULL DEFAULT '', + access_token TEXT NOT NULL DEFAULT '', + refresh_token TEXT NOT NULL DEFAULT '', + expires_at TIMESTAMPTZ, + scope TEXT NOT NULL DEFAULT '', + state TEXT NOT NULL DEFAULT '', + created_at TIMESTAMPTZ NOT NULL DEFAULT now(), + updated_at TIMESTAMPTZ NOT NULL DEFAULT now() +); + +CREATE INDEX IF NOT EXISTS idx_email_oauth_tokens_state ON email_oauth_tokens(state) WHERE state != ''; + -- bot_email_bindings: per-bot email provider binding with read/write/delete permissions CREATE TABLE IF NOT EXISTS bot_email_bindings ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(),