notion-migration-deep-dive
Migrate data to/from Notion or between Notion workspaces with data mapping and validation. Use when migrating data into Notion databases, exporting from Notion, syncing between workspaces, or building ETL pipelines with Notion as source or destination. Trigger with phrases like "migrate notion", "notion migration", "import to notion", "export from notion", "notion data migration", "notion ETL".
What this skill does
# Notion Migration Deep Dive
## Overview
Comprehensive migration patterns for moving data to, from, and between Notion workspaces. This covers rate-limited bulk import from CSV/JSON with property mapping, full database export with pagination and block content extraction, cross-database sync with duplicate detection, data transformation patterns for Confluence and Google Docs content, and post-migration validation with integrity checks. All patterns respect Notion's 3 requests/second rate limit.
## Prerequisites
- `@notionhq/client` v2+ installed (`npm install @notionhq/client`)
- Python alternative: `notion-client` (`pip install notion-client`)
- `p-queue` for rate-limited concurrency (`npm install p-queue`)
- Source data access (CSV files, Confluence API, Google Docs API, etc.)
- Target Notion database(s) created with matching property schema
## Instructions
### Step 1: Import CSV/JSON into Notion Database
Map source data fields to Notion property types, create pages with rate limiting:
```typescript
import { Client } from '@notionhq/client';
import { readFileSync } from 'fs';
import { parse } from 'csv-parse/sync';
import PQueue from 'p-queue';
const notion = new Client({ auth: process.env.NOTION_TOKEN! });
// Rate-limited queue: 3 requests/second (Notion's documented limit)
const queue = new PQueue({ concurrency: 3, interval: 1000, intervalCap: 3 });
interface SourceRecord {
name: string;
status: string;
priority: string;
dueDate: string;
tags: string; // Comma-separated
assigneeEmail: string;
description: string;
}
// Map source fields to Notion property value objects
function mapToNotionProperties(record: SourceRecord) {
const properties: Record<string, any> = {
// Title property (required — every database has exactly one)
Name: { title: [{ text: { content: record.name || 'Untitled' } }] },
// Select — auto-creates options if they don't exist
Status: { select: { name: record.status || 'Not Started' } },
Priority: { select: { name: record.priority || 'Medium' } },
// Multi-select from comma-separated values
Tags: {
multi_select: record.tags
.split(',')
.map(t => t.trim())
.filter(Boolean)
.map(name => ({ name })),
},
// Rich text (max 2000 characters per text block)
Description: {
rich_text: [{ text: { content: (record.description || '').slice(0, 2000) } }],
},
// Email
'Assignee Email': record.assigneeEmail
? { email: record.assigneeEmail }
: { email: null },
};
// Date (only add if valid)
if (record.dueDate && !isNaN(Date.parse(record.dueDate))) {
properties['Due Date'] = { date: { start: record.dueDate } };
}
return properties;
}
async function importFromCSV(csvPath: string, databaseId: string) {
const csv = readFileSync(csvPath, 'utf-8');
const records = parse(csv, { columns: true, skip_empty_lines: true }) as SourceRecord[];
console.log(`Importing ${records.length} records into database ${databaseId}...`);
const results = { created: 0, failed: 0, errors: [] as string[] };
// Validate database schema before importing
const db = await notion.databases.retrieve({ database_id: databaseId });
const dbProps = Object.keys(db.properties);
console.log(`Database properties: ${dbProps.join(', ')}`);
await Promise.all(records.map((record, index) =>
queue.add(async () => {
try {
const properties = mapToNotionProperties(record);
// Remove properties not in database schema
for (const key of Object.keys(properties)) {
if (!dbProps.includes(key)) delete properties[key];
}
await notion.pages.create({
parent: { database_id: databaseId },
properties,
});
results.created++;
if (results.created % 50 === 0) {
console.log(`Progress: ${results.created}/${records.length}`);
}
} catch (error: any) {
results.failed++;
results.errors.push(`Row ${index + 1} ("${record.name}"): ${error.message}`);
}
})
));
console.log(`\nImport complete: ${results.created} created, ${results.failed} failed`);
if (results.errors.length > 0) {
console.log('First 10 errors:');
results.errors.slice(0, 10).forEach(e => console.log(` ${e}`));
}
return results;
}
```
**Python — CSV import:**
```python
import csv
import time
from notion_client import Client
client = Client(auth=os.environ["NOTION_TOKEN"])
def import_csv(csv_path: str, database_id: str):
with open(csv_path) as f:
reader = csv.DictReader(f)
rows = list(reader)
created, failed = 0, 0
for i, row in enumerate(rows):
try:
client.pages.create(
parent={"database_id": database_id},
properties={
"Name": {"title": [{"text": {"content": row.get("name", "Untitled")}}]},
"Status": {"select": {"name": row.get("status", "Not Started")}},
"Tags": {"multi_select": [
{"name": t.strip()} for t in row.get("tags", "").split(",") if t.strip()
]},
},
)
created += 1
except Exception as e:
failed += 1
print(f"Row {i+1}: {e}")
# Rate limit: 3 requests/second
if (created + failed) % 3 == 0:
time.sleep(1.1)
print(f"Done: {created} created, {failed} failed")
```
### Step 2: Export from Notion to JSON/CSV
Full database export with pagination, property extraction, and optional block content:
```typescript
import type { PageObjectResponse } from '@notionhq/client/build/src/api-endpoints';
// Extract a flat record from a Notion page's properties
function extractProperties(page: PageObjectResponse): Record<string, any> {
const row: Record<string, any> = {
id: page.id,
url: page.url,
created_time: page.created_time,
last_edited_time: page.last_edited_time,
};
for (const [name, prop] of Object.entries(page.properties)) {
switch (prop.type) {
case 'title':
row[name] = prop.title.map(t => t.plain_text).join('');
break;
case 'rich_text':
row[name] = prop.rich_text.map(t => t.plain_text).join('');
break;
case 'number':
row[name] = prop.number;
break;
case 'select':
row[name] = prop.select?.name ?? null;
break;
case 'multi_select':
row[name] = prop.multi_select.map(s => s.name).join(', ');
break;
case 'date':
row[name] = prop.date?.start ?? null;
break;
case 'checkbox':
row[name] = prop.checkbox;
break;
case 'url':
row[name] = prop.url;
break;
case 'email':
row[name] = prop.email;
break;
case 'phone_number':
row[name] = prop.phone_number;
break;
case 'people':
row[name] = prop.people.map(p => ('name' in p ? p.name : p.id)).join(', ');
break;
case 'relation':
row[name] = prop.relation.map(r => r.id).join(', ');
break;
default:
row[name] = `[${prop.type}]`;
}
}
return row;
}
// Export entire database with automatic pagination
async function exportDatabase(databaseId: string): Promise<Record<string, any>[]> {
const allRows: Record<string, any>[] = [];
let cursor: string | undefined;
let pageCount = 0;
do {
const response = await notion.databases.query({
database_id: databaseId,
page_size: 100,
start_cursor: cursor,
});
for (const page of response.results) {
if ('properties' in page) {
allRows.push(extractProperties(page as PageObjectResponse));
}
}
pageCount++;
console.log(`Fetched page ${pageCount} (${allRows.length} total records)`);
cursor = response.has_more ? response.next_cursor ?? undefined : undefined;
} while (cursor);
returnRelated in Productivity
gitea-workflow
IncludedOrchestrate agile development workflows for Gitea repositories using the tea CLI. Use when working with Gitea-hosted repos and asking to 'run the workflow', 'continue working', 'what's next', 'complete the task cycle', 'start my day', 'end the sprint', 'implement the next task', or wanting guided step-by-step development assistance. Keywords: workflow, orchestrate, agile, task cycle, sprint, daily, implement, review, PR, standup, retrospective, gitea, tea.
microsoft-graph-gateway
IncludedRoute Microsoft Graph work in this workspace. Use when users want to read or write Outlook mail, calendar events, contacts, OneDrive or SharePoint files, Teams, Planner, To Do, users, groups, directory data, or arbitrary Microsoft Graph endpoints from VS Code. Prefer WorkIQ for common read scenarios. Use Microsoft Graph for write actions and gap-read scenarios that need exact Graph properties, filters, permissions, or endpoints.
copilotkit
IncludedUse when building with CopilotKit — setup, development, integrations, debugging, upgrading, or contributing. Routes to the appropriate specialized skill based on the task.
wordly-wisdom
IncludedProvides calibrated decision analysis using Charlie Munger-style multiple mental models, inversion, incentive mapping, circle-of-competence checks, misjudgment audits, second-order effects, and forecast updates. Use when the user asks for an oracle take, a hard call, a decision memo, a premortem, an outside view, a red-team, a sanity-check, what am I missing, think this through, or wants a strategy, hire, investment, plan, product, partnership, or major life choice analysed. Avoid for simple factual lookups or time-sensitive legal, medical, or market questions without fresh evidence.
swain-session
IncludedSession management and project status dashboard. Owns the full session lifecycle (start/work/close/resume), focus lane, bookmarks, worktree detection, and tab naming. Also serves as the project status dashboard — shows active epics, progress, actionable next steps, blocked items, tasks, GitHub issues, and recommendations. Worktree creation is deferred to swain-do task dispatch (SPEC-195). Triggers on: 'session', 'status', 'what's next', 'dashboard', 'overview', 'where are we', 'what should I work on', 'show me priorities', 'bookmark', 'focus on', 'session info'.
gandi
IncludedComprehensive Gandi domain registrar integration for domain and DNS management. Register and manage domains, create/update/delete DNS records (A, AAAA, CNAME, MX, TXT, SRV, and more), configure email forwarding and aliases, check SSL certificate status, create DNS snapshots for safe rollback, bulk update zone files, and monitor domain expiration. Supports multi-domain management, zone file import/export, and automated DNS backups. Includes both read-only and destructive operations with safety controls.