blob: bedb47844a7e09aef1b6ebbd58b0113a06c59f25 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
import type { MigrationResult, ProjectRecord } from "./types";
import { getProjectId } from "./utils";
/**
* v31 → v32 introduces the `projectVersions` store (named checkpoints +
* auto-checkpoints; see notes/project-versioning.md). The store lives in its
* own IndexedDB database created lazily by the versions adapter, so project
* records need no shape change — this migration only stamps the new version.
*/
export function transformProjectV31ToV32({
project,
}: {
project: ProjectRecord;
}): MigrationResult<ProjectRecord> {
if (!getProjectId({ project })) {
return { project, skipped: true, reason: "no project id" };
}
const version = project.version;
if (typeof version !== "number") {
return { project, skipped: true, reason: "invalid version" };
}
if (version >= 32) {
return { project, skipped: true, reason: "already v32" };
}
if (version !== 31) {
return { project, skipped: true, reason: "not v31" };
}
return { project: { ...project, version: 32 }, skipped: false };
}
|