mirror of
https://github.com/documenso/documenso.git
synced 2025-11-19 03:01:59 +10:00
fix: wip
This commit is contained in:
@ -0,0 +1,238 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `teamId` on the `Subscription` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `userId` on the `Subscription` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `customerId` on the `Team` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `ownerUserId` on the `Team` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `url` on the `User` table. All the data in the column will be lost.
|
||||
- You are about to drop the `TeamMember` table. If the table is not empty, all the data it contains will be lost.
|
||||
- You are about to drop the `TeamMemberInvite` table. If the table is not empty, all the data it contains will be lost.
|
||||
- You are about to drop the `TeamTransferVerification` table. If the table is not empty, all the data it contains will be lost.
|
||||
- Made the column `teamId` on table `Document` required. This step will fail if there are existing NULL values in that column.
|
||||
- Added the required column `organisationId` to the `Subscription` table without a default value. This is not possible if the table is not empty.
|
||||
- Added the required column `organisationId` to the `Team` table without a default value. This is not possible if the table is not empty.
|
||||
- Made the column `teamId` on table `Template` required. This step will fail if there are existing NULL values in that column.
|
||||
|
||||
*/
|
||||
-- CreateEnum
|
||||
CREATE TYPE "OrganisationGroupType" AS ENUM ('INTERNAL_ORGANISATION', 'INTERNAL_TEAM', 'CUSTOM');
|
||||
|
||||
-- CreateEnum
|
||||
CREATE TYPE "OrganisationMemberRole" AS ENUM ('ADMIN', 'MANAGER', 'MEMBER');
|
||||
|
||||
-- CreateEnum
|
||||
CREATE TYPE "OrganisationMemberInviteStatus" AS ENUM ('ACCEPTED', 'PENDING', 'DECLINED');
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "Document" DROP CONSTRAINT "Document_teamId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "Subscription" DROP CONSTRAINT "Subscription_teamId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "Subscription" DROP CONSTRAINT "Subscription_userId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "Team" DROP CONSTRAINT "Team_ownerUserId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "TeamMember" DROP CONSTRAINT "TeamMember_teamId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "TeamMember" DROP CONSTRAINT "TeamMember_userId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "TeamMemberInvite" DROP CONSTRAINT "TeamMemberInvite_teamId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "TeamTransferVerification" DROP CONSTRAINT "TeamTransferVerification_teamId_fkey";
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX "Subscription_teamId_key";
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX "Subscription_userId_idx";
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX "Team_customerId_key";
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX "User_url_key";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "ApiToken" ADD COLUMN "organisationId" TEXT;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Document" ALTER COLUMN "teamId" SET NOT NULL;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Subscription" DROP COLUMN "teamId",
|
||||
DROP COLUMN "userId",
|
||||
ADD COLUMN "organisationId" TEXT NOT NULL;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Team" DROP COLUMN "customerId",
|
||||
DROP COLUMN "ownerUserId",
|
||||
ADD COLUMN "organisationId" TEXT NOT NULL;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Template" ALTER COLUMN "teamId" SET NOT NULL;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "User" DROP COLUMN "url";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Webhook" ADD COLUMN "organisationId" TEXT;
|
||||
|
||||
-- DropTable
|
||||
DROP TABLE "TeamMember";
|
||||
|
||||
-- DropTable
|
||||
DROP TABLE "TeamMemberInvite";
|
||||
|
||||
-- DropTable
|
||||
DROP TABLE "TeamTransferVerification";
|
||||
|
||||
-- DropEnum
|
||||
DROP TYPE "TeamMemberInviteStatus";
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Organisation" (
|
||||
"id" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
"name" TEXT NOT NULL,
|
||||
"url" TEXT NOT NULL,
|
||||
"avatarImageId" TEXT,
|
||||
"customerId" TEXT,
|
||||
"ownerUserId" INTEGER NOT NULL,
|
||||
|
||||
CONSTRAINT "Organisation_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "OrganisationMember" (
|
||||
"id" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
"userId" INTEGER NOT NULL,
|
||||
"organisationId" TEXT NOT NULL,
|
||||
|
||||
CONSTRAINT "OrganisationMember_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "OrganisationMemberInvite" (
|
||||
"id" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"email" TEXT NOT NULL,
|
||||
"token" TEXT NOT NULL,
|
||||
"groupIds" TEXT[],
|
||||
"status" "OrganisationMemberInviteStatus" NOT NULL DEFAULT 'PENDING',
|
||||
"organisationId" TEXT NOT NULL,
|
||||
"organisationRole" "OrganisationMemberRole" NOT NULL,
|
||||
"teamId" INTEGER,
|
||||
"teamRole" "TeamMemberRole",
|
||||
|
||||
CONSTRAINT "OrganisationMemberInvite_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "OrganisationGroup" (
|
||||
"id" TEXT NOT NULL,
|
||||
"name" TEXT,
|
||||
"type" "OrganisationGroupType" NOT NULL,
|
||||
"organisationRole" "OrganisationMemberRole" NOT NULL,
|
||||
"organisationId" TEXT NOT NULL,
|
||||
|
||||
CONSTRAINT "OrganisationGroup_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "OrganisationGroupMember" (
|
||||
"id" TEXT NOT NULL,
|
||||
"groupId" TEXT NOT NULL,
|
||||
"organisationMemberId" TEXT,
|
||||
|
||||
CONSTRAINT "OrganisationGroupMember_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "TeamGroup" (
|
||||
"id" TEXT NOT NULL,
|
||||
"organisationGroupId" TEXT NOT NULL,
|
||||
"teamRole" "TeamMemberRole" NOT NULL,
|
||||
"teamId" INTEGER NOT NULL,
|
||||
|
||||
CONSTRAINT "TeamGroup_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Organisation_url_key" ON "Organisation"("url");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Organisation_customerId_key" ON "Organisation"("customerId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "OrganisationMember_userId_organisationId_key" ON "OrganisationMember"("userId", "organisationId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "OrganisationMemberInvite_token_key" ON "OrganisationMemberInvite"("token");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "OrganisationGroupMember_organisationMemberId_groupId_key" ON "OrganisationGroupMember"("organisationMemberId", "groupId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "Subscription_organisationId_idx" ON "Subscription"("organisationId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "Template_userId_idx" ON "Template"("userId");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Webhook" ADD CONSTRAINT "Webhook_organisationId_fkey" FOREIGN KEY ("organisationId") REFERENCES "Organisation"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "ApiToken" ADD CONSTRAINT "ApiToken_organisationId_fkey" FOREIGN KEY ("organisationId") REFERENCES "Organisation"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Subscription" ADD CONSTRAINT "Subscription_organisationId_fkey" FOREIGN KEY ("organisationId") REFERENCES "Organisation"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Document" ADD CONSTRAINT "Document_teamId_fkey" FOREIGN KEY ("teamId") REFERENCES "Team"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Organisation" ADD CONSTRAINT "Organisation_avatarImageId_fkey" FOREIGN KEY ("avatarImageId") REFERENCES "AvatarImage"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Organisation" ADD CONSTRAINT "Organisation_ownerUserId_fkey" FOREIGN KEY ("ownerUserId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "OrganisationMember" ADD CONSTRAINT "OrganisationMember_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "OrganisationMember" ADD CONSTRAINT "OrganisationMember_organisationId_fkey" FOREIGN KEY ("organisationId") REFERENCES "Organisation"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "OrganisationMemberInvite" ADD CONSTRAINT "OrganisationMemberInvite_organisationId_fkey" FOREIGN KEY ("organisationId") REFERENCES "Organisation"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "OrganisationMemberInvite" ADD CONSTRAINT "OrganisationMemberInvite_teamId_fkey" FOREIGN KEY ("teamId") REFERENCES "Team"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "OrganisationGroup" ADD CONSTRAINT "OrganisationGroup_organisationId_fkey" FOREIGN KEY ("organisationId") REFERENCES "Organisation"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "OrganisationGroupMember" ADD CONSTRAINT "OrganisationGroupMember_groupId_fkey" FOREIGN KEY ("groupId") REFERENCES "OrganisationGroup"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "OrganisationGroupMember" ADD CONSTRAINT "OrganisationGroupMember_organisationMemberId_fkey" FOREIGN KEY ("organisationMemberId") REFERENCES "OrganisationMember"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "TeamGroup" ADD CONSTRAINT "TeamGroup_organisationGroupId_fkey" FOREIGN KEY ("organisationGroupId") REFERENCES "OrganisationGroup"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "TeamGroup" ADD CONSTRAINT "TeamGroup_teamId_fkey" FOREIGN KEY ("teamId") REFERENCES "Team"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Team" ADD CONSTRAINT "Team_organisationId_fkey" FOREIGN KEY ("organisationId") REFERENCES "Organisation"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
14
packages/prisma/migrations/20250425052828_asdf/migration.sql
Normal file
14
packages/prisma/migrations/20250425052828_asdf/migration.sql
Normal file
@ -0,0 +1,14 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- Made the column `organisationMemberId` on table `OrganisationGroupMember` required. This step will fail if there are existing NULL values in that column.
|
||||
|
||||
*/
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "OrganisationGroupMember" DROP CONSTRAINT "OrganisationGroupMember_organisationMemberId_fkey";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "OrganisationGroupMember" ALTER COLUMN "organisationMemberId" SET NOT NULL;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "OrganisationGroupMember" ADD CONSTRAINT "OrganisationGroupMember_organisationMemberId_fkey" FOREIGN KEY ("organisationMemberId") REFERENCES "OrganisationMember"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
@ -0,0 +1,5 @@
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "OrganisationGroupMember" DROP CONSTRAINT "OrganisationGroupMember_organisationMemberId_fkey";
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "OrganisationGroupMember" ADD CONSTRAINT "OrganisationGroupMember_organisationMemberId_fkey" FOREIGN KEY ("organisationMemberId") REFERENCES "OrganisationMember"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@ -0,0 +1,17 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `teamId` on the `OrganisationMemberInvite` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `teamRole` on the `OrganisationMemberInvite` table. All the data in the column will be lost.
|
||||
- A unique constraint covering the columns `[teamId,organisationGroupId]` on the table `TeamGroup` will be added. If there are existing duplicate values, this will fail.
|
||||
|
||||
*/
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "OrganisationMemberInvite" DROP CONSTRAINT "OrganisationMemberInvite_teamId_fkey";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "OrganisationMemberInvite" DROP COLUMN "teamId",
|
||||
DROP COLUMN "teamRole";
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "TeamGroup_teamId_organisationGroupId_key" ON "TeamGroup"("teamId", "organisationGroupId");
|
||||
@ -0,0 +1,8 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `groupIds` on the `OrganisationMemberInvite` table. All the data in the column will be lost.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "OrganisationMemberInvite" DROP COLUMN "groupIds";
|
||||
82
packages/prisma/migrations/20250506035754_/migration.sql
Normal file
82
packages/prisma/migrations/20250506035754_/migration.sql
Normal file
@ -0,0 +1,82 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `teamId` on the `TeamGlobalSettings` table. All the data in the column will be lost.
|
||||
- A unique constraint covering the columns `[settingsId]` on the table `Organisation` will be added. If there are existing duplicate values, this will fail.
|
||||
- A unique constraint covering the columns `[settingsId]` on the table `Team` will be added. If there are existing duplicate values, this will fail.
|
||||
- Added the required column `settingsId` to the `Organisation` table without a default value. This is not possible if the table is not empty.
|
||||
- Added the required column `settingsId` to the `Team` table without a default value. This is not possible if the table is not empty.
|
||||
- The required column `id` was added to the `TeamGlobalSettings` table with a prisma-level default value. This is not possible if the table is not empty. Please add this column as optional, then populate it before making it required.
|
||||
|
||||
*/
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "TeamGlobalSettings" DROP CONSTRAINT "TeamGlobalSettings_teamId_fkey";
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX "TeamGlobalSettings_teamId_key";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Organisation" ADD COLUMN "settingsId" TEXT NOT NULL;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Team" ADD COLUMN "settingsId" TEXT NOT NULL;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "TeamGlobalSettings" DROP COLUMN "teamId",
|
||||
ADD COLUMN "id" TEXT NOT NULL,
|
||||
ALTER COLUMN "documentVisibility" DROP NOT NULL,
|
||||
ALTER COLUMN "documentVisibility" DROP DEFAULT,
|
||||
ALTER COLUMN "includeSenderDetails" DROP NOT NULL,
|
||||
ALTER COLUMN "includeSenderDetails" DROP DEFAULT,
|
||||
ALTER COLUMN "brandingCompanyDetails" DROP NOT NULL,
|
||||
ALTER COLUMN "brandingCompanyDetails" DROP DEFAULT,
|
||||
ALTER COLUMN "brandingEnabled" DROP NOT NULL,
|
||||
ALTER COLUMN "brandingEnabled" DROP DEFAULT,
|
||||
ALTER COLUMN "brandingHidePoweredBy" DROP NOT NULL,
|
||||
ALTER COLUMN "brandingHidePoweredBy" DROP DEFAULT,
|
||||
ALTER COLUMN "brandingLogo" DROP NOT NULL,
|
||||
ALTER COLUMN "brandingLogo" DROP DEFAULT,
|
||||
ALTER COLUMN "brandingUrl" DROP NOT NULL,
|
||||
ALTER COLUMN "brandingUrl" DROP DEFAULT,
|
||||
ALTER COLUMN "documentLanguage" DROP NOT NULL,
|
||||
ALTER COLUMN "documentLanguage" DROP DEFAULT,
|
||||
ALTER COLUMN "typedSignatureEnabled" DROP NOT NULL,
|
||||
ALTER COLUMN "typedSignatureEnabled" DROP DEFAULT,
|
||||
ALTER COLUMN "includeSigningCertificate" DROP NOT NULL,
|
||||
ALTER COLUMN "includeSigningCertificate" DROP DEFAULT,
|
||||
ALTER COLUMN "drawSignatureEnabled" DROP NOT NULL,
|
||||
ALTER COLUMN "drawSignatureEnabled" DROP DEFAULT,
|
||||
ALTER COLUMN "uploadSignatureEnabled" DROP NOT NULL,
|
||||
ALTER COLUMN "uploadSignatureEnabled" DROP DEFAULT,
|
||||
ADD CONSTRAINT "TeamGlobalSettings_pkey" PRIMARY KEY ("id");
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "OrganisationGlobalSettings" (
|
||||
"id" TEXT NOT NULL,
|
||||
"documentVisibility" "DocumentVisibility" NOT NULL DEFAULT 'EVERYONE',
|
||||
"documentLanguage" TEXT NOT NULL DEFAULT 'en',
|
||||
"includeSenderDetails" BOOLEAN NOT NULL DEFAULT true,
|
||||
"includeSigningCertificate" BOOLEAN NOT NULL DEFAULT true,
|
||||
"typedSignatureEnabled" BOOLEAN NOT NULL DEFAULT true,
|
||||
"uploadSignatureEnabled" BOOLEAN NOT NULL DEFAULT true,
|
||||
"drawSignatureEnabled" BOOLEAN NOT NULL DEFAULT true,
|
||||
"brandingEnabled" BOOLEAN NOT NULL DEFAULT false,
|
||||
"brandingLogo" TEXT NOT NULL DEFAULT '',
|
||||
"brandingUrl" TEXT NOT NULL DEFAULT '',
|
||||
"brandingCompanyDetails" TEXT NOT NULL DEFAULT '',
|
||||
"brandingHidePoweredBy" BOOLEAN NOT NULL DEFAULT false,
|
||||
|
||||
CONSTRAINT "OrganisationGlobalSettings_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Organisation_settingsId_key" ON "Organisation"("settingsId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Team_settingsId_key" ON "Team"("settingsId");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Organisation" ADD CONSTRAINT "Organisation_settingsId_fkey" FOREIGN KEY ("settingsId") REFERENCES "OrganisationGlobalSettings"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Team" ADD CONSTRAINT "Team_settingsId_fkey" FOREIGN KEY ("settingsId") REFERENCES "TeamGlobalSettings"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@ -0,0 +1,42 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `settingsId` on the `Organisation` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `settingsId` on the `Team` table. All the data in the column will be lost.
|
||||
- A unique constraint covering the columns `[organisationGlobalSettingsId]` on the table `Organisation` will be added. If there are existing duplicate values, this will fail.
|
||||
- A unique constraint covering the columns `[teamGlobalSettingsId]` on the table `Team` will be added. If there are existing duplicate values, this will fail.
|
||||
- Added the required column `organisationGlobalSettingsId` to the `Organisation` table without a default value. This is not possible if the table is not empty.
|
||||
- Added the required column `teamGlobalSettingsId` to the `Team` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "Organisation" DROP CONSTRAINT "Organisation_settingsId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "Team" DROP CONSTRAINT "Team_settingsId_fkey";
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX "Organisation_settingsId_key";
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX "Team_settingsId_key";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Organisation" DROP COLUMN "settingsId",
|
||||
ADD COLUMN "organisationGlobalSettingsId" TEXT NOT NULL;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Team" DROP COLUMN "settingsId",
|
||||
ADD COLUMN "teamGlobalSettingsId" TEXT NOT NULL;
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Organisation_organisationGlobalSettingsId_key" ON "Organisation"("organisationGlobalSettingsId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Team_teamGlobalSettingsId_key" ON "Team"("teamGlobalSettingsId");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Organisation" ADD CONSTRAINT "Organisation_organisationGlobalSettingsId_fkey" FOREIGN KEY ("organisationGlobalSettingsId") REFERENCES "OrganisationGlobalSettings"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Team" ADD CONSTRAINT "Team_teamGlobalSettingsId_fkey" FOREIGN KEY ("teamGlobalSettingsId") REFERENCES "TeamGlobalSettings"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@ -53,23 +53,25 @@ model User {
|
||||
avatarImageId String?
|
||||
disabled Boolean @default(false)
|
||||
|
||||
accounts Account[]
|
||||
sessions Session[]
|
||||
documents Document[]
|
||||
subscriptions Subscription[]
|
||||
passwordResetTokens PasswordResetToken[]
|
||||
ownedTeams Team[]
|
||||
ownedPendingTeams TeamPending[]
|
||||
teamMembers TeamMember[]
|
||||
accounts Account[]
|
||||
sessions Session[]
|
||||
passwordResetTokens PasswordResetToken[]
|
||||
|
||||
ownedOrganisations Organisation[]
|
||||
organisationMember OrganisationMember[]
|
||||
|
||||
ownedPendingTeams TeamPending[]
|
||||
|
||||
twoFactorSecret String?
|
||||
twoFactorEnabled Boolean @default(false)
|
||||
twoFactorEnabled Boolean @default(false)
|
||||
twoFactorBackupCodes String?
|
||||
url String? @unique
|
||||
|
||||
documents Document[]
|
||||
templates Template[]
|
||||
|
||||
profile UserProfile?
|
||||
verificationTokens VerificationToken[]
|
||||
apiTokens ApiToken[]
|
||||
templates Template[]
|
||||
securityAuditLogs UserSecurityAuditLog[]
|
||||
webhooks Webhook[]
|
||||
siteSettings SiteSettings[]
|
||||
@ -193,6 +195,9 @@ model Webhook {
|
||||
teamId Int?
|
||||
team Team? @relation(fields: [teamId], references: [id], onDelete: Cascade)
|
||||
webhookCalls WebhookCall[]
|
||||
|
||||
organisationId String?
|
||||
organisation Organisation? @relation(fields: [organisationId], references: [id])
|
||||
}
|
||||
|
||||
enum WebhookCallStatus {
|
||||
@ -229,6 +234,9 @@ model ApiToken {
|
||||
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
teamId Int?
|
||||
team Team? @relation(fields: [teamId], references: [id], onDelete: Cascade)
|
||||
|
||||
organisationId String?
|
||||
organisation Organisation? @relation(fields: [organisationId], references: [id])
|
||||
}
|
||||
|
||||
enum SubscriptionStatus {
|
||||
@ -243,16 +251,14 @@ model Subscription {
|
||||
planId String @unique
|
||||
priceId String
|
||||
periodEnd DateTime?
|
||||
userId Int?
|
||||
teamId Int? @unique
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
cancelAtPeriodEnd Boolean @default(false)
|
||||
|
||||
team Team? @relation(fields: [teamId], references: [id], onDelete: Cascade)
|
||||
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
organisationId String
|
||||
organisation Organisation @relation(fields: [organisationId], references: [id])
|
||||
|
||||
@@index([userId])
|
||||
@@index([organisationId])
|
||||
}
|
||||
|
||||
model Account {
|
||||
@ -314,10 +320,15 @@ enum DocumentVisibility {
|
||||
|
||||
/// @zod.import(["import { ZDocumentAuthOptionsSchema } from '@documenso/lib/types/document-auth';", "import { ZDocumentFormValuesSchema } from '@documenso/lib/types/document-form-values';"])
|
||||
model Document {
|
||||
id Int @id @default(autoincrement())
|
||||
externalId String? /// @zod.string.describe("A custom external ID you can use to identify the document.")
|
||||
userId Int /// @zod.number.describe("The ID of the user that created this document.")
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
id Int @id @default(autoincrement())
|
||||
externalId String? /// @zod.string.describe("A custom external ID you can use to identify the document.")
|
||||
|
||||
userId Int /// @zod.number.describe("The ID of the user that created this document.")
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
teamId Int
|
||||
team Team @relation(fields: [teamId], references: [id], onDelete: Cascade)
|
||||
|
||||
authOptions Json? /// [DocumentAuthOptions] @zod.custom.use(ZDocumentAuthOptionsSchema)
|
||||
formValues Json? /// [DocumentFormValues] @zod.custom.use(ZDocumentFormValuesSchema)
|
||||
visibility DocumentVisibility @default(EVERYONE)
|
||||
@ -333,8 +344,6 @@ model Document {
|
||||
updatedAt DateTime @default(now()) @updatedAt
|
||||
completedAt DateTime?
|
||||
deletedAt DateTime?
|
||||
teamId Int?
|
||||
team Team? @relation(fields: [teamId], references: [id])
|
||||
templateId Int?
|
||||
template Template? @relation(fields: [templateId], references: [id], onDelete: SetNull)
|
||||
source DocumentSource
|
||||
@ -532,20 +541,135 @@ model DocumentShareLink {
|
||||
@@unique([documentId, email])
|
||||
}
|
||||
|
||||
model Organisation {
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
name String
|
||||
url String @unique // todo: constrain
|
||||
avatarImageId String?
|
||||
|
||||
customerId String? @unique
|
||||
subscriptions Subscription[]
|
||||
|
||||
members OrganisationMember[]
|
||||
invites OrganisationMemberInvite[]
|
||||
groups OrganisationGroup[]
|
||||
|
||||
teams Team[]
|
||||
|
||||
avatarImage AvatarImage? @relation(fields: [avatarImageId], references: [id], onDelete: SetNull)
|
||||
|
||||
ownerUserId Int
|
||||
owner User @relation(fields: [ownerUserId], references: [id], onDelete: Cascade)
|
||||
|
||||
apiTokens ApiToken[]
|
||||
webhooks Webhook[]
|
||||
|
||||
organisationGlobalSettingsId String @unique
|
||||
organisationGlobalSettings OrganisationGlobalSettings @relation(fields: [organisationGlobalSettingsId], references: [id], onDelete: Cascade)
|
||||
}
|
||||
|
||||
model OrganisationMember {
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
userId Int
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
organisationId String
|
||||
organisation Organisation @relation(fields: [organisationId], references: [id], onDelete: Cascade)
|
||||
|
||||
organisationGroupMembers OrganisationGroupMember[]
|
||||
|
||||
@@unique([userId, organisationId])
|
||||
}
|
||||
|
||||
model OrganisationMemberInvite {
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
email String
|
||||
token String @unique
|
||||
|
||||
status OrganisationMemberInviteStatus @default(PENDING)
|
||||
|
||||
organisationId String
|
||||
organisation Organisation @relation(fields: [organisationId], references: [id], onDelete: Cascade)
|
||||
organisationRole OrganisationMemberRole
|
||||
}
|
||||
|
||||
model OrganisationGroup {
|
||||
id String @id @default(cuid())
|
||||
name String?
|
||||
|
||||
type OrganisationGroupType
|
||||
organisationRole OrganisationMemberRole
|
||||
|
||||
organisationId String
|
||||
organisation Organisation @relation(fields: [organisationId], references: [id], onDelete: Cascade)
|
||||
|
||||
organisationGroupMembers OrganisationGroupMember[]
|
||||
|
||||
teamGroups TeamGroup[]
|
||||
}
|
||||
|
||||
model OrganisationGroupMember {
|
||||
id String @id @default(cuid())
|
||||
|
||||
groupId String
|
||||
group OrganisationGroup @relation(fields: [groupId], references: [id], onDelete: Cascade)
|
||||
|
||||
organisationMember OrganisationMember @relation(fields: [organisationMemberId], references: [id], onDelete: Cascade)
|
||||
organisationMemberId String
|
||||
|
||||
@@unique([organisationMemberId, groupId])
|
||||
}
|
||||
|
||||
model TeamGroup {
|
||||
id String @id @default(cuid())
|
||||
|
||||
organisationGroupId String
|
||||
organisationGroup OrganisationGroup @relation(fields: [organisationGroupId], references: [id], onDelete: Cascade)
|
||||
|
||||
teamRole TeamMemberRole
|
||||
|
||||
teamId Int
|
||||
team Team @relation(fields: [teamId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([teamId, organisationGroupId])
|
||||
}
|
||||
|
||||
enum OrganisationGroupType {
|
||||
INTERNAL_ORGANISATION
|
||||
INTERNAL_TEAM
|
||||
CUSTOM
|
||||
}
|
||||
|
||||
enum OrganisationMemberRole {
|
||||
ADMIN
|
||||
MANAGER
|
||||
MEMBER
|
||||
}
|
||||
|
||||
enum TeamMemberRole {
|
||||
ADMIN
|
||||
MANAGER
|
||||
MEMBER
|
||||
}
|
||||
|
||||
enum TeamMemberInviteStatus {
|
||||
enum OrganisationMemberInviteStatus {
|
||||
ACCEPTED
|
||||
PENDING
|
||||
DECLINED
|
||||
}
|
||||
|
||||
model TeamGlobalSettings {
|
||||
teamId Int @unique
|
||||
model OrganisationGlobalSettings {
|
||||
id String @id @default(cuid())
|
||||
organisation Organisation?
|
||||
|
||||
documentVisibility DocumentVisibility @default(EVERYONE)
|
||||
documentLanguage String @default("en")
|
||||
includeSenderDetails Boolean @default(true)
|
||||
@ -560,8 +684,26 @@ model TeamGlobalSettings {
|
||||
brandingUrl String @default("")
|
||||
brandingCompanyDetails String @default("")
|
||||
brandingHidePoweredBy Boolean @default(false)
|
||||
}
|
||||
|
||||
team Team @relation(fields: [teamId], references: [id], onDelete: Cascade)
|
||||
model TeamGlobalSettings {
|
||||
id String @id @default(cuid())
|
||||
team Team?
|
||||
|
||||
documentVisibility DocumentVisibility?
|
||||
documentLanguage String?
|
||||
includeSenderDetails Boolean?
|
||||
includeSigningCertificate Boolean?
|
||||
|
||||
typedSignatureEnabled Boolean?
|
||||
uploadSignatureEnabled Boolean?
|
||||
drawSignatureEnabled Boolean?
|
||||
|
||||
brandingEnabled Boolean?
|
||||
brandingLogo String?
|
||||
brandingUrl String?
|
||||
brandingCompanyDetails String?
|
||||
brandingHidePoweredBy Boolean?
|
||||
}
|
||||
|
||||
model Team {
|
||||
@ -570,25 +712,24 @@ model Team {
|
||||
url String @unique
|
||||
createdAt DateTime @default(now())
|
||||
avatarImageId String?
|
||||
customerId String? @unique
|
||||
ownerUserId Int
|
||||
|
||||
members TeamMember[]
|
||||
invites TeamMemberInvite[]
|
||||
teamEmail TeamEmail?
|
||||
emailVerification TeamEmailVerification?
|
||||
transferVerification TeamTransferVerification?
|
||||
teamGlobalSettings TeamGlobalSettings?
|
||||
avatarImage AvatarImage? @relation(fields: [avatarImageId], references: [id], onDelete: SetNull)
|
||||
teamEmail TeamEmail?
|
||||
emailVerification TeamEmailVerification?
|
||||
avatarImage AvatarImage? @relation(fields: [avatarImageId], references: [id], onDelete: SetNull)
|
||||
|
||||
profile TeamProfile?
|
||||
owner User @relation(fields: [ownerUserId], references: [id], onDelete: Cascade)
|
||||
subscription Subscription?
|
||||
profile TeamProfile?
|
||||
|
||||
documents Document[]
|
||||
templates Template[]
|
||||
apiTokens ApiToken[]
|
||||
webhooks Webhook[]
|
||||
organisationId String
|
||||
organisation Organisation @relation(fields: [organisationId], references: [id], onDelete: Cascade)
|
||||
|
||||
documents Document[]
|
||||
templates Template[]
|
||||
apiTokens ApiToken[]
|
||||
webhooks Webhook[]
|
||||
teamGroups TeamGroup[]
|
||||
|
||||
teamGlobalSettingsId String @unique
|
||||
teamGlobalSettings TeamGlobalSettings @relation(fields: [teamGlobalSettingsId], references: [id], onDelete: Cascade)
|
||||
}
|
||||
|
||||
model TeamPending {
|
||||
@ -602,18 +743,6 @@ model TeamPending {
|
||||
owner User @relation(fields: [ownerUserId], references: [id], onDelete: Cascade)
|
||||
}
|
||||
|
||||
model TeamMember {
|
||||
id Int @id @default(autoincrement())
|
||||
teamId Int
|
||||
createdAt DateTime @default(now())
|
||||
role TeamMemberRole
|
||||
userId Int
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
team Team @relation(fields: [teamId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([userId, teamId])
|
||||
}
|
||||
|
||||
model TeamEmail {
|
||||
teamId Int @id @unique
|
||||
createdAt DateTime @default(now())
|
||||
@ -634,33 +763,6 @@ model TeamEmailVerification {
|
||||
team Team @relation(fields: [teamId], references: [id], onDelete: Cascade)
|
||||
}
|
||||
|
||||
model TeamTransferVerification {
|
||||
teamId Int @id @unique
|
||||
userId Int
|
||||
name String
|
||||
email String
|
||||
token String @unique
|
||||
completed Boolean @default(false)
|
||||
expiresAt DateTime
|
||||
createdAt DateTime @default(now())
|
||||
clearPaymentMethods Boolean @default(false)
|
||||
|
||||
team Team @relation(fields: [teamId], references: [id], onDelete: Cascade)
|
||||
}
|
||||
|
||||
model TeamMemberInvite {
|
||||
id Int @id @default(autoincrement())
|
||||
teamId Int
|
||||
createdAt DateTime @default(now())
|
||||
email String
|
||||
status TeamMemberInviteStatus @default(PENDING)
|
||||
role TeamMemberRole
|
||||
token String @unique
|
||||
team Team @relation(fields: [teamId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([teamId, email])
|
||||
}
|
||||
|
||||
enum TemplateType {
|
||||
PUBLIC
|
||||
PRIVATE
|
||||
@ -695,8 +797,6 @@ model Template {
|
||||
externalId String?
|
||||
type TemplateType @default(PRIVATE)
|
||||
title String
|
||||
userId Int
|
||||
teamId Int?
|
||||
visibility DocumentVisibility @default(EVERYONE)
|
||||
authOptions Json? /// [DocumentAuthOptions] @zod.custom.use(ZDocumentAuthOptionsSchema)
|
||||
templateMeta TemplateMeta?
|
||||
@ -706,15 +806,21 @@ model Template {
|
||||
publicTitle String @default("")
|
||||
publicDescription String @default("")
|
||||
|
||||
team Team? @relation(fields: [teamId], references: [id], onDelete: Cascade)
|
||||
templateDocumentData DocumentData @relation(fields: [templateDocumentDataId], references: [id], onDelete: Cascade)
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
recipients Recipient[]
|
||||
fields Field[]
|
||||
directLink TemplateDirectLink?
|
||||
documents Document[]
|
||||
userId Int
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
teamId Int
|
||||
team Team @relation(fields: [teamId], references: [id], onDelete: Cascade)
|
||||
|
||||
templateDocumentData DocumentData @relation(fields: [templateDocumentDataId], references: [id], onDelete: Cascade)
|
||||
|
||||
recipients Recipient[]
|
||||
fields Field[]
|
||||
directLink TemplateDirectLink?
|
||||
documents Document[]
|
||||
|
||||
@@unique([templateDocumentDataId])
|
||||
@@index([userId])
|
||||
}
|
||||
|
||||
model TemplateDirectLink {
|
||||
@ -792,6 +898,7 @@ model AvatarImage {
|
||||
id String @id @default(cuid())
|
||||
bytes String
|
||||
|
||||
team Team[]
|
||||
user User[]
|
||||
team Team[]
|
||||
user User[]
|
||||
organisation Organisation[]
|
||||
}
|
||||
|
||||
@ -1,28 +1,21 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
|
||||
const seedDatabase = async () => {
|
||||
const files = fs.readdirSync(path.join(__dirname, './seed'));
|
||||
|
||||
for (const file of files) {
|
||||
const stat = fs.statSync(path.join(__dirname, './seed', file));
|
||||
|
||||
if (stat.isFile()) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const mod = require(path.join(__dirname, './seed', file));
|
||||
|
||||
if ('seedDatabase' in mod && typeof mod.seedDatabase === 'function') {
|
||||
console.log(`[SEEDING]: ${file}`);
|
||||
|
||||
try {
|
||||
await mod.seedDatabase();
|
||||
} catch (e) {
|
||||
console.log(`[SEEDING]: Seed failed for ${file}`);
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// const files = fs.readdirSync(path.join(__dirname, './seed'));
|
||||
// for (const file of files) {
|
||||
// const stat = fs.statSync(path.join(__dirname, './seed', file));
|
||||
// if (stat.isFile()) {
|
||||
// // eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
// const mod = require(path.join(__dirname, './seed', file));
|
||||
// if ('seedDatabase' in mod && typeof mod.seedDatabase === 'function') {
|
||||
// console.log(`[SEEDING]: ${file}`);
|
||||
// try {
|
||||
// await mod.seedDatabase();
|
||||
// } catch (e) {
|
||||
// console.log(`[SEEDING]: Seed failed for ${file}`);
|
||||
// console.error(e);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
};
|
||||
|
||||
seedDatabase()
|
||||
|
||||
@ -17,7 +17,7 @@ const examplePdf = fs
|
||||
type SeedTemplateOptions = {
|
||||
title?: string;
|
||||
userId: number;
|
||||
teamId?: number;
|
||||
teamId: number;
|
||||
createTemplateOptions?: Partial<Prisma.TemplateCreateInput>;
|
||||
};
|
||||
|
||||
@ -82,15 +82,11 @@ export const seedTemplate = async (options: SeedTemplateOptions) => {
|
||||
role: RecipientRole.SIGNER,
|
||||
},
|
||||
},
|
||||
...(teamId
|
||||
? {
|
||||
team: {
|
||||
connect: {
|
||||
id: teamId,
|
||||
},
|
||||
},
|
||||
}
|
||||
: {}),
|
||||
team: {
|
||||
connect: {
|
||||
id: teamId,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
};
|
||||
@ -126,15 +122,11 @@ export const seedDirectTemplate = async (options: SeedTemplateOptions) => {
|
||||
token: Math.random().toString().slice(2, 7),
|
||||
},
|
||||
},
|
||||
...(teamId
|
||||
? {
|
||||
team: {
|
||||
connect: {
|
||||
id: teamId,
|
||||
},
|
||||
},
|
||||
}
|
||||
: {}),
|
||||
team: {
|
||||
connect: {
|
||||
id: teamId,
|
||||
},
|
||||
},
|
||||
...options.createTemplateOptions,
|
||||
},
|
||||
include: {
|
||||
|
||||
Reference in New Issue
Block a user