mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 08:13:56 +10:00
chore: tidy migrations
This commit is contained in:
@ -1,52 +0,0 @@
|
|||||||
-- CreateEnum
|
|
||||||
CREATE TYPE "TemplateStatus" AS ENUM ('PUBLIC', 'PRIVATE');
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "Template" (
|
|
||||||
"id" SERIAL NOT NULL,
|
|
||||||
"userId" INTEGER NOT NULL,
|
|
||||||
"title" TEXT NOT NULL,
|
|
||||||
"description" TEXT,
|
|
||||||
"status" "TemplateStatus" NOT NULL DEFAULT 'PRIVATE',
|
|
||||||
"templateDataId" TEXT NOT NULL,
|
|
||||||
|
|
||||||
CONSTRAINT "Template_pkey" PRIMARY KEY ("id")
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "TemplateData" (
|
|
||||||
"id" TEXT NOT NULL,
|
|
||||||
"type" "DocumentDataType" NOT NULL,
|
|
||||||
"data" TEXT NOT NULL,
|
|
||||||
"initialData" TEXT NOT NULL,
|
|
||||||
|
|
||||||
CONSTRAINT "TemplateData_pkey" PRIMARY KEY ("id")
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "TemplateField" (
|
|
||||||
"id" SERIAL NOT NULL,
|
|
||||||
"templateId" INTEGER NOT NULL,
|
|
||||||
"type" "FieldType" NOT NULL,
|
|
||||||
"page" INTEGER NOT NULL,
|
|
||||||
"positionX" DECIMAL(65,30) NOT NULL DEFAULT 0,
|
|
||||||
"positionY" DECIMAL(65,30) NOT NULL DEFAULT 0,
|
|
||||||
"width" DECIMAL(65,30) NOT NULL DEFAULT -1,
|
|
||||||
"height" DECIMAL(65,30) NOT NULL DEFAULT -1,
|
|
||||||
"customText" TEXT NOT NULL,
|
|
||||||
"inserted" BOOLEAN NOT NULL,
|
|
||||||
|
|
||||||
CONSTRAINT "TemplateField_pkey" PRIMARY KEY ("id")
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "Template_templateDataId_key" ON "Template"("templateDataId");
|
|
||||||
|
|
||||||
-- AddForeignKey
|
|
||||||
ALTER TABLE "Template" ADD CONSTRAINT "Template_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
||||||
|
|
||||||
-- AddForeignKey
|
|
||||||
ALTER TABLE "Template" ADD CONSTRAINT "Template_templateDataId_fkey" FOREIGN KEY ("templateDataId") REFERENCES "TemplateData"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
||||||
|
|
||||||
-- AddForeignKey
|
|
||||||
ALTER TABLE "TemplateField" ADD CONSTRAINT "TemplateField_templateId_fkey" FOREIGN KEY ("templateId") REFERENCES "Template"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
||||||
@ -1,15 +0,0 @@
|
|||||||
/*
|
|
||||||
Warnings:
|
|
||||||
|
|
||||||
- The `status` column on the `Template` table would be dropped and recreated. This will lead to data loss if there is data in the column.
|
|
||||||
|
|
||||||
*/
|
|
||||||
-- CreateEnum
|
|
||||||
CREATE TYPE "TemplateType" AS ENUM ('PUBLIC', 'PRIVATE');
|
|
||||||
|
|
||||||
-- AlterTable
|
|
||||||
ALTER TABLE "Template" DROP COLUMN "status",
|
|
||||||
ADD COLUMN "status" "TemplateType" NOT NULL DEFAULT 'PRIVATE';
|
|
||||||
|
|
||||||
-- DropEnum
|
|
||||||
DROP TYPE "TemplateStatus";
|
|
||||||
@ -1,14 +0,0 @@
|
|||||||
/*
|
|
||||||
Warnings:
|
|
||||||
|
|
||||||
- You are about to drop the `TemplateData` table. If the table is not empty, all the data it contains will be lost.
|
|
||||||
|
|
||||||
*/
|
|
||||||
-- DropForeignKey
|
|
||||||
ALTER TABLE "Template" DROP CONSTRAINT "Template_templateDataId_fkey";
|
|
||||||
|
|
||||||
-- DropTable
|
|
||||||
DROP TABLE "TemplateData";
|
|
||||||
|
|
||||||
-- AddForeignKey
|
|
||||||
ALTER TABLE "Template" ADD CONSTRAINT "Template_templateDataId_fkey" FOREIGN KEY ("templateDataId") REFERENCES "DocumentData"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
/*
|
|
||||||
Warnings:
|
|
||||||
|
|
||||||
- You are about to drop the column `inserted` on the `TemplateField` table. All the data in the column will be lost.
|
|
||||||
|
|
||||||
*/
|
|
||||||
-- AlterTable
|
|
||||||
ALTER TABLE "TemplateField" DROP COLUMN "inserted";
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
/*
|
|
||||||
Warnings:
|
|
||||||
|
|
||||||
- Added the required column `documentName` to the `Template` table without a default value. This is not possible if the table is not empty.
|
|
||||||
|
|
||||||
*/
|
|
||||||
-- AlterTable
|
|
||||||
ALTER TABLE "Template" ADD COLUMN "documentName" TEXT NOT NULL;
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
/*
|
|
||||||
Warnings:
|
|
||||||
|
|
||||||
- Added the required column `updatedAt` to the `Template` table without a default value. This is not possible if the table is not empty.
|
|
||||||
|
|
||||||
*/
|
|
||||||
-- AlterTable
|
|
||||||
ALTER TABLE "Template" ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL;
|
|
||||||
@ -1,51 +0,0 @@
|
|||||||
/*
|
|
||||||
Warnings:
|
|
||||||
|
|
||||||
- You are about to drop the column `description` on the `Template` table. All the data in the column will be lost.
|
|
||||||
- You are about to drop the column `documentName` on the `Template` table. All the data in the column will be lost.
|
|
||||||
- You are about to drop the column `status` on the `Template` table. All the data in the column will be lost.
|
|
||||||
- You are about to drop the column `templateDataId` on the `Template` table. All the data in the column will be lost.
|
|
||||||
- A unique constraint covering the columns `[tempateDocumentDataId]` on the table `Template` will be added. If there are existing duplicate values, this will fail.
|
|
||||||
- Added the required column `tempateDocumentDataId` to the `Template` table without a default value. This is not possible if the table is not empty.
|
|
||||||
- Added the required column `inserted` to the `TemplateField` table without a default value. This is not possible if the table is not empty.
|
|
||||||
|
|
||||||
*/
|
|
||||||
-- DropForeignKey
|
|
||||||
ALTER TABLE "Template" DROP CONSTRAINT "Template_templateDataId_fkey";
|
|
||||||
|
|
||||||
-- DropIndex
|
|
||||||
DROP INDEX "Template_templateDataId_key";
|
|
||||||
|
|
||||||
-- AlterTable
|
|
||||||
ALTER TABLE "Template" DROP COLUMN "description",
|
|
||||||
DROP COLUMN "documentName",
|
|
||||||
DROP COLUMN "status",
|
|
||||||
DROP COLUMN "templateDataId",
|
|
||||||
ADD COLUMN "tempateDocumentDataId" TEXT NOT NULL,
|
|
||||||
ADD COLUMN "type" "TemplateType" NOT NULL DEFAULT 'PRIVATE',
|
|
||||||
ALTER COLUMN "updatedAt" SET DEFAULT CURRENT_TIMESTAMP;
|
|
||||||
|
|
||||||
-- AlterTable
|
|
||||||
ALTER TABLE "TemplateField" ADD COLUMN "inserted" BOOLEAN NOT NULL,
|
|
||||||
ADD COLUMN "recipientId" INTEGER;
|
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "TemplateRecipient" (
|
|
||||||
"id" SERIAL NOT NULL,
|
|
||||||
"templateId" INTEGER NOT NULL,
|
|
||||||
"placeholder" VARCHAR(255) NOT NULL,
|
|
||||||
|
|
||||||
CONSTRAINT "TemplateRecipient_pkey" PRIMARY KEY ("id")
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "Template_tempateDocumentDataId_key" ON "Template"("tempateDocumentDataId");
|
|
||||||
|
|
||||||
-- AddForeignKey
|
|
||||||
ALTER TABLE "Template" ADD CONSTRAINT "Template_tempateDocumentDataId_fkey" FOREIGN KEY ("tempateDocumentDataId") REFERENCES "DocumentData"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
||||||
|
|
||||||
-- AddForeignKey
|
|
||||||
ALTER TABLE "TemplateRecipient" ADD CONSTRAINT "TemplateRecipient_templateId_fkey" FOREIGN KEY ("templateId") REFERENCES "Template"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
||||||
|
|
||||||
-- AddForeignKey
|
|
||||||
ALTER TABLE "TemplateField" ADD CONSTRAINT "TemplateField_recipientId_fkey" FOREIGN KEY ("recipientId") REFERENCES "TemplateRecipient"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
||||||
@ -1,23 +0,0 @@
|
|||||||
/*
|
|
||||||
Warnings:
|
|
||||||
|
|
||||||
- You are about to drop the column `tempateDocumentDataId` on the `Template` table. All the data in the column will be lost.
|
|
||||||
- A unique constraint covering the columns `[templateDocumentDataId]` on the table `Template` will be added. If there are existing duplicate values, this will fail.
|
|
||||||
- Added the required column `templateDocumentDataId` to the `Template` table without a default value. This is not possible if the table is not empty.
|
|
||||||
|
|
||||||
*/
|
|
||||||
-- DropForeignKey
|
|
||||||
ALTER TABLE "Template" DROP CONSTRAINT "Template_tempateDocumentDataId_fkey";
|
|
||||||
|
|
||||||
-- DropIndex
|
|
||||||
DROP INDEX "Template_tempateDocumentDataId_key";
|
|
||||||
|
|
||||||
-- AlterTable
|
|
||||||
ALTER TABLE "Template" DROP COLUMN "tempateDocumentDataId",
|
|
||||||
ADD COLUMN "templateDocumentDataId" TEXT NOT NULL;
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "Template_templateDocumentDataId_key" ON "Template"("templateDocumentDataId");
|
|
||||||
|
|
||||||
-- AddForeignKey
|
|
||||||
ALTER TABLE "Template" ADD CONSTRAINT "Template_templateDocumentDataId_fkey" FOREIGN KEY ("templateDocumentDataId") REFERENCES "DocumentData"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
/*
|
|
||||||
Warnings:
|
|
||||||
|
|
||||||
- Added the required column `email` to the `TemplateRecipient` table without a default value. This is not possible if the table is not empty.
|
|
||||||
|
|
||||||
*/
|
|
||||||
-- AlterTable
|
|
||||||
ALTER TABLE "TemplateRecipient" ADD COLUMN "email" VARCHAR(255) NOT NULL;
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
/*
|
|
||||||
Warnings:
|
|
||||||
|
|
||||||
- Added the required column `token` to the `TemplateRecipient` table without a default value. This is not possible if the table is not empty.
|
|
||||||
|
|
||||||
*/
|
|
||||||
-- AlterTable
|
|
||||||
ALTER TABLE "TemplateRecipient" ADD COLUMN "token" TEXT NOT NULL;
|
|
||||||
@ -1,5 +0,0 @@
|
|||||||
-- AlterTable
|
|
||||||
ALTER TABLE "Recipient" ADD COLUMN "templateToken" TEXT;
|
|
||||||
|
|
||||||
-- AlterTable
|
|
||||||
ALTER TABLE "TemplateRecipient" ADD COLUMN "templateToken" TEXT;
|
|
||||||
@ -1,10 +0,0 @@
|
|||||||
/*
|
|
||||||
Warnings:
|
|
||||||
|
|
||||||
- You are about to drop the column `placeholder` on the `TemplateRecipient` table. All the data in the column will be lost.
|
|
||||||
- Added the required column `name` to the `TemplateRecipient` table without a default value. This is not possible if the table is not empty.
|
|
||||||
|
|
||||||
*/
|
|
||||||
-- AlterTable
|
|
||||||
ALTER TABLE "TemplateRecipient" DROP COLUMN "placeholder",
|
|
||||||
ADD COLUMN "name" VARCHAR(255) NOT NULL;
|
|
||||||
@ -1,54 +0,0 @@
|
|||||||
/*
|
|
||||||
Warnings:
|
|
||||||
|
|
||||||
- You are about to drop the `TemplateField` table. If the table is not empty, all the data it contains will be lost.
|
|
||||||
- You are about to drop the `TemplateRecipient` table. If the table is not empty, all the data it contains will be lost.
|
|
||||||
- A unique constraint covering the columns `[templateId,email]` on the table `Recipient` will be added. If there are existing duplicate values, this will fail.
|
|
||||||
|
|
||||||
*/
|
|
||||||
-- DropForeignKey
|
|
||||||
ALTER TABLE "Field" DROP CONSTRAINT "Field_recipientId_fkey";
|
|
||||||
|
|
||||||
-- DropForeignKey
|
|
||||||
ALTER TABLE "TemplateField" DROP CONSTRAINT "TemplateField_recipientId_fkey";
|
|
||||||
|
|
||||||
-- DropForeignKey
|
|
||||||
ALTER TABLE "TemplateField" DROP CONSTRAINT "TemplateField_templateId_fkey";
|
|
||||||
|
|
||||||
-- DropForeignKey
|
|
||||||
ALTER TABLE "TemplateRecipient" DROP CONSTRAINT "TemplateRecipient_templateId_fkey";
|
|
||||||
|
|
||||||
-- AlterTable
|
|
||||||
ALTER TABLE "Field" ADD COLUMN "templateId" INTEGER,
|
|
||||||
ALTER COLUMN "documentId" DROP NOT NULL;
|
|
||||||
|
|
||||||
-- AlterTable
|
|
||||||
ALTER TABLE "Recipient" ADD COLUMN "templateId" INTEGER,
|
|
||||||
ALTER COLUMN "documentId" DROP NOT NULL,
|
|
||||||
ALTER COLUMN "readStatus" DROP NOT NULL,
|
|
||||||
ALTER COLUMN "signingStatus" DROP NOT NULL,
|
|
||||||
ALTER COLUMN "sendStatus" DROP NOT NULL;
|
|
||||||
|
|
||||||
-- DropTable
|
|
||||||
DROP TABLE "TemplateField";
|
|
||||||
|
|
||||||
-- DropTable
|
|
||||||
DROP TABLE "TemplateRecipient";
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE INDEX "Field_templateId_idx" ON "Field"("templateId");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE INDEX "Recipient_templateId_idx" ON "Recipient"("templateId");
|
|
||||||
|
|
||||||
-- CreateIndex
|
|
||||||
CREATE UNIQUE INDEX "Recipient_templateId_email_key" ON "Recipient"("templateId", "email");
|
|
||||||
|
|
||||||
-- AddForeignKey
|
|
||||||
ALTER TABLE "Recipient" ADD CONSTRAINT "Recipient_templateId_fkey" FOREIGN KEY ("templateId") REFERENCES "Template"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
||||||
|
|
||||||
-- AddForeignKey
|
|
||||||
ALTER TABLE "Field" ADD CONSTRAINT "Field_templateId_fkey" FOREIGN KEY ("templateId") REFERENCES "Template"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
||||||
|
|
||||||
-- AddForeignKey
|
|
||||||
ALTER TABLE "Field" ADD CONSTRAINT "Field_recipientId_fkey" FOREIGN KEY ("recipientId") REFERENCES "Recipient"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
/*
|
|
||||||
Warnings:
|
|
||||||
|
|
||||||
- You are about to drop the column `templateToken` on the `Recipient` table. All the data in the column will be lost.
|
|
||||||
|
|
||||||
*/
|
|
||||||
-- AlterTable
|
|
||||||
ALTER TABLE "Recipient" DROP COLUMN "templateToken";
|
|
||||||
@ -1,12 +0,0 @@
|
|||||||
/*
|
|
||||||
Warnings:
|
|
||||||
|
|
||||||
- Made the column `readStatus` on table `Recipient` required. This step will fail if there are existing NULL values in that column.
|
|
||||||
- Made the column `signingStatus` on table `Recipient` required. This step will fail if there are existing NULL values in that column.
|
|
||||||
- Made the column `sendStatus` on table `Recipient` required. This step will fail if there are existing NULL values in that column.
|
|
||||||
|
|
||||||
*/
|
|
||||||
-- AlterTable
|
|
||||||
ALTER TABLE "Recipient" ALTER COLUMN "readStatus" SET NOT NULL,
|
|
||||||
ALTER COLUMN "signingStatus" SET NOT NULL,
|
|
||||||
ALTER COLUMN "sendStatus" SET NOT NULL;
|
|
||||||
@ -0,0 +1,73 @@
|
|||||||
|
/*
|
||||||
|
Warnings:
|
||||||
|
|
||||||
|
- A unique constraint covering the columns `[templateId,email]` on the table `Recipient` will be added. If there are existing duplicate values, this will fail.
|
||||||
|
|
||||||
|
*/
|
||||||
|
-- CreateEnum
|
||||||
|
CREATE TYPE "TemplateType" AS ENUM ('PUBLIC', 'PRIVATE');
|
||||||
|
|
||||||
|
-- DropForeignKey
|
||||||
|
ALTER TABLE "Field" DROP CONSTRAINT "Field_recipientId_fkey";
|
||||||
|
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "Field" ADD COLUMN "templateId" INTEGER,
|
||||||
|
ALTER COLUMN "documentId" DROP NOT NULL;
|
||||||
|
|
||||||
|
-- AlterTable
|
||||||
|
-- Add CHECK constraint to ensure that only one of the two columns is set
|
||||||
|
ALTER TABLE "Field" ADD CONSTRAINT "Field_templateId_documentId_check" CHECK (
|
||||||
|
("templateId" IS NULL AND "documentId" IS NOT NULL) OR
|
||||||
|
("templateId" IS NOT NULL AND "documentId" IS NULL)
|
||||||
|
);
|
||||||
|
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "Recipient" ADD COLUMN "templateId" INTEGER,
|
||||||
|
ALTER COLUMN "documentId" DROP NOT NULL;
|
||||||
|
|
||||||
|
-- AlterTable
|
||||||
|
-- Add CHECK constraint to ensure that only one of the two columns is set
|
||||||
|
ALTER TABLE "Recipient" ADD CONSTRAINT "Recipient_templateId_documentId_check" CHECK (
|
||||||
|
("templateId" IS NULL AND "documentId" IS NOT NULL) OR
|
||||||
|
("templateId" IS NOT NULL AND "documentId" IS NULL)
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "Template" (
|
||||||
|
"id" SERIAL NOT NULL,
|
||||||
|
"type" "TemplateType" NOT NULL DEFAULT 'PRIVATE',
|
||||||
|
"title" TEXT NOT NULL,
|
||||||
|
"userId" INTEGER NOT NULL,
|
||||||
|
"templateDocumentDataId" TEXT NOT NULL,
|
||||||
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
|
||||||
|
CONSTRAINT "Template_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "Template_templateDocumentDataId_key" ON "Template"("templateDocumentDataId");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE INDEX "Field_templateId_idx" ON "Field"("templateId");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE INDEX "Recipient_templateId_idx" ON "Recipient"("templateId");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "Recipient_templateId_email_key" ON "Recipient"("templateId", "email");
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "Recipient" ADD CONSTRAINT "Recipient_templateId_fkey" FOREIGN KEY ("templateId") REFERENCES "Template"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "Field" ADD CONSTRAINT "Field_templateId_fkey" FOREIGN KEY ("templateId") REFERENCES "Template"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "Field" ADD CONSTRAINT "Field_recipientId_fkey" FOREIGN KEY ("recipientId") REFERENCES "Recipient"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "Template" ADD CONSTRAINT "Template_templateDocumentDataId_fkey" FOREIGN KEY ("templateDocumentDataId") REFERENCES "DocumentData"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "Template" ADD CONSTRAINT "Template_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
Reference in New Issue
Block a user