There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
feat(server): add doc history support (#4970)
liuyib7d6237c2042
diff --git a/packages/backend/server/migrations/20231117062115_history/migration.sql b/packages/backend/server/migrations/20231117062115_history/migration.sqlnew file mode 100644index 0000000000..c432a65431--- /dev/null+++ b/packages/backend/server/migrations/20231117062115_history/migration.sql@@ -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")+);diff --git a/packages/backend/server/schema.prisma b/packages/backend/server/schema.prismaindex 892810ca42..b8a78d3df4 100644--- a/packages/backend/server/schema.prisma+++ b/packages/backend/server/schema.prisma@@ -164,12 +164,14 @@ model VerificationToken {}model Blob {- id Int @id @default(autoincrement()) @db.Integer- hash String @db.VarChar- workspaceId String @map("workspace_id") @db.VarChar- blob Bytes @db.ByteA+ id Int @id @default(autoincrement()) @db.Integer+ hash String @db.VarChar+ workspaceId String @map("workspace_id") @db.VarChar+ blob Bytes @db.ByteAlength 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])@@map("blobs")@@ -191,8 +193,8 @@ model OptimizedBlob {// the latest snapshot of each doc that we've seen// Snapshot + Updates are the latest state of the docmodel Snapshot {- id String @default(uuid()) @map("guid") @db.VarCharworkspaceId String @map("workspace_id") @db.VarChar+ id String @default(uuid()) @map("guid") @db.VarCharblob Bytes @db.ByteAseq Int @default(0) @db.Integerstate Bytes? @db.ByteA@@ -214,6 +216,18 @@ model Update {@@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 {id String @id @default(uuid()) @db.VarCharemail String @unique