mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 04:18:54 +00:00
feat(server): add doc history support (#4970)
This commit is contained in:
@@ -0,0 +1,14 @@
|
|||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "blobs" ADD COLUMN "deleted_at" TIMESTAMPTZ(6);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "snapshot_histories" (
|
||||||
|
"workspace_id" VARCHAR(36) NOT NULL,
|
||||||
|
"guid" VARCHAR(36) NOT NULL,
|
||||||
|
"seq" INTEGER NOT NULL,
|
||||||
|
"blob" BYTEA NOT NULL,
|
||||||
|
"state" BYTEA,
|
||||||
|
"created_at" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
|
||||||
|
CONSTRAINT "snapshot_histories_pkey" PRIMARY KEY ("workspace_id","guid","seq")
|
||||||
|
);
|
||||||
@@ -164,12 +164,14 @@ model VerificationToken {
|
|||||||
}
|
}
|
||||||
|
|
||||||
model Blob {
|
model Blob {
|
||||||
id Int @id @default(autoincrement()) @db.Integer
|
id Int @id @default(autoincrement()) @db.Integer
|
||||||
hash String @db.VarChar
|
hash String @db.VarChar
|
||||||
workspaceId String @map("workspace_id") @db.VarChar
|
workspaceId String @map("workspace_id") @db.VarChar
|
||||||
blob Bytes @db.ByteA
|
blob Bytes @db.ByteA
|
||||||
length BigInt
|
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])
|
@@unique([workspaceId, hash])
|
||||||
@@map("blobs")
|
@@map("blobs")
|
||||||
@@ -191,8 +193,8 @@ model OptimizedBlob {
|
|||||||
// the latest snapshot of each doc that we've seen
|
// the latest snapshot of each doc that we've seen
|
||||||
// Snapshot + Updates are the latest state of the doc
|
// Snapshot + Updates are the latest state of the doc
|
||||||
model Snapshot {
|
model Snapshot {
|
||||||
id String @default(uuid()) @map("guid") @db.VarChar
|
|
||||||
workspaceId String @map("workspace_id") @db.VarChar
|
workspaceId String @map("workspace_id") @db.VarChar
|
||||||
|
id String @default(uuid()) @map("guid") @db.VarChar
|
||||||
blob Bytes @db.ByteA
|
blob Bytes @db.ByteA
|
||||||
seq Int @default(0) @db.Integer
|
seq Int @default(0) @db.Integer
|
||||||
state Bytes? @db.ByteA
|
state Bytes? @db.ByteA
|
||||||
@@ -214,6 +216,18 @@ model Update {
|
|||||||
@@map("updates")
|
@@map("updates")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
model SnapshotHistory {
|
||||||
|
workspaceId String @map("workspace_id") @db.VarChar(36)
|
||||||
|
id String @map("guid") @db.VarChar(36)
|
||||||
|
seq Int @db.Integer
|
||||||
|
blob Bytes @db.ByteA
|
||||||
|
state Bytes? @db.ByteA
|
||||||
|
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)
|
||||||
|
|
||||||
|
@@id([workspaceId, id, seq])
|
||||||
|
@@map("snapshot_histories")
|
||||||
|
}
|
||||||
|
|
||||||
model NewFeaturesWaitingList {
|
model NewFeaturesWaitingList {
|
||||||
id String @id @default(uuid()) @db.VarChar
|
id String @id @default(uuid()) @db.VarChar
|
||||||
email String @unique
|
email String @unique
|
||||||
|
|||||||
Reference in New Issue
Block a user