mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
fix(api-v1): add soft-delete filters and remove any types in database operation routes
This commit is contained in:
@@ -34,7 +34,7 @@ export const GET = withApiKey(
|
|||||||
),
|
),
|
||||||
with: {
|
with: {
|
||||||
storages: {
|
storages: {
|
||||||
where: (bs: any, { isNull: isNullFn }: any) => isNullFn(bs.deletedAt),
|
where: (bs, { isNull }) => isNull(bs.deletedAt),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { withApiKey, ApiKeyContext } from "@/lib/api-v1/middleware";
|
|||||||
import { getAccessibleDatabaseIds } from "@/lib/api-v1/acl";
|
import { getAccessibleDatabaseIds } from "@/lib/api-v1/acl";
|
||||||
import { db } from "@/db";
|
import { db } from "@/db";
|
||||||
import * as drizzleDb from "@/db";
|
import * as drizzleDb from "@/db";
|
||||||
import { eq, and } from "drizzle-orm";
|
import { eq, and, isNull } from "drizzle-orm";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { logger } from "@/lib/logger";
|
import { logger } from "@/lib/logger";
|
||||||
|
|
||||||
@@ -53,7 +53,8 @@ export const POST = withApiKey(
|
|||||||
const backupRecord = await db.query.backup.findFirst({
|
const backupRecord = await db.query.backup.findFirst({
|
||||||
where: and(
|
where: and(
|
||||||
eq(drizzleDb.schemas.backup.id, backupId),
|
eq(drizzleDb.schemas.backup.id, backupId),
|
||||||
eq(drizzleDb.schemas.backup.databaseId, id)
|
eq(drizzleDb.schemas.backup.databaseId, id),
|
||||||
|
isNull(drizzleDb.schemas.backup.deletedAt)
|
||||||
),
|
),
|
||||||
columns: { id: true },
|
columns: { id: true },
|
||||||
});
|
});
|
||||||
@@ -66,7 +67,8 @@ export const POST = withApiKey(
|
|||||||
const backupStorage = await db.query.backupStorage.findFirst({
|
const backupStorage = await db.query.backupStorage.findFirst({
|
||||||
where: and(
|
where: and(
|
||||||
eq(drizzleDb.schemas.backupStorage.id, backupStorageId),
|
eq(drizzleDb.schemas.backupStorage.id, backupStorageId),
|
||||||
eq(drizzleDb.schemas.backupStorage.backupId, backupId)
|
eq(drizzleDb.schemas.backupStorage.backupId, backupId),
|
||||||
|
isNull(drizzleDb.schemas.backupStorage.deletedAt)
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { withApiKey, ApiKeyContext } from "@/lib/api-v1/middleware";
|
|||||||
import { getAccessibleDatabaseIds } from "@/lib/api-v1/acl";
|
import { getAccessibleDatabaseIds } from "@/lib/api-v1/acl";
|
||||||
import { db } from "@/db";
|
import { db } from "@/db";
|
||||||
import * as drizzleDb from "@/db";
|
import * as drizzleDb from "@/db";
|
||||||
import { eq, desc } from "drizzle-orm";
|
import { eq, desc, and, isNull } from "drizzle-orm";
|
||||||
import { logger } from "@/lib/logger";
|
import { logger } from "@/lib/logger";
|
||||||
|
|
||||||
const log = logger.child({ module: "api/v1/databases/[id]/status" });
|
const log = logger.child({ module: "api/v1/databases/[id]/status" });
|
||||||
@@ -28,7 +28,10 @@ export const GET = withApiKey(
|
|||||||
|
|
||||||
const [latestBackup, latestRestoration] = await Promise.all([
|
const [latestBackup, latestRestoration] = await Promise.all([
|
||||||
db.query.backup.findFirst({
|
db.query.backup.findFirst({
|
||||||
where: eq(drizzleDb.schemas.backup.databaseId, id),
|
where: and(
|
||||||
|
eq(drizzleDb.schemas.backup.databaseId, id),
|
||||||
|
isNull(drizzleDb.schemas.backup.deletedAt)
|
||||||
|
),
|
||||||
orderBy: [desc(drizzleDb.schemas.backup.createdAt)],
|
orderBy: [desc(drizzleDb.schemas.backup.createdAt)],
|
||||||
}),
|
}),
|
||||||
db.query.restoration.findFirst({
|
db.query.restoration.findFirst({
|
||||||
|
|||||||
Reference in New Issue
Block a user