migrating-to-db

Expert guidance for migrating Logseq graphs from Markdown (MD) format to the new Database (DB) format. Auto-invokes when users ask about MD to DB migration, converting graphs, import options, data transformation, or compatibility between Logseq versions. Covers migration strategies, common issues, and best practices.

25 stars

Best use case

migrating-to-db is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Expert guidance for migrating Logseq graphs from Markdown (MD) format to the new Database (DB) format. Auto-invokes when users ask about MD to DB migration, converting graphs, import options, data transformation, or compatibility between Logseq versions. Covers migration strategies, common issues, and best practices.

Teams using migrating-to-db should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/migrating-to-db/SKILL.md --create-dirs "https://raw.githubusercontent.com/ComeOnOliver/skillshub/main/skills/aiskillstore/marketplace/c0ntr0lledcha0s/migrating-to-db/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/migrating-to-db/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How migrating-to-db Compares

Feature / Agentmigrating-to-dbStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Expert guidance for migrating Logseq graphs from Markdown (MD) format to the new Database (DB) format. Auto-invokes when users ask about MD to DB migration, converting graphs, import options, data transformation, or compatibility between Logseq versions. Covers migration strategies, common issues, and best practices.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Migrating to Logseq DB

## When to Use This Skill

This skill auto-invokes when:
- User asks about migrating from Logseq MD to DB version
- Converting markdown graphs to database format
- Import/export between Logseq versions
- Questions about what transfers during migration
- Namespace handling during migration
- Tag-to-class conversion decisions
- Property type inference during import
- User mentions "migrate", "convert", "MD to DB", "markdown to database"

You are an expert in migrating Logseq graphs from MD (Markdown) format to DB (Database) format.

## Migration Overview

### Why Migrate?

| Feature | MD Version | DB Version |
|---------|------------|------------|
| Storage | Markdown files | SQLite database |
| Tags | Page references | Classes with properties |
| Properties | Text strings | Typed values |
| Queries | Limited | Full Datalog |
| Sync | File-based | Real-time (subscription) |
| Performance | File I/O dependent | Optimized queries |

### Current Status (2024-2025)

**Important**: Logseq DB is still in **alpha**. Consider:
- Data loss risk exists
- Some features not yet available (whiteboards)
- Plugin compatibility varies
- Requires subscription for sync

## Pre-Migration Checklist

Before migrating, assess your graph:

### 1. Backup Everything
```bash
# Create timestamped backup
cp -r ~/logseq/my-graph ~/logseq/my-graph-backup-$(date +%Y%m%d)

# Or compress
tar -czvf my-graph-backup.tar.gz ~/logseq/my-graph
```

### 2. Audit Current Structure

**Pages to review:**
- [ ] Namespaced pages (a/b/c) → May become separate pages
- [ ] Pages with same name, different namespaces
- [ ] Template pages
- [ ] Query pages

**Properties to review:**
- [ ] Property formats (key:: value)
- [ ] Multi-value properties
- [ ] Date properties
- [ ] Linked properties ([[page]])

