From 1f14e2ce61d5c0b662250dfd6108ebd3dbbc830c Mon Sep 17 00:00:00 2001 From: forehalo Date: Fri, 24 Nov 2023 17:11:54 +0800 Subject: [PATCH] feat(server): add soft deleted flag to optimized blob table --- .../migration.sql | 2 ++ packages/backend/server/schema.prisma | 14 ++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 packages/backend/server/migrations/20231124091123_soft_delete_opt_blobs/migration.sql diff --git a/packages/backend/server/migrations/20231124091123_soft_delete_opt_blobs/migration.sql b/packages/backend/server/migrations/20231124091123_soft_delete_opt_blobs/migration.sql new file mode 100644 index 0000000000000..6e107ce0722b2 --- /dev/null +++ b/packages/backend/server/migrations/20231124091123_soft_delete_opt_blobs/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE "optimized_blobs" ADD COLUMN "deleted_at" TIMESTAMPTZ(6); diff --git a/packages/backend/server/schema.prisma b/packages/backend/server/schema.prisma index a35a4187d20cd..640ad71c4a4a6 100644 --- a/packages/backend/server/schema.prisma +++ b/packages/backend/server/schema.prisma @@ -178,13 +178,15 @@ model Blob { } model OptimizedBlob { - id Int @id @default(autoincrement()) @db.Integer - hash String @db.VarChar - workspaceId String @map("workspace_id") @db.VarChar - params String @db.VarChar - blob Bytes @db.ByteA + id Int @id @default(autoincrement()) @db.Integer + hash String @db.VarChar + workspaceId String @map("workspace_id") @db.VarChar + params String @db.VarChar + blob Bytes @db.ByteA length BigInt - createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6) + createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6) + // not for keeping, but for snapshot history + deletedAt DateTime? @map("deleted_at") @db.Timestamptz(6) @@unique([workspaceId, hash, params]) @@map("optimized_blobs")