From 587ace33664958b7dc38049083a529eb76899711 Mon Sep 17 00:00:00 2001 From: Anthony GAEREMYNCK <1@anthony.sh> Date: Fri, 31 Jul 2026 09:31:13 +0200 Subject: [PATCH] package.json > create deploy script --- README.md | 2 +- package.json | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a465ab6..f3a497d 100644 --- a/README.md +++ b/README.md @@ -22,4 +22,4 @@ 7. **ONE-TIME, before ever running `prisma migrate deploy` on this server:** the o2switch database already has the `conversion_jobs` table (created by hand, before this project used Prisma), but no `_prisma_migrations` tracking table. Running `migrate deploy` first would try to `CREATE TABLE conversion_jobs` again and fail with a "table already exists" MySQL error, leaving Prisma's migration history stuck and needing manual recovery. Avoid that by baselining the existing table once, ever, on this server, before step 8's `migrate deploy` runs for the first time: `DATABASE_URL=$(node scripts/printDatabaseUrl.js) npx prisma migrate resolve --applied 0_init` Do **not** repeat this step on later deployments — after this one-time run, `migrate deploy` (step 8) is the correct command going forward. -8. On every subsequent deployment: pull changes, `npm install`, apply any pending migrations with `DATABASE_URL=$(node scripts/printDatabaseUrl.js) npx prisma migrate deploy`, `npm run build` (frontend), then restart the Passenger app from cPanel and `pm2 restart convert-worker`. +8. On every subsequent deployment: pull changes, `npm run deploy` diff --git a/package.json b/package.json index cc13393..2443c8e 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,10 @@ "cleanup": "node src/cleanup.js", "test": "vitest run", "build": "npm install --prefix frontend --include=dev && npm run build --prefix frontend", - "postinstall": "./node_modules/.bin/prisma generate --schema=\"$INIT_CWD/prisma/schema.prisma\"" + "prisma-generate": "./node_modules/.bin/prisma generate --schema=\"$INIT_CWD/prisma/schema.prisma\"", + "prisma-migration": "DATABASE_URL=$(node scripts/printDatabaseUrl.js) npx prisma migrate deploy", + "worker-restart": "./node_modules/.bin/pm2 restart convert-worker", + "deploy": "npm install --include=dev && npm run prisma-migration && npm run build && npm run worker-restart" }, "dependencies": { "@prisma/client": "^6.19.3",