createCustomRecordMigrationIds

See source code

Creates properly formatted migration IDs for custom record migrations.

Generates standardized migration IDs following the convention: com.tldraw.{recordType}/{version}

function createCustomRecordMigrationIds<
  const S extends string,
  const T extends Record<string, number>,
>(
  recordType: S,
  ids: T
): {
  [k in keyof T]: `com.tldraw.${S}/${T[k]}`
}

Example

const commentVersions = createCustomRecordMigrationIds('comment', {
  AddAuthorId: 1,
  AddCreatedAt: 2,
  RefactorReactions: 3,
})
// Result: {
//   AddAuthorId: 'com.tldraw.comment/1',
//   AddCreatedAt: 'com.tldraw.comment/2',
//   RefactorReactions: 'com.tldraw.comment/3'
// }

Parameters

NameDescription

recordType

S

The type name of the custom record

ids

T

Record mapping migration names to version numbers

Returns

{
  [k in keyof T]: `com.tldraw.${S}/${T[k]}`
}

Record with the same keys but formatted migration ID values

Prev
createCustomRecordId
Next
createCustomRecordMigrationSequence