mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00:00
close CLOUD-226 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced support for comments and replies within workspaces and documents, enabling users to create, update, delete, and resolve comments, as well as manage threaded replies. - **Bug Fixes** - Added user-friendly error messages and handling for situations where comments or replies are not found. - **Tests** - Added comprehensive tests to ensure correct behavior of comment and reply operations. - **Localization** - Added English translations for new comment and reply error messages. <!-- end of auto-generated comment: release notes by coderabbit.ai --> #### PR Dependency Tree * **PR #12760** 👈 * **PR #12909** * **PR #12911** * **PR #12761** * **PR #12924** * **PR #12925** This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal)
68 lines
2.4 KiB
SQL
68 lines
2.4 KiB
SQL
-- CreateTable
|
|
CREATE TABLE "comments" (
|
|
"sid" INT GENERATED BY DEFAULT AS IDENTITY,
|
|
"id" VARCHAR NOT NULL,
|
|
"workspace_id" VARCHAR NOT NULL,
|
|
"doc_id" VARCHAR NOT NULL,
|
|
"user_id" VARCHAR NOT NULL,
|
|
"content" JSONB NOT NULL,
|
|
"created_at" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
"updated_at" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
"deleted_at" TIMESTAMPTZ(3),
|
|
"resolved" BOOLEAN NOT NULL DEFAULT false,
|
|
|
|
CONSTRAINT "comments_pkey" PRIMARY KEY ("id")
|
|
);
|
|
|
|
-- CreateTable
|
|
CREATE TABLE "replies" (
|
|
"sid" INT GENERATED BY DEFAULT AS IDENTITY,
|
|
"id" VARCHAR NOT NULL,
|
|
"user_id" VARCHAR NOT NULL,
|
|
"comment_id" VARCHAR NOT NULL,
|
|
"workspace_id" VARCHAR NOT NULL,
|
|
"doc_id" VARCHAR NOT NULL,
|
|
"content" JSONB NOT NULL,
|
|
"created_at" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
"updated_at" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
"deleted_at" TIMESTAMPTZ(3),
|
|
|
|
CONSTRAINT "replies_pkey" PRIMARY KEY ("id")
|
|
);
|
|
|
|
-- CreateIndex
|
|
CREATE UNIQUE INDEX "comments_sid_key" ON "comments"("sid");
|
|
|
|
-- CreateIndex
|
|
CREATE INDEX "comments_workspace_id_doc_id_sid_idx" ON "comments"("workspace_id", "doc_id", "sid");
|
|
|
|
-- CreateIndex
|
|
CREATE INDEX "comments_workspace_id_doc_id_updated_at_idx" ON "comments"("workspace_id", "doc_id", "updated_at");
|
|
|
|
-- CreateIndex
|
|
CREATE INDEX "comments_user_id_idx" ON "comments"("user_id");
|
|
|
|
-- CreateIndex
|
|
CREATE UNIQUE INDEX "replies_sid_key" ON "replies"("sid");
|
|
|
|
-- CreateIndex
|
|
CREATE INDEX "replies_comment_id_sid_idx" ON "replies"("comment_id", "sid");
|
|
|
|
-- CreateIndex
|
|
CREATE INDEX "replies_workspace_id_doc_id_updated_at_idx" ON "replies"("workspace_id", "doc_id", "updated_at");
|
|
|
|
-- CreateIndex
|
|
CREATE INDEX "replies_user_id_idx" ON "replies"("user_id");
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "comments" ADD CONSTRAINT "comments_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "comments" ADD CONSTRAINT "comments_workspace_id_fkey" FOREIGN KEY ("workspace_id") REFERENCES "workspaces"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "replies" ADD CONSTRAINT "replies_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "replies" ADD CONSTRAINT "replies_comment_id_fkey" FOREIGN KEY ("comment_id") REFERENCES "comments"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|