Skip to content

[SaaS #6] Schema + settings UI: custom domain column, SMTP prep, slug preview update #94

@macwilling

Description

@macwilling

Overview

Two parts: (1) a database migration adding new columns to prepare for future custom domains and custom SMTP per tenant, and (2) updating the Tenant Slug settings form to display the new subdomain-based URL format.

Part 1: Database Migration

New file: supabase/migrations/20260303000010_saas_infrastructure.sql

tenants table

ALTER TABLE tenants
  ADD COLUMN custom_domain TEXT UNIQUE; -- future: bring-your-own-domain (e.g. portal.theirbiz.com)

RLS: same as existing tenants policies (service role only / admin write).

tenant_settings table

ALTER TABLE tenant_settings
  ADD COLUMN smtp_host       TEXT,
  ADD COLUMN smtp_port       INTEGER,
  ADD COLUMN smtp_username   TEXT,
  ADD COLUMN smtp_password   TEXT,    -- store encrypted (pgcrypto AES or Vault in future)
  ADD COLUMN smtp_from_email TEXT,    -- e.g. hello@theircustom.com
  ADD COLUMN smtp_from_name  TEXT;    -- e.g. "Acme Co"

All columns nullable — when null, app falls back to shared Resend + taskflow.com sending domain.

Update docs/schema-reference.md to document the new columns.

Part 2: Settings UI Updates

components/settings/TenantSlugForm.tsx

The form currently shows: {appUrl}/portal/{slug}

Update to show both URLs:

Admin app:      https://{slug}.taskflow.com
Client portal:  https://{slug}.taskflow.com/portal
  • Remove appUrl prop (no longer passed from parent)
  • Read NEXT_PUBLIC_BASE_DOMAIN directly: process.env.NEXT_PUBLIC_BASE_DOMAIN ?? "localhost:3000"
  • Update the warning text: "Changing your slug changes your subdomain — update any portal links shared with clients."

app/(admin)/settings/page.tsx

  • Remove const appUrl = process.env.NEXT_PUBLIC_APP_URL ?? "" (line 46)
  • Remove appUrl prop from <TenantSlugForm />

Key Files

  • New: supabase/migrations/20260303000010_saas_infrastructure.sql
  • components/settings/TenantSlugForm.tsx
  • app/(admin)/settings/page.tsx
  • docs/schema-reference.md

Testing

  • Migration applies cleanly: supabase db push succeeds
  • Settings page renders without errors
  • Slug form shows correct subdomain URL preview
  • Changing slug updates the preview correctly
  • npm run build passes

Depends On

Issue #88 (env var NEXT_PUBLIC_BASE_DOMAIN must exist). Can be developed in parallel with #89#93.

Blocks

Nothing — this can land independently, but the SMTP columns will be used in a future custom email issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    saas-migrationTrue multi-tenant SaaS migration

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions