feat: support migration (#2852)

This commit is contained in:
Alex Yang
2023-06-26 15:55:44 +08:00
committed by GitHub
parent 002e64c819
commit 8e82d1e02c
14 changed files with 395 additions and 119 deletions
@@ -1,5 +1,6 @@
import type { WorkspaceFlavour } from '@affine/env/workspace';
import type { WorkspaceRegistry } from '@affine/env/workspace';
import { WorkspaceVersion } from '@affine/env/workspace';
import { rootWorkspacesMetadataAtom } from '@affine/workspace/atom';
import { useSetAtom } from 'jotai';
import { useCallback } from 'react';
@@ -7,7 +8,7 @@ import { useCallback } from 'react';
import { WorkspaceAdapters } from '../adapters/workspace';
/**
* Transform workspace from one flavour to another
* Transform workspace from one flavor to another
*
* The logic here is to delete the old workspace and create a new one.
*/
@@ -29,6 +30,7 @@ export function useTransformWorkspace() {
workspaces.splice(idx, 1, {
id: newId,
flavour: to,
version: WorkspaceVersion.SubDoc,
});
return [...workspaces];
});
+3 -1
View File
@@ -1,5 +1,5 @@
import { DebugLogger } from '@affine/debug';
import { WorkspaceFlavour } from '@affine/env/workspace';
import { WorkspaceFlavour, WorkspaceVersion } from '@affine/env/workspace';
import { rootWorkspacesMetadataAtom } from '@affine/workspace/atom';
import { saveWorkspaceToLocalStorage } from '@affine/workspace/local/crud';
import { createEmptyBlockSuiteWorkspace } from '@affine/workspace/utils';
@@ -34,6 +34,7 @@ export function useAppHelper() {
{
id: workspaceId,
flavour: WorkspaceFlavour.LOCAL,
version: WorkspaceVersion.SubDoc,
},
]);
logger.debug('imported local workspace', workspaceId);
@@ -54,6 +55,7 @@ export function useAppHelper() {
{
id,
flavour: WorkspaceFlavour.LOCAL,
version: WorkspaceVersion.SubDoc,
},
]);
logger.debug('created local workspace', id);