supabase_annotations 1.2.0
supabase_annotations: ^1.2.0 copied to clipboard
Code generator for Supabase/PostgreSQL database schemas from Dart classes. Supports RLS policies, indexes, foreign keys, migration, and table partitioning.
Changelog #
All notable changes to the Supabase Annotations package will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
1.2.0 - 2024-10-04 #
Enhanced #
- π¨ SQL Formatting System: Completely redesigned SQL formatting with line length management and intelligent formatting
- π Column Type Parser: Enhanced column type parsing with better fallback mechanisms and type resolution
- π§ DO Block Formatting: Improved formatting for column addition DO blocks with proper indentation and line breaks
- βοΈ Constraint Statements: Enhanced formatting for ALTER TABLE CONSTRAINT statements with better readability
- ποΈ CREATE TABLE Formatting: Improved table creation statements with proper column definition formatting
- π Policy Statement Formatting: Better formatting for CREATE POLICY statements with USING clauses
- π― Smart Line Breaking: Intelligent SQL line breaking based on keywords, operators, and maximum line length
- π€ Column Definition Splitting: Enhanced column definition formatting with proper constraint placement
Fixed #
- π Type Resolution: Fixed column type resolution issues with proper element name and library identification
- π Long Statement Handling: Better handling of long SQL statements with intelligent breaking points
- π§Ή Code Structure: Improved code organization with better separation of formatting concerns
1.1.9 #
Fixed #
- π RLS Policy SQL Generation: Fixed PostgreSQL syntax error in CREATE POLICY statements when no roles specified
- π RLS Policy Annotation Parsing: Updated parser to correctly handle new RLSPolicy field names (type, condition, checkCondition)
- ποΈ DatabaseTable Policy Support: Added support for parsing policies defined within @DatabaseTable annotation
- β‘ Empty Roles Handling: Improved SQL generation to omit TO clause when no roles are specified
Enhanced #
- π οΈ Schema Generator: Better handling of both standalone @RLSPolicy annotations and embedded policies
- β SQL Validation: All generated RLS policy SQL now follows correct PostgreSQL syntax
1.1.8 #
Fixed #
- π Bug Fixes: Minor bug fixes and stability improvements
- π Documentation: Updated documentation and examples
1.1.7 #
Enhanced #
- ποΈ Architecture Refactoring: Complete redesign of schema generation using Strategy Pattern for better maintainability
- π§ Foreign Key System: Major refactoring of foreign key parsing with improved field-level and class-level annotation support
- β Validation Pipeline: New comprehensive schema validation system with detailed error reporting
- π οΈ SQL Builder: Introduction of fluent SQL statement builder for more robust query construction
- β‘ Performance: Enhanced performance through better parsing algorithms and code organization
Improved #
- π¦ Code Structure: Better separation of concerns with dedicated parsers, validators, and builders
- π‘οΈ Error Handling: More detailed error messages and better exception handling throughout the system
- π Strategy Pattern: Flexible SQL generation strategies for different migration modes
- π Schema Processing: Improved schema parsing with better type safety and null handling
1.1.6 #
Fixed #
- π§ Analyzer Compatibility: Updated codebase to be compatible with analyzer ^8.1.1
- π API Migration: Replaced deprecated
LibraryElement.topLevelElements
with fragment-based approach usinglibrary.library.classes
- π‘οΈ Null Safety: Fixed null safety issues with
getEffectiveName
method calls by adding proper null checks - π Metadata Handling: Resolved metadata iteration issues due to analyzer API changes
- β‘ Build Performance: Improved build system compatibility with latest analyzer versions
Changed #
- π¦ Dependencies: Updated analyzer dependency to ^8.1.1 for latest Dart SDK compatibility
- ποΈ Code Generation: Enhanced robustness of schema generation with better error handling
1.1.5 #
Fixed #
- π§ Constant Expressions: Resolved "Methods can't be invoked in constant expressions" errors for
ColumnType
factory constructors - π Default Values: Fixed
DefaultValue.jsonObject()
,DefaultValue.nextVal()
, andDefaultValue.expression()
to work in const contexts - β
Validators: Removed dynamic types and made all validators properly generic typed (
EnumValidator
,AndValidator
,OrValidator
) - π― Type Safety: Complete elimination of
dynamic
types throughout the validator system - π« Assert Issues: Fixed
EnumValidator
const assertion that accessed.length
property in constant expressions
Improved #
- π Factory Constructors: Converted static methods to const factory constructors for better const expression support
- π¦ Generic Types: All validators now use proper generic type constraints instead of
dynamic
- ποΈ Architecture: Better separation of concerns with implementation classes for different column and default value types
- β‘ Performance: Reduced runtime type checking by leveraging compile-time type safety
1.1.4 #
Improved #
- π§ Schema Generator: Refactored Supabase schema builder and generator for improved annotation handling
- π¦ Dependencies: Updated source_gen version alignment with compatibility requirements
- π οΈ Code Quality: Enhanced builder.dart for better maintainability
1.1.3 #
Improved #
- π Documentation: Cleaned up changelog by removing specific dates for better maintainability
- π Version Management: Updated to semantic versioning without timestamp dependencies
1.1.2 #
Added #
- π Professional Documentation: Complete README overhaul with comprehensive navigation
- π― Enhanced Examples: Real-world use cases for multi-tenant apps, e-commerce, and analytics
- π Navigation Links: Table of contents with anchor links for easy navigation
- π Visual Improvements: Professional badges, emojis, and better formatting
- π οΈ Development Guide: Comprehensive contributor documentation
- π Community Support: Clear support channels and community guidelines
Improved #
- π Documentation Structure: Logical organization with clear sections
- π¨ Visual Appeal: Consistent emoji usage and professional formatting
- π± Responsive Design: Markdown optimized for all platforms
- π Searchability: Better keywords and descriptions for discoverability
Fixed #
- π Documentation Accuracy: Updated all examples to reflect current API
- π Link Consistency: All internal and external links verified and updated
1.1.1 #
Fixed #
- π§ Build System: Resolved build configuration issues
- π¦ Dependencies: Updated dependency constraints for better compatibility
- π Minor Bugs: Various small fixes for improved stability
1.1.0 #
Added #
- π Migration Support: Complete schema migration system with 5 migration modes:
createOnly
: Original behavior (default)createIfNotExists
: Safe table creation with IF NOT EXISTScreateOrAlter
: Create table if not exists, then add missing columnsalterOnly
: Only generate ALTER TABLE statements for existing schemasdropAndRecreate
: Drop and recreate tables (development only)
- π PostgreSQL DO Blocks: Conditional ALTER TABLE statements using DO blocks for maximum safety
- βοΈ Migration Configuration: Extensive configuration options in build.yaml:
migration_mode
: Choose migration strategyenable_column_adding
: Control column addition behaviorgenerate_do_blocks
: Use PostgreSQL DO blocks for conditional operations
- ποΈ Table Partitioning: Full PostgreSQL partitioning support:
RangePartition
: Partition by range (ideal for time-series data)HashPartition
: Partition by hash (for even data distribution)ListPartition
: Partition by list (for categorical data)
- π§ Composite Primary Keys: Automatic composite primary key generation for partitioned tables
- π Migration Documentation: Comprehensive migration guide and examples
Fixed #
- Critical: PostgreSQL partitioned table primary key constraints now include all partition columns
- Critical: ALTER TABLE statements no longer generate conflicting PRIMARY KEY constraints
- Migration modes properly handle existing table scenarios without errors
- Partition clause SQL formatting and generation
Improved #
- Enhanced SQL formatter with partition clause support
- Better error handling for partition configuration validation
- Backward compatibility maintained - existing code continues to work
- More robust annotation parsing for complex configurations
Examples #
- Added comprehensive migration examples for all modes
- Added partition table examples with different strategies
- Updated build.yaml configuration examples
1.0.6 #
Fixed #
- Critical: Fixed RLS Policy annotation parsing - resolved "Null check operator used on a null value" error when processing RLSPolicy annotations
- Critical: Fixed enum value handling in annotation processing - RLSPolicyType and other enums now parse correctly
- Improved error handling for null annotation values to prevent build failures
- Enhanced annotation reading safety with proper null checks
Improved #
- Better error messages for annotation parsing issues
- More robust handling of optional annotation parameters
- Enhanced test coverage for RLS policy generation
1.0.5 #
Fixed #
- Critical: Fixed index column name mapping issues - indexes now properly recognize database column names vs field names
- Critical: Fixed column type parsing - all column types (UUID, TEXT, JSONB, TIMESTAMP WITH TIME ZONE, etc.) now generate correctly
- Critical: Fixed foreign key column references - foreign keys now include proper column names instead of empty references
- Critical: Fixed composite primary key duplication - individual columns no longer get PRIMARY KEY constraint when part of composite key
- Fixed SQL formatting issues - proper line breaks and comma separation between columns
- Fixed missing index comments in generated SQL
Improved #
- Enhanced SQL readability with proper formatting and structure
- Better error handling for null values in annotation processing
- Improved validation for database schema generation
- Added comprehensive test coverage for edge cases
1.0.4 #
Fixed #
- Fixed static analysis issues by removing invalid @immutable annotations from enums
- Cleaned up unused imports to eliminate linting warnings
- Standardized LICENSE file to OSI-approved MIT License format for proper pub.flutter-io.cn recognition
- Added proper example package structure with pubspec.yaml for better pub.flutter-io.cn scoring
- Enhanced example documentation and build configuration
Improved #
- Significantly improved pub.flutter-io.cn package score by addressing all major scoring criteria
- Better package discoverability and community accessibility
1.0.3 #
Fixed #
- Improved package reliability and build system stability
- Enhanced error handling for edge cases
- Better validation for schema generation
1.0.2 #
Fixed #
- Fixed static analysis issues by removing unnecessary library names
- Added proper library directives to resolve dangling documentation comments
- Improved package score for pub.flutter-io.cn by addressing linting issues
- Enhanced code quality and documentation standards
1.0.1 #
Fixed #
- Updated README.md with correct package version and repository links
- Fixed version number consistency in documentation
- Improved package metadata for better discoverability
1.0.0 #
Added #
ποΈ Core Features
- PostgreSQL Schema Generation: Convert Dart classes to SQL DDL statements
- Type-Safe Column Mapping: Complete Dart-to-PostgreSQL type system
- Row Level Security (RLS): Declarative policy generation and management
- Foreign Key Relationships: Full referential integrity support
- Database Indexes: Multiple index types with optimization
- Schema Validation: Comprehensive validation and error reporting
π Security Features
- RLS Policies: Support for all policy types (SELECT, INSERT, UPDATE, DELETE, ALL)
- Fine-Grained Permissions: Row and column-level access control
- Authentication Integration: Built-in Supabase auth helpers
- SQL Injection Protection: Safe parameterized conditions
- Access Control: Role-based permission management
β‘ Performance Features
- Smart Indexing: Automatic index recommendations
- Multiple Index Types: B-tree, Hash, GIN, GiST, SP-GiST, BRIN support
- Composite Indexes: Multi-column index optimization
- Partial Indexes: Conditional indexing for large tables
- Query Optimization: Performance-aware SQL generation
π Foreign Key Support
- Cascade Actions: NO ACTION, RESTRICT, CASCADE, SET NULL, SET DEFAULT
- Composite Keys: Multi-column foreign key relationships
- Self-referencing: Support for hierarchical data structures
- Deferrable Constraints: Transaction-level constraint checking
π Column Types & Constraints
- Complete PostgreSQL Types: All standard PostgreSQL data types
- Custom Constraints: CHECK constraints with validation
- Default Values: Rich default value support including functions
- Nullability Control: Explicit NULL/NOT NULL configuration
- Primary Keys: Single and composite primary key support
π‘οΈ Validation & Error Handling
- Schema Validation: Comprehensive validation with detailed error messages
- Type Compatibility: Automatic Dart-to-PostgreSQL type checking
- Constraint Validation: Business rule and constraint validation
- Performance Warnings: Index and query optimization suggestions
- Build-time Errors: Catch issues before deployment
π§ Code Generation
- SQL DDL Generation: Complete CREATE TABLE statements
- Index Generation: Optimized index creation statements
- Policy Generation: RLS policy creation and management
- Comment Generation: Automatic documentation in SQL
- Clean Output: Formatted, readable SQL generation
π― Developer Experience
- Type Safety: Full compile-time type checking with null safety
- IDE Support: Complete IntelliSense and code completion
- Comprehensive Documentation: Inline help and examples
- Clear Error Messages: Actionable error reporting with suggestions
- Rich Examples: Real-world usage patterns and best practices
ποΈ Architecture & Design
- SOLID Principles: Clean, maintainable architecture
- Domain-Driven Design: Clear domain models and language
- Extensible Design: Plugin architecture for customization
- Test-Driven Development: Comprehensive test coverage
- Performance Optimized: Efficient code generation
π Documentation & Examples
- Quick Start Guide: Get running in minutes
- API Reference: Complete annotation documentation
- Best Practices: Production-ready patterns
- Real-world Examples: E-commerce, CMS, SaaS patterns
- Migration Guide: Step-by-step upgrade instructions
π§ͺ Testing & Quality
- Unit Tests: Comprehensive unit test coverage
- Integration Tests: End-to-end database testing
- Static Analysis: Strict linting and quality checks
- CI/CD: Automated testing on multiple platforms
- Code Coverage: High test coverage requirements
π Compatibility
- Dart SDK: 3.2.0 and above with null safety
- PostgreSQL: 12.0+ with full feature support
- Supabase: All current versions
- Platforms: Windows, macOS, Linux development support
πΊοΈ Development Roadmap #
Planned Features #
v1.2.0 - Advanced Migration Tools
- Schema Diff Tools: Automatic migration generation from schema changes
- Rollback Support: Safe rollback mechanisms for failed migrations
- Migration Testing: Built-in migration validation and testing
- Data Migration: Support for data transformation during schema changes
v1.3.0 - Extended PostgreSQL Features
- Stored Procedures: Generation of PostgreSQL functions and procedures
- Triggers: Event-driven database logic support
- Views: Materialized and standard view generation
- Extensions: Support for PostgreSQL extensions
v1.4.0 - Advanced Analytics
- Query Analysis: Performance analysis and optimization suggestions
- Schema Metrics: Database schema health and performance metrics
- Usage Patterns: Analysis of schema usage and optimization opportunities
- Documentation Generation: Automatic schema documentation
v2.0.0 - Next Generation Features
- GraphQL Integration: Automatic GraphQL schema generation
- Real-time Support: Enhanced real-time subscription features
- Cloud Integration: Direct cloud deployment and management
- Advanced Caching: Intelligent caching strategies
π Support & Contributing #
Getting Help #
- Documentation: API Reference
- Issues: GitHub Issues
- Discussions: GitHub Discussions
Contributing #
We welcome contributions! Please see our Contributing Guide for details.
Changelog Conventions #
- Added: New features and capabilities
- Changed: Changes in existing functionality
- Deprecated: Soon-to-be removed features
- Removed: Removed features
- Fixed: Bug fixes and corrections
- Security: Security-related improvements
For detailed information about any release, please see the corresponding release notes and documentation.