Overview
Quality Hub GINEZ uses Supabase (PostgreSQL) as its database. This guide covers how to safely modify the database schema and manage migrations.Database Schema
Core Tables
The application uses two main tables:1. bitacora_produccion
Stores all production batch records with quality measurements:2. profiles
Stores user profile information and admin status:Creating Migrations
Using Supabase Dashboard
The simplest way to create migrations is through the Supabase dashboard:- Go to your Supabase project
- Navigate to SQL Editor
- Write your migration SQL
- Click Run to execute
Example: Adding a New Column
Example: Creating Indexes
Row Level Security (RLS)
Understanding RLS
RLS ensures users can only access data they’re authorized to see. Quality Hub uses RLS extensively for security.User Access Policies
Admin Access Policies
Migration Best Practices
1. Always Backup First
Before running migrations:- Go to Database → Backups
- Create a manual backup before major changes
2. Test Migrations in Development
Never run migrations directly in production:- Create a separate Supabase project for development
- Test migrations there first
- Verify application functionality
- Then apply to production
3. Use Transactions
4. Make Migrations Reversible
Always know how to undo a migration:Common Migration Scenarios
Adding a New Quality Parameter
lib/production-constants.ts:
Creating an Audit Log Table
Adding Full-Text Search
Modifying Existing Columns
Changing Column Type
Adding NOT NULL Constraint
Monitoring and Maintenance
Check Table Size
Vacuum and Analyze
Emergency Rollback
If a migration causes issues:- Restore from backup (Supabase Dashboard → Backups)
- Or manually revert the changes:
Next Steps
Adding Products
Learn how to add new products and standards
Customization
Customize the application functionality
