Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
Save project uploader when create file (#1618)
Bogdan Chadkin93f636919aa4
diff --git a/packages/asset-uploader/src/upload.ts b/packages/asset-uploader/src/upload.tsindex 74ef79fa77..3bb26f3331 100644--- a/packages/asset-uploader/src/upload.ts+++ b/packages/asset-uploader/src/upload.ts@@ -40,19 +40,17 @@ export const createUploadName = async (* than UPLOADING_STALE_TIMEOUT milliseconds ago**/- const count = await prisma.asset.count({+ const count = await prisma.file.count({where: {OR: [{- projectId,- file: { status: "UPLOADED" },+ status: "UPLOADED",+ uploaderProjectId: projectId,},{- projectId,- file: {- status: "UPLOADING",- createdAt: { gt: new Date(Date.now() - UPLOADING_STALE_TIMEOUT) },- },+ status: "UPLOADING",+ createdAt: { gt: new Date(Date.now() - UPLOADING_STALE_TIMEOUT) },+ uploaderProjectId: projectId,},],},@@ -89,6 +87,7 @@ export const createUploadName = async (// store content type in related fieldformat: type,size: 0,+ uploaderProjectId: projectId,},},// @todo remove once legacy fields are removed from schemadiff --git a/packages/prisma-client/prisma/migrations/20230515112405_file_uploader_project/migration.sql b/packages/prisma-client/prisma/migrations/20230515112405_file_uploader_project/migration.sqlnew file mode 100644index 0000000000..e26abf7f19--- /dev/null+++ b/packages/prisma-client/prisma/migrations/20230515112405_file_uploader_project/migration.sql@@ -0,0 +1,9 @@+-- DropForeignKey+ALTER TABLE "File" DROP CONSTRAINT "File_userId_fkey";++-- AlterTable+ALTER TABLE "File" DROP COLUMN "userId",+ADD COLUMN "uploaderProjectId" TEXT;++-- AddForeignKey+ALTER TABLE "File" ADD CONSTRAINT "File_uploaderProjectId_fkey" FOREIGN KEY ("uploaderProjectId") REFERENCES "Project"("id") ON DELETE SET NULL ON UPDATE CASCADE;diff --git a/packages/prisma-client/prisma/schema.prisma b/packages/prisma-client/prisma/schema.prismaindex efed5083b1..1d2cba4f4c 100644--- a/packages/prisma-client/prisma/schema.prisma+++ b/packages/prisma-client/prisma/schema.prisma@@ -31,14 +31,16 @@ enum UploadStatus {}model File {- name String @id- format String- size Int- description String?- createdAt DateTime @default(now())- meta String @default("{}")- status UploadStatus @default(UPLOADING)- assets Asset[]+ name String @id+ format String+ size Int+ description String?+ createdAt DateTime @default(now())+ meta String @default("{}")+ status UploadStatus @default(UPLOADING)+ uploaderProject Project? @relation(fields: [uploaderProjectId], references: [id])+ uploaderProjectId String?+ assets Asset[]}model Asset {@@ -80,6 +82,7 @@ model Project {userId String?build Build[]isDeleted Boolean @default(false)+ files File[]@@unique([id, isDeleted])@@unique([domain, isDeleted])