mirror of
https://github.com/documenso/documenso.git
synced 2025-11-23 05:01:54 +10:00
feat: migrate nextjs to rr7
This commit is contained in:
@ -0,0 +1,2 @@
|
||||
-- AlterEnum
|
||||
ALTER TYPE "RecipientRole" ADD VALUE 'ASSISTANT';
|
||||
@ -0,0 +1,2 @@
|
||||
-- AlterEnum
|
||||
ALTER TYPE "WebhookTriggerEvents" ADD VALUE 'DOCUMENT_CANCELLED';
|
||||
@ -0,0 +1,18 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `expires` on the `Session` table. All the data in the column will be lost.
|
||||
- Added the required column `expiresAt` to the `Session` table without a default value. This is not possible if the table is not empty.
|
||||
- Added the required column `updatedAt` to the `Session` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "Account" ADD COLUMN "password" TEXT;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Session" DROP COLUMN "expires",
|
||||
ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
ADD COLUMN "expiresAt" TIMESTAMP(3) NOT NULL,
|
||||
ADD COLUMN "ipAddress" TEXT,
|
||||
ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
ADD COLUMN "userAgent" TEXT;
|
||||
@ -0,0 +1,2 @@
|
||||
-- AlterEnum
|
||||
ALTER TYPE "DocumentStatus" ADD VALUE 'REJECTED';
|
||||
@ -21,19 +21,19 @@
|
||||
"seed": "tsx ./seed-database.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@prisma/client": "5.4.2",
|
||||
"kysely": "^0.27.3",
|
||||
"prisma": "5.4.2",
|
||||
"@prisma/client": "^5.4.2",
|
||||
"kysely": "0.26.3",
|
||||
"prisma": "^5.4.2",
|
||||
"prisma-extension-kysely": "^2.1.0",
|
||||
"ts-pattern": "^5.0.6"
|
||||
"prisma-kysely": "^1.8.0",
|
||||
"prisma-json-types-generator": "^3.2.2",
|
||||
"ts-pattern": "^5.0.6",
|
||||
"zod-prisma-types": "3.1.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"dotenv": "^16.3.1",
|
||||
"dotenv-cli": "^7.3.0",
|
||||
"prisma-json-types-generator": "^3.2.2",
|
||||
"prisma-kysely": "^1.8.0",
|
||||
"tsx": "^4.11.0",
|
||||
"typescript": "5.6.2",
|
||||
"zod-prisma-types": "3.1.9"
|
||||
"tsx": "^4.19.2",
|
||||
"typescript": "5.6.2"
|
||||
}
|
||||
}
|
||||
@ -11,10 +11,11 @@ generator json {
|
||||
}
|
||||
|
||||
generator zod {
|
||||
provider = "zod-prisma-types"
|
||||
createInputTypes = false
|
||||
writeBarrelFiles = true
|
||||
useMultipleFiles = true
|
||||
provider = "zod-prisma-types"
|
||||
createInputTypes = false
|
||||
writeBarrelFiles = false
|
||||
useMultipleFiles = true
|
||||
useDefaultValidators = false
|
||||
}
|
||||
|
||||
datasource db {
|
||||
@ -23,6 +24,7 @@ datasource db {
|
||||
directUrl = env("NEXT_PRIVATE_DIRECT_DATABASE_URL")
|
||||
}
|
||||
|
||||
// Todo: (RR7) Remove after RR7 migration.
|
||||
enum IdentityProvider {
|
||||
DOCUMENSO
|
||||
GOOGLE
|
||||
@ -40,14 +42,14 @@ model User {
|
||||
customerId String? @unique
|
||||
email String @unique
|
||||
emailVerified DateTime?
|
||||
password String?
|
||||
password String? // Todo: (RR7) Remove after RR7 migration.
|
||||
source String?
|
||||
signature String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @default(now()) @updatedAt
|
||||
lastSignedIn DateTime @default(now())
|
||||
roles Role[] @default([USER])
|
||||
identityProvider IdentityProvider @default(DOCUMENSO)
|
||||
identityProvider IdentityProvider @default(DOCUMENSO) // Todo: (RR7) Remove after RR7 migration.
|
||||
avatarImageId String?
|
||||
disabled Boolean @default(false)
|
||||
|
||||
@ -175,6 +177,7 @@ enum WebhookTriggerEvents {
|
||||
DOCUMENT_SIGNED
|
||||
DOCUMENT_COMPLETED
|
||||
DOCUMENT_REJECTED
|
||||
DOCUMENT_CANCELLED
|
||||
}
|
||||
|
||||
model Webhook {
|
||||
@ -269,24 +272,32 @@ model Account {
|
||||
scope String?
|
||||
id_token String? @db.Text
|
||||
session_state String?
|
||||
password String?
|
||||
|
||||
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([provider, providerAccountId])
|
||||
}
|
||||
|
||||
model Session {
|
||||
id String @id @default(cuid())
|
||||
sessionToken String @unique
|
||||
id String @id @default(cuid())
|
||||
sessionToken String @unique
|
||||
userId Int
|
||||
expires DateTime
|
||||
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
ipAddress String?
|
||||
userAgent String?
|
||||
expiresAt DateTime
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
}
|
||||
|
||||
enum DocumentStatus {
|
||||
DRAFT
|
||||
PENDING
|
||||
COMPLETED
|
||||
REJECTED
|
||||
}
|
||||
|
||||
enum DocumentSource {
|
||||
@ -416,6 +427,7 @@ enum RecipientRole {
|
||||
SIGNER
|
||||
VIEWER
|
||||
APPROVER
|
||||
ASSISTANT
|
||||
}
|
||||
|
||||
/// @zod.import(["import { ZRecipientAuthOptionsSchema } from '@documenso/lib/types/document-auth';"])
|
||||
|
||||
@ -31,6 +31,7 @@ type DocumentToSeed = {
|
||||
|
||||
export const seedDocuments = async (documents: DocumentToSeed[]) => {
|
||||
await Promise.all(
|
||||
// eslint-disable-next-line @typescript-eslint/require-await
|
||||
documents.map(async (document, i) =>
|
||||
match(document.type)
|
||||
.with(DocumentStatus.DRAFT, async () =>
|
||||
@ -50,8 +51,7 @@ export const seedDocuments = async (documents: DocumentToSeed[]) => {
|
||||
key: i,
|
||||
createDocumentOptions: document.documentOptions,
|
||||
}),
|
||||
)
|
||||
.exhaustive(),
|
||||
),
|
||||
),
|
||||
);
|
||||
};
|
||||
|
||||
@ -5,6 +5,18 @@ import { hashSync } from '@documenso/lib/server-only/auth/hash';
|
||||
|
||||
import { prisma } from '..';
|
||||
import { DocumentDataType, DocumentSource, Role, TeamMemberRole } from '../client';
|
||||
import { seedPendingDocument } from './documents';
|
||||
import { seedDirectTemplate, seedTemplate } from './templates';
|
||||
|
||||
const createDocumentData = async ({ documentData }: { documentData: string }) => {
|
||||
return prisma.documentData.create({
|
||||
data: {
|
||||
type: DocumentDataType.BYTES_64,
|
||||
data: documentData,
|
||||
initialData: documentData,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
export const seedDatabase = async () => {
|
||||
const examplePdf = fs
|
||||
@ -39,35 +51,80 @@ export const seedDatabase = async () => {
|
||||
update: {},
|
||||
});
|
||||
|
||||
const examplePdfData = await prisma.documentData.upsert({
|
||||
where: {
|
||||
id: 'clmn0kv5k0000pe04vcqg5zla',
|
||||
},
|
||||
create: {
|
||||
id: 'clmn0kv5k0000pe04vcqg5zla',
|
||||
type: DocumentDataType.BYTES_64,
|
||||
data: examplePdf,
|
||||
initialData: examplePdf,
|
||||
},
|
||||
update: {},
|
||||
});
|
||||
for (let i = 1; i <= 4; i++) {
|
||||
const documentData = await createDocumentData({ documentData: examplePdf });
|
||||
|
||||
await prisma.document.create({
|
||||
data: {
|
||||
source: DocumentSource.DOCUMENT,
|
||||
title: 'Example Document',
|
||||
documentDataId: examplePdfData.id,
|
||||
userId: exampleUser.id,
|
||||
recipients: {
|
||||
create: {
|
||||
name: String(adminUser.name),
|
||||
email: adminUser.email,
|
||||
token: Math.random().toString(36).slice(2, 9),
|
||||
await prisma.document.create({
|
||||
data: {
|
||||
source: DocumentSource.DOCUMENT,
|
||||
title: `Example Document ${i}`,
|
||||
documentDataId: documentData.id,
|
||||
userId: exampleUser.id,
|
||||
recipients: {
|
||||
create: {
|
||||
name: String(adminUser.name),
|
||||
email: adminUser.email,
|
||||
token: Math.random().toString(36).slice(2, 9),
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
for (let i = 1; i <= 4; i++) {
|
||||
const documentData = await createDocumentData({ documentData: examplePdf });
|
||||
|
||||
await prisma.document.create({
|
||||
data: {
|
||||
source: DocumentSource.DOCUMENT,
|
||||
title: `Document ${i}`,
|
||||
documentDataId: documentData.id,
|
||||
userId: adminUser.id,
|
||||
recipients: {
|
||||
create: {
|
||||
name: String(exampleUser.name),
|
||||
email: exampleUser.email,
|
||||
token: Math.random().toString(36).slice(2, 9),
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
await seedPendingDocument(exampleUser, [adminUser], {
|
||||
key: 'example-pending',
|
||||
createDocumentOptions: {
|
||||
title: 'Pending Document',
|
||||
},
|
||||
});
|
||||
|
||||
await seedPendingDocument(adminUser, [exampleUser], {
|
||||
key: 'admin-pending',
|
||||
createDocumentOptions: {
|
||||
title: 'Pending Document',
|
||||
},
|
||||
});
|
||||
|
||||
await Promise.all([
|
||||
seedTemplate({
|
||||
title: 'Template 1',
|
||||
userId: exampleUser.id,
|
||||
}),
|
||||
seedDirectTemplate({
|
||||
title: 'Direct Template 1',
|
||||
userId: exampleUser.id,
|
||||
}),
|
||||
|
||||
seedTemplate({
|
||||
title: 'Template 1',
|
||||
userId: adminUser.id,
|
||||
}),
|
||||
seedDirectTemplate({
|
||||
title: 'Direct Template 1',
|
||||
userId: adminUser.id,
|
||||
}),
|
||||
]);
|
||||
|
||||
const testUsers = [
|
||||
'test@documenso.com',
|
||||
'test2@documenso.com',
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import type { Document, DocumentData, Recipient } from '@documenso/prisma/client';
|
||||
import type { Document, DocumentData, Recipient } from '@prisma/client';
|
||||
|
||||
export type DocumentWithRecipients = Document & {
|
||||
recipients: Recipient[];
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import type { Field, Signature } from '@prisma/client';
|
||||
|
||||
import { type TFieldMetaSchema as FieldMeta } from '@documenso/lib/types/field-meta';
|
||||
import type { Field, Signature } from '@documenso/prisma/client';
|
||||
|
||||
export type FieldWithSignatureAndFieldMeta = Field & {
|
||||
signature?: Signature | null;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import type { Field, Signature } from '@documenso/prisma/client';
|
||||
import type { Field, Signature } from '@prisma/client';
|
||||
|
||||
export type FieldWithSignature = Field & {
|
||||
signature?: Signature | null;
|
||||
|
||||
5
packages/prisma/types/recipient-with-fields.ts
Normal file
5
packages/prisma/types/recipient-with-fields.ts
Normal file
@ -0,0 +1,5 @@
|
||||
import type { Field, Recipient } from '@prisma/client';
|
||||
|
||||
export type RecipientWithFields = Recipient & {
|
||||
fields: Field[];
|
||||
};
|
||||
Reference in New Issue
Block a user