Schema Migration
During BYOK onboarding, NearSync runs a one-time database migration against your Supabase project. This page explains what gets created, how updates work, and what to expect.
One-Time Initial Migration
The initial migration creates the complete NearSync database schema in your Supabase project. This is an automated process that runs during the onboarding call via the client portal Setup tab.
What Gets Created
The migration creates all database tables spanning all NearSync modules:
| Module | Example Tables |
|---|---|
| Authentication & Users | User profiles, roles, permissions, role-permission mappings |
| CRM | Contacts, companies, deals/pipelines, stages, tasks, activities |
| Communications | Email messages, WhatsApp messages, chat threads, templates |
| Finance | Invoices, company expenses, employee expenses, subscriptions, approval workflows |
| HR Management | Employees, departments, leave requests, attendance, payroll |
| Projects | Issues, boards, sprints, time tracking, documents |
| Support | Tickets, SLA configurations, knowledge base articles |
| Marketing | Campaigns, email lists, analytics events |
| Operations | Workflows, automation rules, audit logs |
| AI & Knowledge | Knowledge base entries with vector embeddings, AI configuration |
| Platform | Global settings, system manifest, staff invitations, integration sessions |
Row-Level Security Policies
Every table receives RLS policies during migration. These policies enforce data access rules at the PostgreSQL level, meaning even direct database queries respect your access controls. See Row-Level Security for details on how these policies work.
Database Functions
The migration also creates PostgreSQL functions used by the application:
- Vector similarity search - powers the AI knowledge base with semantic matching
- Aggregation functions - used by dashboards and analytics views
- Trigger functions - handle automated timestamps, status transitions, and cascading updates
Extensions
The migration enables required PostgreSQL extensions:
pgvector- vector similarity search for AI/RAG featurespg_trgm- trigram matching for fuzzy text search- Standard extensions provided by Supabase (uuid, crypto, etc.)
Initial Data Seeding
After schema creation, the migration seeds:
- An initial admin user account (using the email you provide during setup)
- A default system manifest with your organization's configuration
- Default roles and permission sets
Schema Update Process
When NearSync releases database schema changes, the process depends on your deployment model:
NearSync-Managed Deployments (Default)
If NearSync manages your Vercel deployment:
- NearSync notifies you in advance of a scheduled maintenance window
- NearSync applies the migration during that window
- Migrations are provided as incremental SQL diff files (e.g., changes since the last release)
- No action required from you
Client Self-Hosted Deployments (Enterprise)
If you manage your own deployment:
- Migration SQL diff files are provided with each release
- You apply them via the Supabase Dashboard SQL editor or the Supabase CLI
- You choose when to apply updates
Backward Compatibility
- Schema migrations are backward-compatible where possible
- Breaking changes (rare) require coordinated upgrades - NearSync will work with you on timing
- Migration files are idempotent and can be safely re-run
Verification
After the initial migration, you can verify the schema was applied correctly:
- Open the Supabase Dashboard for your project
- Navigate to Table Editor - you should see tenant-scoped tables organized by module
- Navigate to Authentication > Users - your initial admin account should be present
- Check Database > Extensions -
vectorandpg_trgmshould be enabled
Next Steps
- Configure environment variables for your deployment
- Set up Vercel deployment to go live