MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / seedLegacyDatabase

Function seedLegacyDatabase

apps/desktop/src/main/databases-migrate.test.ts:28–48  ·  view source on GitHub ↗
(root: string)

Source from the content-addressed store, hash-verified

26// A minimal legacy database: loose `<Name>.csv` + co-located sidecar, with one
27// record-page note under the per-database `<Name>/` folder.
28async function seedLegacyDatabase(root: string): Promise<void> {
29 await writeFile(path.join(root, 'inbox', 'Books.csv'), 'id,Title\nr1,Dune\n', 'utf8')
30 await mkdir(path.join(root, 'inbox', 'Books'), { recursive: true })
31 await writeFile(path.join(root, 'inbox', 'Books', 'Dune.md'), '# Dune\n\nGreat book.', 'utf8')
32 const sidecar = {
33 version: 1,
34 idFieldId: 'f_id',
35 fields: [
36 { id: 'f_id', name: 'id', type: 'text', hidden: true },
37 { id: 'f_title', name: 'Title', type: 'text' }
38 ],
39 views: [{ id: 'v1', name: 'Table', type: 'table', filters: [], sorts: [] }],
40 activeViewId: 'v1',
41 pages: { r1: 'inbox/Books/Dune.md' }
42 }
43 await writeFile(
44 path.join(root, 'inbox', 'Books.csv.base.json'),
45 JSON.stringify(sidecar, null, 2),
46 'utf8'
47 )
48}
49
50describe('migrateLegacyDatabases (#185 .base reorg)', () => {
51 it('moves a legacy database into a self-contained .base folder', async () => {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected