mirror of
https://github.com/colanode/colanode.git
synced 2025-12-29 00:25:03 +01:00
Init workspace database create on workspace create event
This commit is contained in:
@@ -6,6 +6,7 @@ import { appDatabaseMigrations } from '@/main/data/app/migrations';
|
||||
import { workspaceDatabaseMigrations } from '@/main/data/workspace/migrations';
|
||||
import { appDatabasePath, getWorkspaceDirectoryPath } from '@/main/utils';
|
||||
import SQLite from 'better-sqlite3';
|
||||
import { eventBus } from '@/shared/lib/event-bus';
|
||||
|
||||
class DatabaseService {
|
||||
private initPromise: Promise<void> | null = null;
|
||||
@@ -22,6 +23,12 @@ class DatabaseService {
|
||||
});
|
||||
|
||||
this.appDatabase = new Kysely<AppDatabaseSchema>({ dialect });
|
||||
|
||||
eventBus.subscribe((event) => {
|
||||
if (event.type === 'workspace_created') {
|
||||
this.initWorkspaceDatabase(event.workspace.userId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public async init(): Promise<void> {
|
||||
|
||||
@@ -23,7 +23,7 @@ export class WorkspaceGetQueryHandler
|
||||
public async checkForChanges(
|
||||
event: Event,
|
||||
input: WorkspaceGetQueryInput,
|
||||
output: Workspace | null
|
||||
_: Workspace | null
|
||||
): Promise<ChangeCheckResult<WorkspaceGetQueryInput>> {
|
||||
if (
|
||||
event.type === 'workspace_created' &&
|
||||
|
||||
Reference in New Issue
Block a user