Guide for upgrading Data Hub and migrating pipelines between versions.
Data Hub follows semantic versioning (MAJOR.MINOR.PATCH):
| Type | Description | Downtime | Complexity |
|---|---|---|---|
| Patch | Bug fixes only | None | Low |
| Minor | New features, backward compatible | None | Low |
| Major | Breaking changes | Possible | Medium-High |
| Data Hub Version | Minimum Vendure | Recommended Vendure |
|---|---|---|
| 2.0.x | 2.0.0 | 2.2.x |
| 1.5.x | 1.9.0 | 2.1.x |
| 1.0.x | 1.8.0 | 1.9.x |
| Data Hub Version | Node.js |
|---|---|
| 2.x | >= 18.0.0 |
| 1.x | >= 16.0.0 |
Before upgrading, complete these steps:
# Backup database
pg_dump vendure_db > backup-$(date +%Y%m%d).sql
# Backup pipeline definitions (if using file-based config)
tar -czf pipeline-backup-$(date +%Y%m%d).tar.gz ./pipelines
# Backup plugin configuration
cp vendure-config.ts vendure-config.ts.backup
Read the CHANGELOG.md for:
# Clone production data to staging
pg_dump production_db | psql staging_db
# Test upgrade in staging first
cd staging-environment
npm install @oronts/vendure-data-hub-plugin@latest
npm run dev
# List installed version
npm list @oronts/vendure-data-hub-plugin
# Check for peer dependency conflicts
npm ls
Check for compatibility with new version.
No migration needed. Simply update the package:
npm install @oronts/vendure-data-hub-plugin@latest
npm run build
pm2 restart vendure
Backward compatible. Update package and optionally adopt new features:
# Update package
npm install @oronts/vendure-data-hub-plugin@latest
# Run database migrations (if any)
npm run migration:run
# Restart server
pm2 restart vendure
Breaking changes. Follow detailed migration guide:
Read Breaking Changes
Review breaking changes for your version in Breaking Changes.
Update Package
npm install @oronts/vendure-data-hub-plugin@2.0.0
Run Migration Script
npx data-hub-migrate --from=1.x --to=2.0
Update Configuration
Update vendure-config.ts for new plugin options.
Migrate Pipelines
Use migration tool to update pipeline definitions:
npx data-hub-migrate-pipelines \
--input=./pipelines \
--output=./pipelines-v2 \
--from=1.x \
--to=2.0
Run Database Migrations
npm run migration:run
Test Thoroughly
Run all pipelines in dry-run mode:
mutation {
startDataHubPipelineRun(pipelineId: "pipeline-1") {
id
status
}
}
Deploy
npm run build
pm2 restart vendure
Release Date: 2024-01-15
Pipeline Definition Schema
Before (1.x):
{
version: 1,
steps: [{
type: 'extract',
adapter: 'httpApi', // ❌ Old field
config: {}
}]
}
After (2.x):
{
version: 1,
steps: [{
type: 'EXTRACT', // ✅ Uppercase
config: {
adapterCode: 'httpApi', // ✅ New field
}
}]
}
Migration:
adapter → adapterCode in all stepsHook Stages
Before (1.x):
hooks: {
beforeExtract: [], // ❌ camelCase
}
After (2.x):
hooks: {
BEFORE_EXTRACT: [], // ✅ SCREAMING_SNAKE_CASE
}
Migration:
Operator Config
Before (1.x):
operators: [{
type: 'rename',
from: 'old',
to: 'new'
}]
After (2.x):
operators: [{
op: 'rename', // ✅ 'op' instead of 'type'
args: { // ✅ 'args' wrapper
from: 'old',
to: 'new'
}
}]
Migration:
type → opargs objectConnection Schema
Before (1.x):
connectionType: 'http' // ❌ Lowercase
After (2.x):
type: 'HTTP' // ✅ Uppercase
Removed Features
JobQueue system removed (use Pipelines instead)legacyMode option removedsyncMode replaced with runModeRelease Date: 2023-09-01
GraphQL Schema
pipelineRuns → dataHubPipelineRunspipelines → dataHubPipelinesPermissions
New permission structure:
// Old
'ReadPipeline'
// New
'ReadDataHubPipeline'
Release Date: 2023-03-15
Initial release.
Data Hub uses TypeORM migrations. Run after upgrading:
npm run migration:run
For complex upgrades, run migrations manually:
# Generate migration
npm run migration:generate -- -n MigrationName
# Review generated migration
cat src/migrations/[timestamp]-MigrationName.ts
# Run migration
npm run migration:run
# Revert if needed
npm run migration:revert
Check current migration status:
npm run migration:show
Use the migration tool to update pipeline definitions:
npx data-hub-migrate-pipelines \
--from=1.5.0 \
--to=2.0.0 \
--input=./pipelines \
--output=./pipelines-migrated \
--backup
Options:
--from: Source version--to: Target version--input: Input directory--output: Output directory--backup: Create backup before migration--dry-run: Preview changes without writingFor custom pipelines, manually update:
Update Step Types
// Before
type: 'extract'
// After
type: 'EXTRACT'
Update Adapter References
// Before
adapter: 'httpApi'
// After
config: {
adapterCode: 'httpApi'
}
Update Operators
// Before
operators: [{
type: 'rename',
from: 'old',
to: 'new'
}]
// After
operators: [{
op: 'rename',
args: { from: 'old', to: 'new' }
}]
Update Hooks
// Before
hooks: {
beforeExtract: []
}
// After
hooks: {
BEFORE_EXTRACT: []
}
import { validatePipelineDefinition } from '@oronts/vendure-data-hub-plugin';
const pipeline = /* ... migrated pipeline ... */;
const result = validatePipelineDefinition(pipeline);
if (!result.valid) {
console.error('Validation errors:', result.errors);
}
If migration fails, rollback to previous version:
pm2 stop vendure
psql vendure_db < backup-YYYYMMDD.sql
npm install @oronts/vendure-data-hub-plugin@1.5.0
cp vendure-config.ts.backup vendure-config.ts
npm run build
pm2 start vendure
curl http://localhost:3000/health
After successful migration, validate:
# Check server logs
pm2 logs vendure | grep "DataHubPlugin"
Expected output:
DataHubPlugin initialized successfully
query {
__type(name: "DataHubPipeline") {
fields {
name
type {
name
}
}
}
}
-- Check tables exist
SELECT table_name
FROM information_schema.tables
WHERE table_name LIKE 'data_hub%';
Run each pipeline in dry-run mode:
mutation {
startDataHubPipelineRun(pipelineId: "test-pipeline") {
id
status
}
}
Test custom adapters:
// test-custom-adapters.ts
import { myCustomExtractor } from './custom-adapters';
const context = createMockContext();
const config = { /* ... */ };
// Test extraction
const records = [];
for await (const record of myCustomExtractor.extract(context, config)) {
records.push(record);
}
console.log(`Extracted ${records.length} records`);
Monitor performance metrics after migration:
query {
dataHubPipelinePerformance(
pipelineId: "test-pipeline"
timeRange: {
from: "2024-01-01T00:00:00Z"
to: "2024-01-31T23:59:59Z"
}
) {
avgDurationMs
p95DurationMs
successRate
}
}
Solution:
# Check migration status
npm run migration:show
# Manually run missing migrations
npm run migration:run
Solution:
# Use migration tool
npx data-hub-migrate-pipelines \
--from=1.5.0 \
--to=2.0.0 \
--input=./pipelines \
--output=./pipelines-v2
Solution: Check adapter registration:
// vendure-config.ts
DataHubPlugin.init({
adapters: [
myCustomExtractor, // ✅ Registered
],
})
Solution:
SELECT * FROM pg_indexes
WHERE tablename LIKE 'data_hub%';
ANALYZE data_hub_pipeline_run;
ANALYZE data_hub_pipeline_log;
VACUUM ANALYZE;
For production systems requiring zero downtime:
Setup Green Environment
# Clone current environment
docker-compose -f docker-compose.green.yml up -d
Run Migrations on Green
# Connect to green database
export DATABASE_URL=postgresql://green-db
# Run migrations
npm run migration:run
# Deploy new version
npm run build
pm2 start ecosystem.config.green.js
Test Green Environment
curl http://green.example.com/health
Switch Traffic
# nginx.conf
upstream vendure {
server green.example.com:3000; # Point to green
}
Monitor
Watch metrics for 24 hours before decommissioning blue.
For Kubernetes deployments:
# deployment.yaml
spec:
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
template:
spec:
containers:
- name: vendure
image: vendure:2.0.0 # New version