数据与分析
Database Sync
Automate database synchronization, replication, migration, and cross-platform data integration
Claude Office Skills · 已有静态检查记录
安装与使用
运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。
npx skills add claude-office-skills/skills --skill Database Sync技能说明
name: Database Sync description: Automate database synchronization, replication, migration, and cross-platform data integration version: 1.0.0 author: Claude Office Skills category: data tags:
- database
- sync
- replication
- migration
- integration department: engineering models:
- claude-3-opus
- claude-3-sonnet
- gpt-4
mcp:
server: data-mcp
tools:
- postgres_sync
- mysql_replicate
- mongodb_sync
- redis_cache capabilities:
- Real-time replication
- Cross-database sync
- Schema migration
- Conflict resolution input:
- Source database config
- Target database config
- Sync rules
- Transformation mappings output:
- Synced data
- Replication logs
- Conflict reports
- Migration status languages:
- en related_skills:
- etl-pipeline
- sheets-automation
- airtable-automation
Database Sync
Comprehensive skill for database synchronization, replication, and data integration.
Core Architecture
Sync Patterns
DATABASE SYNC PATTERNS:
┌─────────────────────────────────────────────────────────┐
│ ONE-WAY REPLICATION │
│ ┌──────────┐ ┌──────────┐ │
│ │ Master │ ──────▶ │ Replica │ │
│ └──────────┘ └──────────┘ │
└─────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────┐
│ BI-DIRECTIONAL SYNC │
│ ┌──────────┐ ┌──────────┐ │
│ │ Database │ ◀─────▶ │ Database │ │
│ │ A │ │ B │ │
│ └──────────┘ └──────────┘ │
└─────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────┐
│ HUB-AND-SPOKE │
│ ┌──────────┐ │
│ │ Spoke 1 │ │
│ └────┬─────┘ │
│ │ │
│ ┌──────────┐──┴──┌──────────┐ │
│ │ Spoke 2 │◀───▶│ Hub │◀────┬──────────┐ │
│ └──────────┘ └──────────┘ │ Spoke 3 │ │
│ └──────────┘ │
└─────────────────────────────────────────────────────────┘
Sync Methods
sync_methods:
full_sync:
description: "Complete data refresh"
use_when:
- Initial sync
- Schema changes
- Disaster recovery
considerations:
- Downtime required
- Resource intensive
incremental_sync:
description: "Changes only"
tracking_methods:
- timestamps (updated_at)
- change_data_capture (CDC)
- triggers
- log_based
advantages:
- Minimal data transfer
- Near real-time
snapshot_sync:
description: "Point-in-time copy"
use_when:
- Analytics
- Reporting
- Backup
Configuration
Source/Target Setup
sync_config:
source:
type: postgresql
host: "source-db.example.com"
port: 5432
database: "production"
credentials:
type: secret_manager
path: "db/source/credentials"
ssl: required
target:
type: mysql
host: "target-db.example.com"
port: 3306
database: "analytics"
credentials:
type: secret_manager
path: "db/target/credentials"
ssl: required
sync_settings:
mode: incremental
batch_size: 10000
parallel_tables: 4
retry_attempts: 3
checkpoint_interval: 5_minutes
Table Mapping
table_mappings:
- source_table: users
target_table: dim_users
columns:
id: user_id
email: email_address
created_at: registration_date
status: user_status
transformations:
- column: status
transform: "UPPER(status)"
- column: email_address
transform: "LOWER(email)"
filters:
- "status != 'deleted'"
- "created_at > '2023-01-01'"
- source_table: orders
target_table: fact_orders
columns:
"*": "*" # All columns
exclude_columns:
- internal_notes
- deleted_at
incremental_key: updated_at
Change Data Capture
CDC Configuration
cdc_config:
method: logical_replication # or: trigger, polling
postgresql:
publication: "sync_publication"
slot: "sync_slot"
tables:
- users
- orders
- products
change_tracking:
capture_deletes: true
capture_before_values: true
output_format:
type: json
include:
- operation
- timestamp
- table
- key
- before
- after
CDC Event Processing
cdc_events:
example_insert:
operation: INSERT
timestamp: "2024-01-15T10:30:00Z"
table: users
key: { id: 12345 }
after:
id: 12345
email: "user@example.com"
status: "active"
example_update:
operation: UPDATE
timestamp: "2024-01-15T10:31:00Z"
table: users
key: { id: 12345 }
before:
status: "active"
after:
status: "premium"
example_delete:
operation: DELETE
timestamp: "2024-01-15T10:32:00Z"
table: users
key: { id: 12345 }
before:
id: 12345
email: "user@example.com"
Conflict Resolution
Conflict Strategies
conflict_resolution:
strategies:
- name: last_write_wins
description: "Most recent update wins"
resolution: |
IF source.updated_at > target.updated_at
THEN use source
ELSE keep target
- name: source_priority
description: "Source always wins"
resolution: "always use source"
- name: merge
description: "Merge non-conflicting fields"
resolution: |
FOR
阅读完整来源 ↗