diff --git a/components/db.ts b/components/db.ts index d92632f..d6ac4a0 100644 --- a/components/db.ts +++ b/components/db.ts @@ -26,11 +26,6 @@ export interface Icon { name: string } -export interface List { - order: string[] // Todo IDs - type: '#important' -} - export enum ListType { wayfinder, icebox, @@ -43,7 +38,6 @@ export interface Setting { export class DexieStarfocus extends Dexie { wayfinderOrder!: DexieCloudTable<{ todoId: string; order: string }, 'todoId'> - lists!: Table settings!: DexieCloudTable starRoles: DexieCloudTable starRolesOrder!: DexieCloudTable< @@ -80,6 +74,14 @@ export class DexieStarfocus extends Dexie { starRolesOrder: '&starRoleId, &order', todos: '@id, createdAt, completedAt, starRole, title', }) + this.version(5).stores({ + lists: null, + wayfinderOrder: '&todoId, &order', + settings: '&key', + starRoles: '@id, title', + starRolesOrder: '&starRoleId, &order', + todos: '@id, createdAt, completedAt, starRole, title', + }) this.cloud.configure({ databaseUrl: process.env.NEXT_PUBLIC_DATABASE_URL!, requireAuth: false, diff --git a/components/pages/Home.tsx b/components/pages/Home.tsx index 63d6bf0..f88b7b0 100644 --- a/components/pages/Home.tsx +++ b/components/pages/Home.tsx @@ -336,30 +336,6 @@ export const MiscMenu = () => { // Remove empty todos await db.todos.where('title').equals('').delete() - - // Remove todos from important list that don't exist - const important = await db.lists.get('#important') - const todos = await db.todos.bulkGet(important?.order || []) - const cleanedImportantOrder = _.zip(important!.order, todos) - .filter(([_id, todo]) => todo !== undefined) - .map(([id, _todo]) => id) as string[] - await db.lists.update('#important', { - order: cleanedImportantOrder, - }) - - // Migrate to new important order - const wayfinderOrder = await db.wayfinderOrder - .orderBy('order') - .keys() - if (wayfinderOrder.length === 0) { - const oldOrder = await db.lists.get('#important') - const orderKeys = starMudder(oldOrder?.order.length) - const records = oldOrder?.order.map(todoId => ({ - todoId, - order: orderKeys.shift(), - })) - db.wayfinderOrder.bulkAdd(records as any) - } }} > Clean database