Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add db:generate and db:migrate scripts #1893

Merged
merged 3 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading