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.
What this skill does
# 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 in Writing & Docs
jax-development
IncludedUse this skill when the user is writing, debugging, profiling, refactoring, reviewing, benchmarking, parallelising, exporting, or explaining JAX code, or when they mention JAX, jax.numpy, jit, grad, value_and_grad, vmap, scan, lax, random keys, pytrees, jax.Array, sharding, Mesh, PartitionSpec, NamedSharding, pmap, shard_map, Pallas, XLA, StableHLO, checkify, profiler, or the JAX repo. It helps turn NumPy or PyTorch-style code into pure functional JAX, fix tracer/control-flow/shape/PRNG bugs, remove recompiles and host-device syncs, choose transforms and sharding strategies, inspect jaxpr/lowering/IR, and benchmark compiled code correctly.
nature-article-writer
IncludedDrafts, rewrites, diagnostically critiques, and style-calibrates primary research manuscripts for Nature and Nature Portfolio journals. Use when the user wants a Nature-style title, summary paragraph or abstract, introduction, results, discussion, methods, figure legends, presubmission enquiry, cover letter, reviewer response, or when a scientific draft sounds generic, jargon-heavy, structurally weak, or AI-ish and needs precise, broad-reader-friendly prose without inventing data, analyses, or references. Best for primary research articles and letters rather than reviews or press releases unless explicitly adapting one.
deckrd
IncludedDocument-driven framework that derives requirements, specifications, implementation plans, and executable tasks from goals through structured AI dialogue. Use when user says "write requirements", "create spec", "plan implementation", "derive tasks", "structure this feature", "break down into tasks", or "document this module". Also use for reverse engineering existing code into docs (/deckrd rev). Do NOT use for direct code writing — use /deckrd-coder after tasks are generated. Do NOT use when the user only wants to run or fix existing code without planning.
clinical-decision-support
IncludedGenerate professional clinical decision support (CDS) documents for pharmaceutical and clinical research settings, including patient cohort analyses (biomarker-stratified with outcomes) and treatment recommendation reports (evidence-based guidelines with decision algorithms). Supports GRADE evidence grading, statistical analysis (hazard ratios, survival curves, waterfall plots), biomarker integration, and regulatory compliance. Outputs publication-ready LaTeX/PDF format optimized for drug development, clinical research, and evidence synthesis.
handling-sf-data
IncludedSalesforce data operations with 130-point scoring. Use this skill to create, update, delete, bulk import/export, generate test data, and clean up org records using sf CLI and anonymous Apex. TRIGGER when: user creates test data, performs bulk import/export, uses sf data CLI commands, needs data factory patterns for Apex tests, or needs to seed/clean records in a Salesforce org. DO NOT TRIGGER when: SOQL query writing only (use querying-soql), Apex test execution (use running-apex-tests), or metadata deployment (use deploying-metadata).
accelint-ac-to-playwright
IncludedConvert and validate acceptance criteria for Playwright test automation. Use when user asks to (1) review/evaluate/check if AC are ready for automation, (2) assess if AC can be converted as-is, (3) validate AC quality for Playwright, (4) turn AC into tests, (5) generate tests from acceptance criteria, (6) convert .md bullets or .feature Gherkin files to Playwright specs, (7) create test automation from requirements. Handles both bullet-style markdown and Gherkin syntax with JSON test plan generation and validation.