Cange to use primaryDb

This commit is contained in:
Owen
2026-05-07 20:07:06 -07:00
parent c46ef2fe9c
commit 5b8994d143
2 changed files with 11 additions and 14 deletions

View File

@@ -10,7 +10,8 @@ import {
SiteResource, SiteResource,
siteResources, siteResources,
sites, sites,
userSiteResources userSiteResources,
primaryDb
} from "@server/db"; } from "@server/db";
import { getUniqueSiteResourceName } from "@server/db/names"; import { getUniqueSiteResourceName } from "@server/db/names";
import { import {
@@ -519,12 +520,10 @@ export async function createSiteResource(
// own transaction so it always executes on the primary — avoiding any // own transaction so it always executes on the primary — avoiding any
// replica-lag issues while still allowing the HTTP response to return // replica-lag issues while still allowing the HTTP response to return
// early. // early.
db.transaction(async (trx) => { rebuildClientAssociationsFromSiteResource(
await rebuildClientAssociationsFromSiteResource( newSiteResource!,
newSiteResource!, primaryDb
trx ).catch((err) => {
);
}).catch((err) => {
logger.error( logger.error(
`Error rebuilding client associations for site resource ${newSiteResource!.siteResourceId}:`, `Error rebuilding client associations for site resource ${newSiteResource!.siteResourceId}:`,
err err

View File

@@ -1,6 +1,6 @@
import { Request, Response, NextFunction } from "express"; import { Request, Response, NextFunction } from "express";
import { z } from "zod"; import { z } from "zod";
import { db, newts, sites } from "@server/db"; import { db, newts, primaryDb, sites } from "@server/db";
import { siteResources } from "@server/db"; import { siteResources } from "@server/db";
import response from "@server/lib/response"; import response from "@server/lib/response";
import HttpCode from "@server/types/HttpCode"; import HttpCode from "@server/types/HttpCode";
@@ -73,12 +73,10 @@ export async function deleteSiteResource(
// own transaction so it always executes on the primary — avoiding any // own transaction so it always executes on the primary — avoiding any
// replica-lag issues while still allowing the HTTP response to return // replica-lag issues while still allowing the HTTP response to return
// early. // early.
db.transaction(async (trx) => { rebuildClientAssociationsFromSiteResource(
await rebuildClientAssociationsFromSiteResource( removedSiteResource,
removedSiteResource, primaryDb
trx ).catch((err) => {
);
}).catch((err) => {
logger.error( logger.error(
`Error rebuilding client associations for site resource ${removedSiteResource!.siteResourceId}:`, `Error rebuilding client associations for site resource ${removedSiteResource!.siteResourceId}:`,
err err