mirror of
https://github.com/documenso/documenso.git
synced 2025-11-12 07:43:16 +10:00
## Description Direct templates links is a feature that provides template owners the ability to allow users to create documents based of their templates. ## General outline This works by allowing the template owner to configure a "direct recipient" in the template. When a user opens the direct link to the template, it will create a flow where they sign the fields configured by the template owner for the direct recipient. After these fields are signed the following will occur: - A document will be created where the owner is the template owner - The direct recipient fields will be signed - The document will be sent to any other recipients configured in the template - If there are none the document will be immediately completed ## Notes There's a custom prisma migration to migrate all documents to have 'DOCUMENT' as the source, then sets the column to required. --------- Co-authored-by: Lucas Smith <me@lucasjamessmith.me>
46 lines
1.5 KiB
SQL
46 lines
1.5 KiB
SQL
/*
|
|
Warnings:
|
|
|
|
- Added the required column `source` to the `Document` table without a default value. This is not possible if the table is not empty.
|
|
|
|
*/
|
|
-- CreateEnum
|
|
CREATE TYPE "DocumentSource" AS ENUM ('DOCUMENT', 'TEMPLATE', 'TEMPLATE_DIRECT_LINK');
|
|
|
|
-- AlterTable
|
|
ALTER TABLE "Document" ADD COLUMN "source" "DocumentSource",
|
|
ADD COLUMN "templateId" INTEGER;
|
|
|
|
-- Custom: UpdateTable
|
|
UPDATE "Document" SET "source" = 'DOCUMENT' WHERE "source" IS NULL;
|
|
|
|
-- Custom: AlterColumn
|
|
ALTER TABLE "Document" ALTER COLUMN "source" SET NOT NULL;
|
|
|
|
-- CreateTable
|
|
CREATE TABLE "TemplateDirectLink" (
|
|
"id" TEXT NOT NULL,
|
|
"templateId" INTEGER NOT NULL,
|
|
"token" TEXT NOT NULL,
|
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
"enabled" BOOLEAN NOT NULL,
|
|
"directTemplateRecipientId" INTEGER NOT NULL,
|
|
|
|
CONSTRAINT "TemplateDirectLink_pkey" PRIMARY KEY ("id")
|
|
);
|
|
|
|
-- CreateIndex
|
|
CREATE UNIQUE INDEX "TemplateDirectLink_id_key" ON "TemplateDirectLink"("id");
|
|
|
|
-- CreateIndex
|
|
CREATE UNIQUE INDEX "TemplateDirectLink_templateId_key" ON "TemplateDirectLink"("templateId");
|
|
|
|
-- CreateIndex
|
|
CREATE UNIQUE INDEX "TemplateDirectLink_token_key" ON "TemplateDirectLink"("token");
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "Document" ADD CONSTRAINT "Document_templateId_fkey" FOREIGN KEY ("templateId") REFERENCES "Template"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "TemplateDirectLink" ADD CONSTRAINT "TemplateDirectLink_templateId_fkey" FOREIGN KEY ("templateId") REFERENCES "Template"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|