From 1925236bcfcafc6c490319ab5f07b2a698e88ef5 Mon Sep 17 00:00:00 2001 From: Brandon Smith <4730164+brandon93s@users.noreply.github.com> Date: Wed, 22 May 2024 13:42:45 -0500 Subject: [PATCH] feat: add `db:generate` and `db:migrate` scripts (#1893) --- .changeset/hot-chairs-fail.md | 5 +++++ cli/src/installers/drizzle.ts | 6 ++++-- cli/src/installers/prisma.ts | 2 ++ 3 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 .changeset/hot-chairs-fail.md diff --git a/.changeset/hot-chairs-fail.md b/.changeset/hot-chairs-fail.md new file mode 100644 index 0000000000..0aa1621ded --- /dev/null +++ b/.changeset/hot-chairs-fail.md @@ -0,0 +1,5 @@ +--- +"create-t3-app": minor +--- + +Add `db:generate` and `db:migrate` scripts to drizzle and prisma installers diff --git a/cli/src/installers/drizzle.ts b/cli/src/installers/drizzle.ts index f6be4c8b6a..538cbfa2b4 100644 --- a/cli/src/installers/drizzle.ts +++ b/cli/src/installers/drizzle.ts @@ -77,14 +77,16 @@ export const drizzleInstaller: Installer = ({ ); const clientDest = path.join(projectDir, "src/server/db/index.ts"); - // add db:push script to package.json + // add db:* scripts to package.json const packageJsonPath = path.join(projectDir, "package.json"); const packageJsonContent = fs.readJSONSync(packageJsonPath) as PackageJson; packageJsonContent.scripts = { ...packageJsonContent.scripts, - "db:push": `drizzle-kit push`, + "db:push": "drizzle-kit push", "db:studio": "drizzle-kit studio", + "db:generate": "drizzle-kit generate", + "db:migrate": "drizzle-kit migrate", }; fs.copySync(configFile, configDest); diff --git a/cli/src/installers/prisma.ts b/cli/src/installers/prisma.ts index db2245e857..f92da12395 100644 --- a/cli/src/installers/prisma.ts +++ b/cli/src/installers/prisma.ts @@ -74,6 +74,8 @@ export const prismaInstaller: Installer = ({ postinstall: "prisma generate", "db:push": "prisma db push", "db:studio": "prisma studio", + "db:generate": "prisma migrate dev", + "db:migrate": "prisma migrate deploy", }; fs.copySync(clientSrc, clientDest);