Implementation roadmap for BetterStructureSql gem development.
Three-phase development approach:
- Phase 1: Core schema dumping foundation
- Phase 2: Schema versioning system
- Phase 3: Advanced PostgreSQL features
Goal: Clean structure.sql generation without pg_dump
Duration: 2-3 weeks
Key Deliverables:
- Pure Ruby PostgreSQL introspection
- Table, index, foreign key generation
- Extension and custom type support
- Rails integration (rake tasks)
- Basic testing framework
Files: ~20 Ruby files, ~25 spec files
Goal: Database-backed schema version storage
Duration: 1-2 weeks
Key Deliverables:
- SchemaVersion ActiveRecord model
- Version storage and retrieval
- Retention policy management
- PostgreSQL version tracking
- API endpoint examples
Files: ~8 Ruby files, ~10 spec files
Goal: Complete PostgreSQL feature support
Duration: 3-4 weeks
Key Deliverables:
- Views and materialized views
- Functions and triggers
- Partitioned tables
- Table inheritance
- Dependency resolution
- Performance optimization
Files: ~15 Ruby files, ~20 spec files
- Development: 6-9 weeks
- Testing: Ongoing throughout all phases
- Documentation: Ongoing throughout all phases
- Generates clean structure.sql for basic schemas
- All unit tests passing
- Integration tests with dummy app
- Output comparable to pg_dump (tables, indexes, FKs)
- Rails 7+ integration working
- Schema versions stored in database
- Retention policy functional
- Version retrieval working
- All versioning tests passing
- API endpoint documented
- All PostgreSQL features supported
- Complex dummy app schema fully dumped
- Performance meets targets
- Comparison tests vs pg_dump passing
- Documentation complete
-
Planning
- Review phase tasks
- Identify dependencies
- Setup development branch
-
Implementation
- TDD approach (test first)
- Incremental feature development
- Regular commits
-
Testing
- Unit tests for each component
- Integration tests for features
- Manual testing with dummy app
-
Documentation
- Inline code docs (YARD)
- User-facing docs
- Examples and guides
-
Review
- Code review
- Performance check
- Documentation review
- Test individual components in isolation
- Mock external dependencies
- Fast execution (<1s per test)
- Test full workflow
- Use dummy Rails app
- Compare with pg_dump output
- Test edge cases
- Benchmark against pg_dump
- Test with varying database sizes
- Monitor memory usage
- Generate schema with both tools
- Normalize and compare output
- Ensure completeness
Complex schema including:
- 15+ tables with relationships
- 5+ PostgreSQL extensions
- Custom types and enums
- Multiple index types (partial, expression, multi-column)
- Views and materialized views
- Functions (plpgsql)
- Triggers
- Partitioned tables
- Foreign keys with various actions
See spec/dummy/README.md for full schema.
- Language: Ruby 2.7+
- Framework: Rails 7.0+
- Database: PostgreSQL 12+
- Testing: RSpec 3.x
- CI: GitHub Actions
- Coverage: SimpleCov
- Linting: Rubocop
rails >= 7.0pg >= 1.0
rspec-railsfactory_bot_railsfakerdatabase_cleanersimplecovrubocoprubocop-railsrubocop-rspec
- Core introspection working
- Basic SQL generation
- Rails integration
- Schema storage functional
- Retention working
- API documented
- All features implemented
- Performance optimized
- Ready for v1.0.0 release
PostgreSQL Version Compatibility
- Risk: Different PG versions have different metadata schemas
- Mitigation: Test against PG 12, 13, 14, 15, 16
- Fallback: Document minimum supported version
Performance with Large Schemas
- Risk: Slow with 500+ tables
- Mitigation: Implement caching, batch queries, parallel processing
- Fallback: Document performance expectations
pg_dump Parity
- Risk: Missing edge cases
- Mitigation: Comprehensive comparison tests
- Fallback: Document known differences
Scope Creep
- Risk: Adding too many features
- Mitigation: Stick to phase plan, defer non-essentials
- Fallback: Cut Phase 3 features to optional
Testing Coverage
- Risk: Insufficient test coverage
- Mitigation: Enforce >95% coverage, mandatory integration tests
- Fallback: Focus on critical path coverage
- Basic functionality
- Alpha testing with select users
- Schema versioning
- Beta release
- All features
- Production ready
- Public announcement
- Comprehensive README
- Per-feature docs
- API documentation (YARD)
- Examples and guides
- GitHub Issues
- Bug reports template
- Feature requests template
- Response within 48 hours
- Contributing guidelines
- Code of conduct
- Changelog maintenance