TLPropsMigration
See source codeTable of contents
A migration definition for shape or record properties.
Defines how to transform record properties when migrating between schema versions.
Each migration has an up
function to upgrade data and an optional down
function
to downgrade data if needed.
interface TLPropsMigration {}
Example
const addColorMigration: TLPropsMigration = {
id: 'com.myapp.shape.custom/1.0.0',
up: (props) => {
// Add a default color property
return { ...props, color: 'black' }
},
down: (props) => {
// Remove the color property
const { color, ...rest } = props
return rest
},
}
Properties
dependsOn
readonlyoptional
readonly dependsOn?: MigrationId[]
down
readonlyoptional
If a down migration was deployed more than a couple of months ago it should be safe to retire it. We only really need them to smooth over the transition between versions, and some folks do keep browser tabs open for months without refreshing, but at a certain point that kind of behavior is on them. Plus anyway recently chrome has started to actually kill tabs that are open for too long rather than just suspending them, so if other browsers follow suit maybe it's less of a concern.
readonly down?: 'none' | 'retired' | ((props: any) => any)
id
readonly
readonly id: MigrationId
up
readonly
readonly up: (props: any) => any
Prev
TLPresenceUserInfoNext
TLPropsMigrations