Initial commit
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
# Migration Checklist
|
||||
|
||||
**Use before applying database migrations.**
|
||||
|
||||
## Before Migration
|
||||
|
||||
- [ ] Backup database
|
||||
- [ ] Test migration in development
|
||||
- [ ] Test migration rollback
|
||||
- [ ] Review generated SQL
|
||||
- [ ] Check for breaking changes
|
||||
- [ ] Coordinate with team if breaking
|
||||
|
||||
## Migration Quality
|
||||
|
||||
- [ ] Migration is reversible (has downgrade)
|
||||
- [ ] No data loss
|
||||
- [ ] Preserves existing data
|
||||
- [ ] Handles NULL values correctly
|
||||
- [ ] Default values provided for NOT NULL
|
||||
|
||||
## After Migration
|
||||
|
||||
- [ ] Migration applied successfully
|
||||
- [ ] Application tested
|
||||
- [ ] Rollback tested
|
||||
- [ ] Performance verified
|
||||
- [ ] No errors in logs
|
||||
91
skills/database-conventions/checklists/schema-checklist.md
Normal file
91
skills/database-conventions/checklists/schema-checklist.md
Normal file
@@ -0,0 +1,91 @@
|
||||
# Database Schema Checklist
|
||||
|
||||
**Use before creating PR for new database schemas.**
|
||||
|
||||
## Naming Conventions
|
||||
|
||||
- [ ] All field names use snake_case (NOT camelCase)
|
||||
- [ ] Boolean fields use is_/has_/can_ prefix
|
||||
- [ ] Timestamp fields use _at suffix
|
||||
- [ ] Foreign keys use _id suffix
|
||||
- [ ] Email field named `email_address` (not `email`)
|
||||
- [ ] Phone field named `phone_number` (not `phone`)
|
||||
|
||||
## Multi-Tenant Requirements
|
||||
|
||||
- [ ] tenant_id field present on all tables
|
||||
- [ ] tenant_id has NOT NULL constraint
|
||||
- [ ] tenant_id has index for performance
|
||||
- [ ] tenant_id has foreign key to tenants table
|
||||
- [ ] RLS policy created for tenant isolation
|
||||
- [ ] Test cases verify tenant isolation
|
||||
|
||||
## Standard Fields
|
||||
|
||||
- [ ] id field (UUID primary key)
|
||||
- [ ] created_at timestamp (NOT NULL, default now())
|
||||
- [ ] updated_at timestamp (NOT NULL, auto-update)
|
||||
- [ ] tenant_id (NOT NULL, indexed)
|
||||
- [ ] deleted_at timestamp (for soft delete)
|
||||
|
||||
## Indexes
|
||||
|
||||
- [ ] tenant_id indexed
|
||||
- [ ] Foreign keys indexed
|
||||
- [ ] Unique fields indexed
|
||||
- [ ] Frequently queried fields indexed
|
||||
- [ ] Composite indexes for common query patterns
|
||||
|
||||
## Relationships
|
||||
|
||||
- [ ] Foreign keys defined explicitly
|
||||
- [ ] Relationships documented in schema
|
||||
- [ ] Cascade delete configured appropriately
|
||||
- [ ] Join tables for many-to-many
|
||||
|
||||
## Migrations
|
||||
|
||||
- [ ] Migration generated (Drizzle Kit or Alembic)
|
||||
- [ ] Migration tested locally
|
||||
- [ ] Migration reversible (has downgrade)
|
||||
- [ ] Migration reviewed by teammate
|
||||
- [ ] No breaking changes without coordination
|
||||
|
||||
## Row Level Security
|
||||
|
||||
- [ ] RLS enabled on table
|
||||
- [ ] Tenant isolation policy created
|
||||
- [ ] Admin override policy (if needed)
|
||||
- [ ] Anonymous policy (if public data)
|
||||
- [ ] RLS tested with different roles
|
||||
|
||||
## Performance
|
||||
|
||||
- [ ] Appropriate indexes created
|
||||
- [ ] No N+1 query patterns
|
||||
- [ ] Large text fields use TEXT (not VARCHAR)
|
||||
- [ ] Consider partitioning for large tables
|
||||
|
||||
## Security
|
||||
|
||||
- [ ] No sensitive data in plain text
|
||||
- [ ] Passwords hashed (never store plain)
|
||||
- [ ] PII properly handled
|
||||
- [ ] Input validation at model level
|
||||
- [ ] SQL injection prevented (using ORM)
|
||||
|
||||
## Testing
|
||||
|
||||
- [ ] Model tests written
|
||||
- [ ] Migration tested
|
||||
- [ ] Relationships tested
|
||||
- [ ] Tenant isolation tested
|
||||
- [ ] Unique constraints tested
|
||||
- [ ] Foreign key constraints tested
|
||||
|
||||
## Documentation
|
||||
|
||||
- [ ] Schema documented in code comments
|
||||
- [ ] README updated if needed
|
||||
- [ ] ERD diagram updated (if exists)
|
||||
- [ ] Migration notes added
|
||||
Reference in New Issue
Block a user