Add white migration (#3334)
This PR adds a down migration for #3321. ### Change Type - [x] `sdk` — Changes the tldraw SDK - [x] `dunno` — I don't know
This commit is contained in:
parent
0161ec796e
commit
43edeb09b5
3 changed files with 48 additions and 3 deletions
|
@ -2387,7 +2387,7 @@
|
|||
},
|
||||
{
|
||||
"kind": "Content",
|
||||
"text": "Value | (() => Value)"
|
||||
"text": "(() => Value) | Value"
|
||||
},
|
||||
{
|
||||
"kind": "Content",
|
||||
|
@ -2813,7 +2813,7 @@
|
|||
},
|
||||
{
|
||||
"kind": "Content",
|
||||
"text": "undefined | any[]"
|
||||
"text": "any[] | undefined"
|
||||
},
|
||||
{
|
||||
"kind": "Content",
|
||||
|
|
|
@ -2030,6 +2030,34 @@ describe('Fractional indexing for line points', () => {
|
|||
})
|
||||
})
|
||||
|
||||
describe('add white', () => {
|
||||
const { up, down } = rootShapeMigrations.migrators[rootShapeVersions.AddWhite]
|
||||
|
||||
test('up works as expected', () => {
|
||||
expect(
|
||||
up({
|
||||
props: {},
|
||||
})
|
||||
).toEqual({
|
||||
props: {},
|
||||
})
|
||||
})
|
||||
|
||||
test('down works as expected', () => {
|
||||
expect(
|
||||
down({
|
||||
props: {
|
||||
color: 'white',
|
||||
},
|
||||
})
|
||||
).toEqual({
|
||||
props: {
|
||||
color: 'black',
|
||||
},
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
/* --- PUT YOUR MIGRATIONS TESTS ABOVE HERE --- */
|
||||
|
||||
for (const migrator of allMigrators) {
|
||||
|
|
|
@ -87,11 +87,12 @@ export const rootShapeVersions = {
|
|||
AddIsLocked: 1,
|
||||
HoistOpacity: 2,
|
||||
AddMeta: 3,
|
||||
AddWhite: 4,
|
||||
} as const
|
||||
|
||||
/** @internal */
|
||||
export const rootShapeMigrations = defineMigrations({
|
||||
currentVersion: rootShapeVersions.AddMeta,
|
||||
currentVersion: rootShapeVersions.AddWhite,
|
||||
migrators: {
|
||||
[rootShapeVersions.AddIsLocked]: {
|
||||
up: (record) => {
|
||||
|
@ -147,6 +148,22 @@ export const rootShapeMigrations = defineMigrations({
|
|||
}
|
||||
},
|
||||
},
|
||||
[rootShapeVersions.AddWhite]: {
|
||||
up: (record) => {
|
||||
return {
|
||||
...record,
|
||||
}
|
||||
},
|
||||
down: (record) => {
|
||||
return {
|
||||
...record,
|
||||
props: {
|
||||
...record.props,
|
||||
color: record.props.color === 'white' ? 'black' : record.props.color,
|
||||
},
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in a new issue