- Updated ExperimentForm to handle additional phase parameters and improved initial state management. - Modified ExperimentModal to fetch experiment data with phase configuration and ensure unique experiment numbers within the same phase. - Renamed references from "phases" to "books" across ExperimentPhases, PhaseExperiments, and related components for consistency with the new terminology. - Enhanced error handling and validation for new shelling parameters in ExperimentForm. - Updated Supabase interface definitions to reflect changes in experiment and phase data structures.
3.1 KiB
Supabase Database Module
This directory contains all Supabase configuration, migrations, and seed data for the USDA Vision project.
Structure
supabase/
├── config.toml # Supabase CLI configuration
├── migrations/ # Database migration files (run in order)
│ ├── 00001_extensions_and_utilities.sql
│ ├── 00002_users_and_roles.sql
│ └── ...
├── seed_01_users.sql # Initial user data
└── seed_02_phase2_experiments.sql # Initial experiment data
Usage
With Docker Compose (Recommended)
The Supabase containers are managed by the main docker-compose.yml at the project root. Migrations and seeds are automatically run on startup.
# From project root
docker compose up -d
With Supabase CLI
If you need to use Supabase CLI commands, run them from the project root (this directory's parent):
# From project root
cd /path/to/USDA-VISION
# Start Supabase (if not using docker-compose)
supabase start
# Run migrations manually
supabase db reset
# Generate types
supabase gen types typescript --local > management-dashboard-web-app/src/types/supabase.ts
Note: The Supabase CLI looks for the supabase/ directory in the current working directory. Since we've moved it to the root, you can now run Supabase commands from the project root instead of needing to cd into management-dashboard-web-app.
Migration Workflow
-
Create a new migration:
supabase migration new migration_name -
Apply migrations:
- Automatically via docker-compose on startup
- Manually:
supabase db reset(from project root)
-
Check migration status:
supabase migration list
Seed Data
Seed files are run automatically after migrations when using supabase db reset (see config.toml → [db.seed] → sql_paths). Currently only user seed is enabled:
seed_01_users.sql: Creates admin user and initial user profiles (enabled)seed_02_phase2_experiments.sql: Initial experiment data (temporarily disabled; add back tosql_pathsinconfig.tomlto re-enable)
Configuration
The config.toml file contains all Supabase service configurations:
- Database port: 54322
- API port: 54321
- Studio port: 54323
- Inbucket (email testing): 54324
See config.toml for detailed configuration options.
Accessing Services
- Supabase Studio: http://localhost:54323
- API: http://localhost:54321
- Database:
postgresql://postgres:postgres@localhost:54322/postgres - Email Testing (Inbucket): http://localhost:54324
Best Practices
- Migrations are versioned: Always use numbered prefixes (e.g.,
00001_,00002_) - Migrations should be idempotent: Use
IF NOT EXISTSandCREATE OR REPLACEwhere possible - Test migrations locally: Always test migrations before committing
- Document breaking changes: Add notes in migration files for schema changes