https://github.com/tinybirdco/forward_migration_checker
https://github.com/tinybirdco/forward_migration_checker
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/tinybirdco/forward_migration_checker
- Owner: tinybirdco
- Created: 2025-05-29T11:13:59.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-29T15:08:30.000Z (about 1 year ago)
- Last Synced: 2025-07-22T20:13:24.807Z (11 months ago)
- Language: Python
- Size: 19.5 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Tinybird Migration Agent
A powerful AI-powered tool to analyze Tinybird Classic projects and assess their compatibility for migration to Tinybird Forward.
## Features
- **Comprehensive Analysis**: Checks version tags, sinks, shared datasources, DynamoDB connections, endpoint types, and include files
- **AI-Powered Insights**: Uses Google's Vertex AI to generate detailed migration recommendations
- **đ§ Automatic Fixes**: Can automatically fix compatible issues with user confirmation
- **Detailed Reporting**: Generates a comprehensive `migration.md` report with step-by-step migration plans
- **Safe Operations**: Creates backup files before making any changes
- **Easy to Use**: Simple command-line interface with progress indicators
## Installation
1. **Install Dependencies**:
```bash
pip install -r requirements.txt
```
2. **Set up Google Cloud Authentication**:
You need to authenticate with Google Cloud to use Vertex AI:
```bash
# Option 1: Service Account Key
export GOOGLE_APPLICATION_CREDENTIALS="path/to/your/service-account-key.json"
# Option 2: gcloud CLI
gcloud auth application-default login
# Set your project ID
export GOOGLE_CLOUD_PROJECT="your-project-id"
```
## Usage
### Basic Usage
Run the migration check on a Tinybird project:
```bash
python main.py
```
This will analyze the `./tinybird` directory by default.
### Custom Project Path
Specify a custom path to your Tinybird project:
```bash
python main.py /path/to/your/tinybird/project
```
### What the Agent Checks
The migration agent performs these checks:
1. **đˇī¸ Version Tags**: Looks for version management files (*.mdc, *version*)
2. **đ° Sinks**: Checks for `TYPE sink` declarations in .pipe files (**Auto-fixable** â
)
3. **đ¤ Shared Datasources**: Looks for `SHARED_WITH` declarations and vendor/ directories (**Auto-fixable** â
)
4. **đī¸ DynamoDB Connections**: Finds `IMPORT_SERVICE "dynamodb"` declarations
5. **đ Endpoint Types**: Validates endpoint file structures (**Auto-fixable** â
)
6. **đ Include Files**: Checks for `INCLUDE` statements and .incl files (**Auto-fixable** â
)
### Auto-Fix Capabilities
The agent can automatically fix the following issues with your confirmation:
#### â
**Auto-Fixable Issues**
- **Sinks**: Comments out sink declarations and related export configurations
- **Shared Datasources**: Removes `SHARED_WITH` declarations and offers to remove vendor directories
- **Endpoint Types**: Adds missing `NODE` declarations to endpoint files
- **Include Files**: Comments out `INCLUDE` statements and offers to move .incl files to backup
#### â ī¸ **Manual Fix Required**
- **DynamoDB Connections**: Requires manual migration strategy
- **Version Tags**: Needs manual setup of version management
### Migration Compatibility Rules
#### â **BLOCKING Issues** (Must Fix Before Migration)
- **Sinks**: Not supported in Tinybird Forward (**Auto-fixable** â
)
- **Shared Datasources**: Not supported in Tinybird Forward (**Auto-fixable** â
)
#### â ī¸ **WARNING Issues** (Review Required)
- **DynamoDB Connections**: May have limitations in Forward
- **Include Files**: Need to verify compatibility (**Auto-fixable** â
)
- **Version Tags**: Recommended for migration tracking
#### âšī¸ **Important Notes**
- **BI Connector**: Not available in Tinybird Forward - migrate to REST/SQL APIs
## Auto-Fix Process
When the agent detects fixable issues, it will:
1. **đ Identify** the specific problems
2. **đŦ Ask for confirmation** before making any changes
3. **đ Create backup files** with `.backup` extension
4. **đ§ Apply the fixes** safely
5. **đ Report** what was changed
### Example Auto-Fix Session
```
đ§ Found 2 sink-related issues that can be auto-fixed:
- Sink found in tinybird/pipes/s3_sink_example.pipe
- Export configurations detected
Would you like to automatically comment out sink declarations? (y/n): y
đ Created backup: tinybird/pipes/s3_sink_example.pipe.backup
â
Fixed 1 sink issues
```
## Output
The agent generates:
1. **Console Output**: Real-time progress and summary
2. **migration.md**: Detailed migration report with:
- Executive summary
- Detailed check results
- Specific recommendations
- Step-by-step migration plan
- BI Connector migration warning
## Example Output
```
đ Starting Tinybird migration check for: ./tinybird
đ Starting Tinybird migration compatibility check...
đ Found 4 Tinybird files
đ Running migration checks:
1ī¸âŖ Checking version tags...
Status: WARNING
2ī¸âŖ Checking for sinks...
Status: FAIL
3ī¸âŖ Checking shared datasources...
Status: FAIL
4ī¸âŖ Checking DynamoDB connections...
Status: WARNING
5ī¸âŖ Checking endpoint types...
Status: PASS
6ī¸âŖ Checking include files...
Status: PASS
đ¤ Generating migration analysis...
â
Migration check complete!
đ Report saved to: migration.md
```
## Sample Project Structure
The included sample project demonstrates common migration issues and auto-fixes:
```
tinybird/
âââ datasources/
â âââ sample_data.datasource # DynamoDB connection (WARNING)
â âââ shared_data.datasource # Shared datasource (AUTO-FIXABLE)
âââ pipes/
â âââ s3_sink_example.pipe # Sink usage (AUTO-FIXABLE)
â âââ example_with_include.pipe # Include statements (AUTO-FIXABLE)
âââ endpoints/
â âââ sample_endpoint.endpoint # Regular endpoint (PASS)
âââ includes/
âââ common_filters.incl # Include file (AUTO-FIXABLE)
```
## Backup and Recovery
### Backup Files
The agent automatically creates backup files before making changes:
- Original: `file.datasource`
- Backup: `file.datasource.backup`
### Restoring from Backup
To restore original files:
```bash
# Restore a specific file
cp tinybird/datasources/shared_data.datasource.backup tinybird/datasources/shared_data.datasource
# Restore all files from backups (be careful!)
find tinybird/ -name "*.backup" | while read backup; do
original="${backup%.backup}"
cp "$backup" "$original"
done
```
### Include Files Backup
Include files are moved to `tinybird/includes_backup/` directory for safe keeping.
## Troubleshooting
### Authentication Issues
- Ensure Google Cloud credentials are properly set
- Verify your project has Vertex AI API enabled
- Check that your service account has the necessary permissions
### File Permission Issues
- Ensure the agent has read access to your Tinybird project directory
- Check that it can write to the current directory for the migration.md report
### No Tinybird Files Found
- Verify the path to your Tinybird project is correct
- Ensure your project has .datasource, .pipe, or .endpoint files
## Contributing
Feel free to contribute improvements or report issues. The agent is designed to be extensible for additional migration checks.
## License
MIT License - see LICENSE file for details.