Skip to content

Commit

Permalink
feat: add db:generate and db:migrate scripts (#1893)
Browse files Browse the repository at this point in the history
  • Loading branch information
brandon93s authored May 22, 2024
1 parent 4236f0d commit 1925236
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/hot-chairs-fail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-t3-app": minor
---

Add `db:generate` and `db:migrate` scripts to drizzle and prisma installers
6 changes: 4 additions & 2 deletions cli/src/installers/drizzle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions cli/src/installers/prisma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 1925236

Please sign in to comment.