Skip to content

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.

make width and height a decimal

Sara Vieira2b494332870e
diff --git a/apps/designer/app/shared/db/assets.server.ts b/apps/designer/app/shared/db/assets.server.ts
index 86cc6ce974..3a14d3a488 100644
--- a/apps/designer/app/shared/db/assets.server.ts
+++ b/apps/designer/app/shared/db/assets.server.ts
@@ -1,5 +1,5 @@
import { type Project } from "@webstudio-is/react-sdk";
-import { prisma } from "./prisma.server";
+import { prisma, Prisma } from "./prisma.server";
import sharp from "sharp";
export const loadByProject = async (projectId?: Project["id"]) => {
@@ -30,8 +30,10 @@ export const create = async (
path: values.path,
size: values.size,
format: metadata.format,
- ...(metadata.width ? { width: metadata.width } : {}),
- ...(metadata.height ? { height: metadata.height } : {}),
+ ...(metadata.width ? { width: new Prisma.Decimal(metadata.width) } : {}),
+ ...(metadata.height
+ ? { height: new Prisma.Decimal(metadata.height) }
+ : {}),
projectId,
},
});
diff --git a/apps/designer/prisma/migrations/20220717193140_make_width_and_height_decimal/migration.sql b/apps/designer/prisma/migrations/20220717193140_make_width_and_height_decimal/migration.sql
new file mode 100644
index 0000000000..e4da818b5d
--- /dev/null
+++ b/apps/designer/prisma/migrations/20220717193140_make_width_and_height_decimal/migration.sql
@@ -0,0 +1,10 @@
+/*
+ Warnings:
+
+ - You are about to alter the column `height` on the `Asset` table. The data in that column could be lost. The data in that column will be cast from `DoublePrecision` to `Decimal(65,30)`.
+ - You are about to alter the column `width` on the `Asset` table. The data in that column could be lost. The data in that column will be cast from `DoublePrecision` to `Decimal(65,30)`.
+
+*/
+-- AlterTable
+ALTER TABLE "Asset" ALTER COLUMN "height" SET DATA TYPE DECIMAL(65,30),
+ALTER COLUMN "width" SET DATA TYPE DECIMAL(65,30);
diff --git a/apps/designer/prisma/schema.prisma b/apps/designer/prisma/schema.prisma
index 189a414d7b..9946c6fe12 100644
--- a/apps/designer/prisma/schema.prisma
+++ b/apps/designer/prisma/schema.prisma
@@ -21,8 +21,8 @@ model Asset {
projectId String
format String?
size Int
- width Float?
- height Float?
+ width Decimal?
+ height Decimal?
name String
path String
alt String?
diff --git a/packages/webstudio-react-sdk/prisma/schema.prisma b/packages/webstudio-react-sdk/prisma/schema.prisma
index 26015a5835..9946c6fe12 100644
--- a/packages/webstudio-react-sdk/prisma/schema.prisma
+++ b/packages/webstudio-react-sdk/prisma/schema.prisma
@@ -19,7 +19,10 @@ model Asset {
id String @id @default(uuid())
project Project @relation(fields: [projectId], references: [id])
projectId String
- type String
+ format String?
+ size Int
+ width Decimal?
+ height Decimal?
name String
path String
alt String?