Skip to content

Commit b1694a3

Browse files
Fall back to Postgres eventRepository for non-ClickHouse stores
Co-Authored-By: Matt Aitken <matt@mattaitken.com>
1 parent 5cd8588 commit b1694a3

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

apps/webapp/app/services/clickhouse/clickhouseFactory.server.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { singleton } from "~/utils/singleton";
66
import { organizationDataStoresRegistry } from "~/services/dataStores/organizationDataStoresRegistryInstance.server";
77
import type { OrganizationDataStoresRegistry } from "~/services/dataStores/organizationDataStoresRegistry.server";
88
import { type IEventRepository } from "~/v3/eventRepository/eventRepository.types";
9+
import { eventRepository as postgresEventRepository } from "~/v3/eventRepository/eventRepository.server";
910

1011
// ---------------------------------------------------------------------------
1112
// Default clients (singleton per process)
@@ -254,6 +255,14 @@ export class ClickhouseFactory {
254255
store: string,
255256
organizationId: string
256257
): { key: string; repository: IEventRepository } {
258+
// Non-ClickHouse stores (e.g. the "taskEvent" DB default for Postgres-backed
259+
// runs, or "postgres") fall back to the Prisma event repository. This lets
260+
// callers pass `run.taskEventStore` directly without needing to guard
261+
// against legacy/Postgres values.
262+
if (store !== "clickhouse" && store !== "clickhouse_v2") {
263+
return { key: `postgres:${store}`, repository: postgresEventRepository };
264+
}
265+
257266
const dataStore = this._registry.get(organizationId, "CLICKHOUSE");
258267

259268
if (!dataStore) {

apps/webapp/app/v3/eventRepository/index.server.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,12 @@ export async function getEventRepository(
7979
): Promise<{ repository: IEventRepository; store: string }> {
8080
const taskEventStore = parentStore ?? (await resolveTaskEventRepositoryFlag(featureFlags));
8181

82-
// Support legacy Postgres store for self-hosters
83-
if (taskEventStore === EVENT_STORE_TYPES.POSTGRES) {
82+
// Non-ClickHouse stores (e.g. the "taskEvent" DB default for Postgres-backed
83+
// runs, or the legacy "postgres" value) resolve to the Prisma event repo.
84+
if (
85+
taskEventStore !== EVENT_STORE_TYPES.CLICKHOUSE &&
86+
taskEventStore !== EVENT_STORE_TYPES.CLICKHOUSE_V2
87+
) {
8488
return { repository: eventRepository, store: getTaskEventStore() };
8589
}
8690

0 commit comments

Comments
 (0)