feat(db): add custom workspace name

This commit is contained in:
Haileyesus
2026-03-26 13:19:51 +03:00
parent fdad9acc2e
commit 24abcef110
4 changed files with 47 additions and 10 deletions

View File

@@ -1,4 +1,5 @@
import { getConnection } from '@/shared/database/connection.js';
import type { WorkspaceOriginalPathRow } from '@/shared/database/types.js';
export const workspaceOriginalPathsDb = {
createWorkspacePath(workspacePath: string): void {
@@ -9,4 +10,24 @@ export const workspaceOriginalPathsDb = {
ON CONFLICT(workspace_path) DO NOTHING
`).run(workspacePath);
},
}
getCustomWorkspaceName(workspacePath: string): string | null {
const db = getConnection();
const row = db.prepare(`
SELECT custom_workspace_name
FROM workspace_original_paths
WHERE workspace_path = ?
`).get(workspacePath) as Pick<WorkspaceOriginalPathRow, 'custom_workspace_name'> | undefined;
return row?.custom_workspace_name ?? null;
},
updateCustomWorkspaceName(workspacePath: string, customWorkspaceName: string | null): void {
const db = getConnection();
db.prepare(`
INSERT INTO workspace_original_paths (workspace_path, custom_workspace_name)
VALUES (?, ?)
ON CONFLICT(workspace_path) DO UPDATE SET custom_workspace_name = excluded.custom_workspace_name
`).run(workspacePath, customWorkspaceName);
},
}