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 all existing project domains lowercase

Roman Pominovc67412ec0c9f
diff --git a/packages/prisma-client/prisma/migrations/20221021172647_lowercase_domains/migration.ts b/packages/prisma-client/prisma/migrations/20221021172647_lowercase_domains/migration.ts
new file mode 100644
index 0000000000..9e1c86b519
--- /dev/null
+++ b/packages/prisma-client/prisma/migrations/20221021172647_lowercase_domains/migration.ts
@@ -0,0 +1,36 @@
+import { PrismaClient, Project } from "./client";
+
+export default () => {
+ const client = new PrismaClient({
+ // Uncomment to see the queries in console as the migration runs
+ // log: ["query", "info", "warn", "error"],
+ });
+ return client.$transaction(
+ async (prisma) => {
+ const projects = await prisma.project.findMany();
+
+ const projectsByDomain = new Map<string, Project>();
+
+ for (const project of projects) {
+ const domain = project.domain.toLowerCase();
+ if (projectsByDomain.has(domain) === false) {
+ projectsByDomain.set(domain, project);
+ } else {
+ let suffix = 1;
+ while (projectsByDomain.has(`${domain}${suffix}`)) {
+ suffix++;
+ }
+ projectsByDomain.set(`${domain}${suffix}`, project);
+ }
+ }
+
+ for (const [domain, project] of projectsByDomain) {
+ await prisma.project.update({
+ where: { id: project.id },
+ data: { domain },
+ });
+ }
+ },
+ { timeout: 1000 * 60 }
+ );
+};
diff --git a/packages/prisma-client/prisma/migrations/20221021172647_lowercase_domains/schema.prisma b/packages/prisma-client/prisma/migrations/20221021172647_lowercase_domains/schema.prisma
new file mode 100644
index 0000000000..6b01a80b0a
--- /dev/null
+++ b/packages/prisma-client/prisma/migrations/20221021172647_lowercase_domains/schema.prisma
@@ -0,0 +1,95 @@
+// DO NOT EDIT THIS FILE!
+// This is a copy of your schema.prisma that corresponds to the state of the database
+// when all migrations up until this one are applied.
+// It's used to generate a Prisma Client for the migration.
+
+// This is your Prisma schema file,
+// learn more about it in the docs: https://pris.ly/d/prisma-schema
+
+generator client {
+ provider = "prisma-client-js"
+ previewFeatures = ["interactiveTransactions"]
+ output = "client"
+}
+
+datasource db {
+ provider = "postgres"
+ url = env("DATABASE_URL")
+}
+
+model Team {
+ id String @id @default(uuid())
+ users User[]
+}
+
+enum Location {
+ FS
+ REMOTE
+}
+
+model Asset {
+ id String @id @default(uuid())
+ project Project @relation(fields: [projectId], references: [id])
+ projectId String
+ format String
+ size Int
+ name String
+ description String?
+ location Location
+ createdAt DateTime @default(now())
+ meta String @default("{}")
+}
+
+model User {
+ id String @id @default(uuid())
+ email String? @unique
+ provider String?
+ image String?
+ username String?
+ createdAt DateTime @default(now())
+ team Team? @relation(fields: [teamId], references: [id])
+ teamId String?
+ projects Project[]
+}
+
+model Project {
+ id String @id @default(uuid())
+ title String
+ domain String @unique
+ user User? @relation(fields: [userId], references: [id])
+ userId String?
+ assets Asset[]
+ build Build[]
+}
+
+model Build {
+ id String @id @default(uuid())
+ createdAt DateTime @default(now())
+ pages String
+
+ project Project @relation(fields: [projectId], references: [id])
+ projectId String
+
+ isDev Boolean // exctly one is true per project
+ isProd Boolean // at most one is true per project (none if not published)
+
+ breakpoints Breakpoints?
+}
+
+model Tree {
+ id String @id @default(uuid())
+ root String
+}
+
+model InstanceProps {
+ id String @id @default(uuid())
+ instanceId String
+ treeId String
+ props String @default("[]")
+}
+
+model Breakpoints {
+ build Build @relation(fields: [buildId], references: [id])
+ buildId String @id
+ values String @default("[]")
+}