Database Migrations
Migrations are located in supabase/migrations/ and should be applied in order.
Migration Files
| File | Description |
|---|---|
0000_initial_schema.sql | Core tables: projects, documents, spec_uploads, spec_sections, pip_items, matches, building_stories, floor_plans, floor_plan_elements, pip_floor_plan_links, upload_jobs |
0001_rls_policies.sql | RLS policies for all core tables, helper functions (is_admin, pip_ai_check_is_admin) |
0002_spec_uploads.sql | Extended spec upload fields and processing |
0003_building_stories.sql | Building stories table extensions |
0003_spec_sections_extended.sql | Extended spec section fields (keywords, past_pip_requests, vendor, category) |
0005_floor_plan_integration.sql | Floor plan integration: elements, links, annotations, canvas state |
0006_fix_user_profiles_rls.sql | Fix infinite recursion in user profiles RLS |
0007_document_builder.sql | Document builder tables: pages, blocks, templates |
0008_page_orientation.sql | Page orientation support |
0009_document_builder_storage.sql | Document builder storage bucket and policies |
0010_project_images.sql | Project images table for document builder |
0011_nano_banana.sql | AI image generation: image_jobs, image_variants, image_messages |
Additionally, supabase/supabase_migrations.sql contains a consolidated migration file.
Applying Migrations
Via Supabase SQL Editor
- Open the Supabase Dashboard → SQL Editor
- Run each migration file in order (0000 → 0011)
- Verify tables were created in the Table Editor
Via Supabase CLI
bash
supabase db pushVerifying Migrations
After applying all migrations, verify:
sql
SELECT tablename FROM pg_tables
WHERE schemaname = 'public'
AND tablename LIKE 'pip_ai_%'
ORDER BY tablename;Expected output: 15+ tables with the pip_ai_ prefix.