Skip to content

Commit

Permalink
add db-migrate commands
Browse files Browse the repository at this point in the history
  • Loading branch information
moeakwak committed Apr 29, 2024
1 parent b912dac commit 9522d54
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@
"build": "next build",
"build-zip": "next build && zip -r standalone.zip .next/standalone .next/static public package.json scripts-dist drizzle next.config.js",
"build-scripts": "node scripts/build.mjs",
"db:push": "drizzle-kit push:pg --config drizzle.config.dev.ts",
"db:studio": "drizzle-kit studio",
"db:generate": "drizzle-kit generate:pg",
"db:migrate": "tsx ./scripts/db-migrate.ts",
"dev": "next dev",
"format": "prettier src --write",
"lint": "next lint",
"lint-fix": "next lint --fix",
"start": "next start",
"create-admin": "tsx scripts/create-admin.ts",
"seed-test": "pnpm db:push && tsx scripts/seed.ts",
"docker:create-admin": "node scripts-dist/create-admin.cjs"
"docker:create-admin": "node scripts-dist/create-admin.cjs",
"docker:db-migrate": "node scripts-dist/db-migrate.cjs"
},
"dependencies": {
"@hookform/resolvers": "^3.3.4",
Expand Down
2 changes: 1 addition & 1 deletion scripts/db-migrate.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { conn, db } from "@/server/db";
import "dotenv/config";
import { conn, db } from "@/server/db";
import { migrate } from "drizzle-orm/postgres-js/migrator";

migrate(db, { migrationsFolder: "./drizzle" })
Expand Down
4 changes: 1 addition & 3 deletions src/server/db/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@ const globalForDb = globalThis as unknown as {

export const conn = globalForDb.conn ?? postgres(env.POSTGRES_URL, {
// eslint-disable-next-line @typescript-eslint/no-empty-function
onnotice: (_notice) => {}
// onnotice: (_notice) => {}
});

if (env.NODE_ENV !== "production") globalForDb.conn = conn;

export const db = drizzle(conn, { schema, logger: false });

// await migrate(db, { migrationsFolder: "drizzle" });

export type Db = typeof db;

0 comments on commit 9522d54

Please sign in to comment.