-
Notifications
You must be signed in to change notification settings - Fork 0
Description
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
appUrlprop (no longer passed from parent) - Read
NEXT_PUBLIC_BASE_DOMAINdirectly: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
appUrlprop from<TenantSlugForm />
Key Files
- New:
supabase/migrations/20260303000010_saas_infrastructure.sql components/settings/TenantSlugForm.tsxapp/(admin)/settings/page.tsxdocs/schema-reference.md
Testing
- Migration applies cleanly:
supabase db pushsucceeds - Settings page renders without errors
- Slug form shows correct subdomain URL preview
- Changing slug updates the preview correctly
npm run buildpasses
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.