From 8cc9a0b21b5d8b4cefcadaf17ebf144d94e7b7e8 Mon Sep 17 00:00:00 2001 From: liuyi Date: Mon, 27 Nov 2023 07:06:30 +0000 Subject: [PATCH] feat(server): add soft deleted flag to optimized blob table (#5058) requires https://github.com/toeverything/OctoBase/pull/561 --- Cargo.lock | 10 +++++----- .../migration.sql | 2 ++ packages/backend/server/schema.prisma | 14 ++++++++------ packages/backend/storage/Cargo.toml | 6 +++--- 4 files changed, 18 insertions(+), 14 deletions(-) create mode 100644 packages/backend/server/migrations/20231124091123_soft_delete_opt_blobs/migration.sql diff --git a/Cargo.lock b/Cargo.lock index 4f03beba90..3a340d7113 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1112,7 +1112,7 @@ dependencies = [ [[package]] name = "jwst-codec" version = "0.1.0" -source = "git+https://github.com/toeverything/OctoBase.git?rev=aad9e5b#aad9e5b7e9d6f479e6cf7555f5845bbbaaadbc66" +source = "git+https://github.com/toeverything/OctoBase.git?rev=49a6b7a#49a6b7af25ce1fe54e8383e10980e9536821d286" dependencies = [ "arbitrary", "bitvec", @@ -1133,7 +1133,7 @@ dependencies = [ [[package]] name = "jwst-core" version = "0.1.0" -source = "git+https://github.com/toeverything/OctoBase.git?rev=aad9e5b#aad9e5b7e9d6f479e6cf7555f5845bbbaaadbc66" +source = "git+https://github.com/toeverything/OctoBase.git?rev=49a6b7a#49a6b7af25ce1fe54e8383e10980e9536821d286" dependencies = [ "async-trait", "base64", @@ -1151,7 +1151,7 @@ dependencies = [ [[package]] name = "jwst-logger" version = "0.1.0" -source = "git+https://github.com/toeverything/OctoBase.git?rev=aad9e5b#aad9e5b7e9d6f479e6cf7555f5845bbbaaadbc66" +source = "git+https://github.com/toeverything/OctoBase.git?rev=49a6b7a#49a6b7af25ce1fe54e8383e10980e9536821d286" dependencies = [ "chrono", "nu-ansi-term 0.49.0", @@ -1164,7 +1164,7 @@ dependencies = [ [[package]] name = "jwst-storage" version = "0.1.0" -source = "git+https://github.com/toeverything/OctoBase.git?rev=aad9e5b#aad9e5b7e9d6f479e6cf7555f5845bbbaaadbc66" +source = "git+https://github.com/toeverything/OctoBase.git?rev=49a6b7a#49a6b7af25ce1fe54e8383e10980e9536821d286" dependencies = [ "anyhow", "async-trait", @@ -1189,7 +1189,7 @@ dependencies = [ [[package]] name = "jwst-storage-migration" version = "0.1.0" -source = "git+https://github.com/toeverything/OctoBase.git?rev=aad9e5b#aad9e5b7e9d6f479e6cf7555f5845bbbaaadbc66" +source = "git+https://github.com/toeverything/OctoBase.git?rev=49a6b7a#49a6b7af25ce1fe54e8383e10980e9536821d286" dependencies = [ "sea-orm-migration", "tokio", 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 0000000000..6e107ce072 --- /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 a35a4187d2..640ad71c4a 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") diff --git a/packages/backend/storage/Cargo.toml b/packages/backend/storage/Cargo.toml index 7ccff97bdd..b1374cac9f 100644 --- a/packages/backend/storage/Cargo.toml +++ b/packages/backend/storage/Cargo.toml @@ -8,9 +8,9 @@ crate-type = ["cdylib"] [dependencies] chrono = "0.4" -jwst-codec = { git = "https://github.com/toeverything/OctoBase.git", rev = "aad9e5b" } -jwst-core = { git = "https://github.com/toeverything/OctoBase.git", rev = "aad9e5b" } -jwst-storage = { git = "https://github.com/toeverything/OctoBase.git", rev = "aad9e5b" } +jwst-codec = { git = "https://github.com/toeverything/OctoBase.git", rev = "49a6b7a" } +jwst-core = { git = "https://github.com/toeverything/OctoBase.git", rev = "49a6b7a" } +jwst-storage = { git = "https://github.com/toeverything/OctoBase.git", rev = "49a6b7a" } napi = { version = "2", default-features = false, features = [ "napi5", "async",