Skip to main content

Migration Guide: V1 to V2 Schema

This document outlines the key differences between Drafft V1 and V2 schemas to help you migrate your projects and understand the structural changes.

Breaking Changes Overview

The migration from V1 to V2 includes several notable changes:

  1. Content Structure Changes: The content property now contains type-specific structured data rather than direct values
  2. Dialogue Structure Changes: Complete overhaul of dialogue representation from graph to tree structure
  3. New Properties: Additional metadata fields across all collections
  4. Collection-specific Properties: More specialized properties for each collection type

Common Changes Across All Collections

ChangeV1 SchemaV2 SchemaImpact
Content StructureDirect propertiesNested in content objectBreaking Change: All content access requires .content prefix
CommentsNot standardizedStandardized comments field (for future use)Enhancement: Consistent commenting across objects

Folders Collection Changes

ChangeV1 SchemaV2 SchemaImpact
ChildrenArray of ID stringsArray of objects with _id propertyBreaking Change: Children structure changed from simple IDs to objects

GDD Collection Changes

ChangeV1 SchemaV2 SchemaImpact
GDD ContentDirect propertyNested as content.gddBreaking Change: GDD content access path changed
GDD FormatMArkdown and HTMLMarkdown OnlyBreaking Change: HTML support dropped

Scripts Collection Changes

ChangeV1 SchemaV2 SchemaImpact
Script ContentDirect propertyNested as content.scriptBreaking Change: Script content access path changed
Editor ModescriptEditorModeeditorModeBreaking Change: Property renamed

Code Example: Accessing Script Content

// V1
const scriptContent = script.content;

// V2
const scriptContent = script.content.script;

Dialogues Collection Changes

ChangeV1 SchemaV2 SchemaImpact
Structuregraph with nodes and linkstree with nodes and edgesBreaking Change: Complete restructuring of dialogue format
Positioningx/y coordinatesposition.x/position.y objectsBreaking Change: Node positioning access changed
Connection Modellinks and portsSimplified edgesBreaking Change: Connection model completely changed
Node PropertiesVarious direct propertiesRestructured under dataBreaking Change: Node property access paths changed

Code Example: Accessing Dialogue Nodes

// V1
const nodes = dialogue.graph.nodes;
const nodePosition = { x: nodes[0].x, y: nodes[0].y };

// V2
const nodes = dialogue.content.tree.nodes;
const nodePosition = nodes[0].position;

Actors Collection Changes

ChangeV1 SchemaV2 SchemaImpact
ContentDirect propertyAll props below are now nested under contentBreaking Change: Actor content access path changed
BioDirect bio property (HTML)content.bio (Markdown)Breaking Change: Format change from HTML to Markdown
ExpressionsDirect propertyNested as content.expressionsBreaking Change: Expressions access path changed
PropertiesDirect properties propertycontent.propertiesBreaking Change: Properties access path changed
AttachmentsStored with document as _attachmentsRemoved (using drafft:// protocol)Breaking Change: Attachment storage mechanism changed

Code Example: Accessing Actor Properties

// V1
const actorProperties = JSON.parse(actor.properties); // Direct access to properties

// V2
const rawProperties = actor.content.properties; // Available under content. Could be parsed manually

Grids Collection Changes

ChangeV1 SchemaV2 SchemaImpact
ColumnsDirect columns propertyNested as content.columnsBreaking Change: Columns access path changed
DataDirect data propertyNested as content.dataBreaking Change: Data access path changed
Data StructureLess detailedComprehensive cell/column modelEnhancement: More powerful grid capabilities
StylingNot standardizedDetailed style objectNew Feature: Cell-level styling support
Worksheet MetadataNot presentAdded worksheetId and worksheetNameEnhancement: Better worksheet identification (For future use)

Kanban Collection Changes

info

Under development

Other Changes

ChangeV1 SchemaV2 SchemaImpact
Hotkeys CollectionPresentRemovedBreaking Change: Hotkeys collection no longer exists

Migration Helper

Check this script for a reference implementation (under development)

Conclusion

The migration from V1 to V2 schema represents a significant evolution in the data model, offering more structure, better organization, and enhanced capabilities. While the changes do introduce breaking changes, the resulting schema is more robust and future-proof.

The most critical changes are in the content access patterns and the dialogue structure. By following this migration guide, you should be able to successfully update your application to support the V2 schema while understanding the architectural improvements it brings.