**Tags to review:**
- [ ] Simple tags (#tag)
- [ ] Page tags ([[tag]])
- [ ] Nested tags (#parent/child)

### 3. Identify Migration Decisions

| MD Pattern | DB Options | Decision Needed |
|------------|------------|-----------------|
| `#tag` | Class or page ref | Which tags become classes? |
| `[[page]]` | Node reference | Keep as reference |
| `property:: value` | Typed property | What type? |
| `namespace/page` | Separate page or hierarchy | Flatten or nest? |

## Migration Process

### Step 1: Export from MD Version

1. Open your MD graph in Logseq
2. Go to **Settings** → **Export**
3. Choose **Export to EDN** (for full data)
4. Save the export file

### Step 2: Prepare Import Settings

When importing to DB, you'll choose:

**Tag Handling:**
- **Convert to classes**: Tags become proper classes with inherited properties
- **Keep as references**: Tags remain simple page links

**Namespace Handling:**
- **Flatten**: `a/b/c` → single page "a/b/c"
- **Hierarchical**: Creates page hierarchy

**Property Handling:**
- **Infer types**: Logseq guesses types (number, date, etc.)
- **All as text**: Everything stays as strings

### Step 3: Create New DB Graph

1. Create new DB-based graph in Logseq
2. Use **Import** feature
3. Select your exported data
4. Configure migration options
5. Review and confirm

### Step 4: Post-Migration Validation

```clojure
;; Check page count matches
[:find (count ?p)
 :where [?p :block/tags ?t]
        [?t :db/ident :logseq.class/Page]]

;; Check for orphaned blocks
[:find (pull ?b [:block/title])
 :where [?b :block/title _]
        (not [?b :block/page _])
        (not [?b :block/tags ?t]
             [?t :db/ident :logseq.class/Page])]

;; Verify properties migrated
[:find ?prop-name (count ?b)
 :where [?b ?prop _]
        [?p :db/ident ?prop]
        [?p :block/title ?prop-name]
        [(clojure.string/starts-with? (str ?prop) ":user.property")]]
```

## Common Migration Issues

### Issue 1: Lost Property Types

**Symptom**: Numbers/dates stored as strings

**Solution**: Manually update property types
```clojure
;; In DB, update property type
{:db/ident :user.property/rating
 :logseq.property/type :number}  ; was :default
```

### Issue 2: Tag/Class Confusion

**Symptom**: Tags didn't become proper classes

**Solution**: Convert pages to classes
1. Open the tag page
2. Add `#Tag` to make it a class
3. Define properties on the class

### Issue 3: Broken References

**Symptom**: `[[page]]` links not working

**Cause**: Page names changed during migration

**Solution**: Use find/replace or query to identify broken refs
```clojure
[:find ?ref-text
 :where
 [?b :block/title ?title]
 [(re-find #"\[\[.*?\]\]" ?title) ?ref-text]
 (not [_ :block/title ?ref-text])]
```

### Issue 4: Namespace Flattening

**Symptom**: `project/tasks` and `project/notes` merged

**Solution**: Pre-migration, rename pages to avoid conflicts

### Issue 5: Query Compatibility

**Symptom**: Old queries don't work

**Reason**: Different attribute names

| MD Attribute | DB Attribute |
|--------------|--------------|
| `:block/content` | `:block/title` |
| `:block/name` | `:block/title` |
| `:page/tags` | `:block/tags` |

## Migration Strategies

### Strategy 1: Big Bang Migration

- Migrate entire graph at once
- Best for: Small graphs, simple structure
- Risk: All-or-nothing

### Strategy 2: Parallel Operation

- Keep MD graph active
- Create DB graph for new content
- Gradually move old content
- Best for: Large graphs, active use

### Strategy 3: Selective Migration

- Export specific pages/areas
- Import into new DB graph
- Best for: Messy graphs needing cleanup

## Best Practices

### Before Migration

1. **Clean up your graph**
   - Remove unused pages
   - Standardize property names
   - Fix broken links

2. **Document your structure**
   - List all tags and their purposes
   - Document property meanings
   - Map namespaces

3. **Plan your classes**
   - Which tags become classes?
   - What properties do they need?
   - Define inheritance hierarchy

### During Migration

1. **Start small** - Test with a subset
2. **Compare counts** - Pages, blocks, properties
3. **Check critical pages** - Most important content first
4. **Verify queries** - Update and test all queries

### After Migration

1. **Don't delete MD graph** - Keep as backup
2. **Monitor for issues** - Note problems for feedback
3. **Update workflows** - Adapt to new features
4. **Explore new capabilities** - Classes, typed properties

## Feature Comparison

### Available in DB Version
- ✅ Typed properties (number, date, checkbox)
- ✅ Class inheritance
- ✅ Property schemas
- ✅ Full Datalog queries
- ✅ Real-time collaboration (Pro)
- ✅ Library view

### Not Yet Available (Alpha)
- ⏳ Whiteboards
- ⏳ Some plugins
- ⏳ Full export options
- ⏳ Advanced templates

### Different Behavior
- 📝 Tags = Classes (more powerful but different)
- 📝 Sync requires subscription
- 📝 File access limited (SQLite, not .md)

## Resources

- [Logseq DB Documentation](https://github.com/logseq/docs/blob/master/db-version.md)
- [DB Unofficial FAQ](https://discuss.logseq.com/t/logseq-db-unofficial-faq/32508)
- [Migration Feedback Thread](https://discuss.logseq.com/t/logseq-db-changelog/30013)

Related Skills

migrating-oracle-to-postgres-stored-procedures

25
from ComeOnOliver/skillshub

Migrates Oracle PL/SQL stored procedures to PostgreSQL PL/pgSQL. Translates Oracle-specific syntax, preserves method signatures and type-anchored parameters, leverages orafce where appropriate, and applies COLLATE "C" for Oracle-compatible text sorting. Use when converting Oracle stored procedures or functions to PostgreSQL equivalents during a database migration.

migrating-dbt-project-across-platforms

25
from ComeOnOliver/skillshub

Use when migrating a dbt project from one data platform or data warehouse to another (e.g., Snowflake to Databricks, Databricks to Snowflake) using dbt Fusion's real-time compilation to identify and fix SQL dialect differences.

migrating-dbt-core-to-fusion

25
from ComeOnOliver/skillshub

Classifies dbt-core to Fusion migration errors into actionable categories (auto-fixable, guided fixes, needs input, blocked). Use when a user needs help triaging migration errors to understand what they can fix vs what requires Fusion engine updates.

api-gateway-config

25
from ComeOnOliver/skillshub

Api Gateway Config - Auto-activating skill for AWS Skills. Triggers on: api gateway config, api gateway config Part of the AWS Skills skill category.

fuzzing-apis

25
from ComeOnOliver/skillshub

This skill enables Claude to perform automated fuzz testing on APIs to discover vulnerabilities, crashes, and unexpected behavior. It leverages malformed inputs, boundary values, and random payloads to generate comprehensive fuzz test suites. Use this skill when you need to identify potential SQL injection, XSS, command injection vulnerabilities, input validation failures, and edge cases in APIs. Trigger this skill by requesting fuzz testing, vulnerability scanning, or security analysis of an API. The skill is invoked using the `/fuzz-api` command.

api-flow-diagram-creator

25
from ComeOnOliver/skillshub

Api Flow Diagram Creator - Auto-activating skill for Visual Content. Triggers on: api flow diagram creator, api flow diagram creator Part of the Visual Content skill category.

api-contract

25
from ComeOnOliver/skillshub

Configure this skill should be used when the user asks about "API contract", "api-contract.md", "shared interface", "TypeScript interfaces", "request response schemas", "endpoint design", or needs guidance on designing contracts that coordinate backend and frontend agents. Use when building or modifying API endpoints. Trigger with phrases like 'create API', 'design endpoint', or 'API scaffold'.

api-client-generator

25
from ComeOnOliver/skillshub

Api Client Generator - Auto-activating skill for API Integration. Triggers on: api client generator, api client generator Part of the API Integration skill category.

api-caching-strategy

25
from ComeOnOliver/skillshub

Api Caching Strategy - Auto-activating skill for API Development. Triggers on: api caching strategy, api caching strategy Part of the API Development skill category.

apdex-score-calculator

25
from ComeOnOliver/skillshub

Apdex Score Calculator - Auto-activating skill for Performance Testing. Triggers on: apdex score calculator, apdex score calculator Part of the Performance Testing skill category.

anth-webhooks-events

25
from ComeOnOliver/skillshub

Implement event-driven patterns with Claude API: streaming SSE events, Message Batches callbacks, and async processing architectures. Use when building real-time Claude integrations or processing batch results. Trigger with phrases like "anthropic events", "claude streaming events", "anthropic async processing", "claude batch callbacks".

anth-upgrade-migration

25
from ComeOnOliver/skillshub

Upgrade Anthropic SDK versions and migrate between Claude API versions. Use when upgrading the Python/TypeScript SDK, migrating from Text Completions to Messages API, or adopting new API features like tool use or batches. Trigger with phrases like "upgrade anthropic sdk", "anthropic migration", "update claude sdk", "migrate to messages api".