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.

fix: Remove deleted projects from domain count calc (#2821)

Ivan Starkov5bff0d7584e2
diff --git a/packages/prisma-client/prisma/migrations/20240125182656_calc-domains/migration.sql b/packages/prisma-client/prisma/migrations/20240125182656_calc-domains/migration.sql
new file mode 100644
index 0000000000..64f67ba656
--- /dev/null
+++ b/packages/prisma-client/prisma/migrations/20240125182656_calc-domains/migration.sql
@@ -0,0 +1,17 @@
+CREATE OR REPLACE VIEW "ProjectWithDomain" AS
+SELECT
+ pd."projectId",
+ pd."domainId",
+ pd."txtRecord",
+ pd."cname",
+ pd."createdAt",
+ -- any DNS txt record change would cause verified to be changed immediately
+ coalesce(pd."txtRecord" = d."txtRecord", false) AS verified,
+ -- domains count per user
+ p."userId"
+FROM
+ "ProjectDomain" pd
+ LEFT JOIN "Domain" d ON pd."domainId" = d.id
+ LEFT JOIN "Project" p ON pd."projectId" = p.id
+ WHERE p."isDeleted" = FALSE;
+