Skip to content

Database Migrations

Migrations are located in supabase/migrations/ and should be applied in order.

Migration Files

FileDescription
0000_initial_schema.sqlCore 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.sqlRLS policies for all core tables, helper functions (is_admin, pip_ai_check_is_admin)
0002_spec_uploads.sqlExtended spec upload fields and processing
0003_building_stories.sqlBuilding stories table extensions
0003_spec_sections_extended.sqlExtended spec section fields (keywords, past_pip_requests, vendor, category)
0005_floor_plan_integration.sqlFloor plan integration: elements, links, annotations, canvas state
0006_fix_user_profiles_rls.sqlFix infinite recursion in user profiles RLS
0007_document_builder.sqlDocument builder tables: pages, blocks, templates
0008_page_orientation.sqlPage orientation support
0009_document_builder_storage.sqlDocument builder storage bucket and policies
0010_project_images.sqlProject images table for document builder
0011_nano_banana.sqlAI image generation: image_jobs, image_variants, image_messages

Additionally, supabase/supabase_migrations.sql contains a consolidated migration file.

Applying Migrations

Via Supabase SQL Editor

  1. Open the Supabase Dashboard → SQL Editor
  2. Run each migration file in order (0000 → 0011)
  3. Verify tables were created in the Table Editor

Via Supabase CLI

bash
supabase db push

Verifying 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.

Built with VitePress