mirror of
https://github.com/formbricks/formbricks.git
synced 2026-04-19 19:21:15 -05:00
fix: schema
This commit is contained in:
@@ -1,54 +0,0 @@
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
|
||||
import { TStyling } from "@formbricks/types/styling";
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
async function main() {
|
||||
await prisma.$transaction(async (tx) => {
|
||||
// product table with brand color and the highlight border color (if available)
|
||||
// styling object needs to be created for each product
|
||||
const products = await tx.product.findMany({});
|
||||
|
||||
if (!products) {
|
||||
// something went wrong, could not find any products
|
||||
return;
|
||||
}
|
||||
|
||||
if (products.length) {
|
||||
for (const product of products) {
|
||||
if (product.styling !== null) {
|
||||
// styling object already exists for this product
|
||||
continue;
|
||||
}
|
||||
|
||||
const styling: TStyling = {
|
||||
brandColor: {
|
||||
light: product.brandColor,
|
||||
},
|
||||
...(product.highlightBorderColor && {
|
||||
highlightBorderColor: {
|
||||
light: product.highlightBorderColor,
|
||||
},
|
||||
}),
|
||||
};
|
||||
|
||||
await tx.product.update({
|
||||
where: {
|
||||
id: product.id,
|
||||
},
|
||||
data: {
|
||||
styling,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
main()
|
||||
.catch(async (e) => {
|
||||
console.error(e);
|
||||
process.exit(1);
|
||||
})
|
||||
.finally(async () => await prisma.$disconnect());
|
||||
@@ -1,4 +0,0 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "Product" ADD COLUMN "allowStyleOverwrite" BOOLEAN DEFAULT true,
|
||||
ADD COLUMN "styling" JSONB,
|
||||
ADD COLUMN "unifiedStyling" BOOLEAN DEFAULT true;
|
||||
@@ -420,9 +420,7 @@ model Product {
|
||||
highlightBorderColor String?
|
||||
/// @zod.custom(imports.ZStyling)
|
||||
/// [Styling]
|
||||
styling Json?
|
||||
unifiedStyling Boolean? @default(true)
|
||||
allowStyleOverwrite Boolean? @default(true)
|
||||
styling Json? @default("{\"unifiedStyling\":true,\"allowStyleOverwrite\":true,\"brandColor\":{\"light\":\"#64748b\"}}")
|
||||
recontactDays Int @default(7)
|
||||
linkSurveyBranding Boolean @default(true) // Determines if the survey branding should be displayed in link surveys
|
||||
inAppSurveyBranding Boolean @default(true) // Determines if the survey branding should be displayed in in-app surveys
|
||||
|
||||
@@ -13,8 +13,6 @@ export const ZProduct = z.object({
|
||||
brandColor: ZColor,
|
||||
highlightBorderColor: ZColor.nullable(),
|
||||
styling: ZStyling.nullable(),
|
||||
unifiedStyling: z.boolean().nullable(),
|
||||
allowStyleOverwrite: z.boolean().nullable(),
|
||||
recontactDays: z.number().int(),
|
||||
inAppSurveyBranding: z.boolean(),
|
||||
linkSurveyBranding: z.boolean(),
|
||||
|
||||
@@ -15,6 +15,8 @@ export const ZCardArrangement = z.object({
|
||||
});
|
||||
|
||||
export const ZStyling = z.object({
|
||||
unifiedStyling: z.boolean(),
|
||||
allowStyleOverwrite: z.boolean(),
|
||||
brandColor: ZStylingColor.optional(),
|
||||
questionColor: ZStylingColor.optional(),
|
||||
inputColor: ZStylingColor.optional(),
|
||||
|
||||
Reference in New Issue
Block a user