These notes cover the POS release: migrations 0070_order_refund_method_counter, 0071_pos_counter_returns and 0072_pos_counter_walk_in_customer and 0073_order_item_serial_release, the permission changes, and the desktop client (nano-store-pos). Base setup lives in docs/vps-deployment-runbook.md; this page lists only what differs. That runbook is not committed to the repo.
Appends card_reversal and qr_reversal to the order_refund_method enum (IF NOT EXISTS)
0071_pos_counter_returns
Creates the pos_counter_returns table
0072_pos_counter_walk_in_customer
Inserts the shared Counter Walk-in customer, fixed id 01a2076e-fe59-73dc-9d64-ee3ce2edb086
0073_order_item_serial_release
Adds release columns to order_item_serial and swaps its full unique index for a partial one over unreleased rows
Replay all four against a production dump first. The replay is manual and uses the same rules as b2b-second-inventory/deploy.mdx section 1: a database name that does not look like production, and never a live app against it.
Expect one row: Counter Walk-in, email and phone NULL, status = 'active', banned = false.
A missing or edited row makes every POS sale answer 503 POS_COUNTER_CUSTOMER_MISSING. The application accepts the row only while it is not soft-deleted, active, not banned, and has no email and no phone. Do not rename it, give it a contact or ban it.
Sync permissions. This release changes the permission catalogue. Run it after the build: the script reads the catalogue from the built @nano-store/db dist, so a run before the build sees the previous release's catalogue, prints Permissions are already up to date and inserts nothing.
pnpm --filter @nano-store/api permissions:sync
Expect Added N missing permissions on a release that adds a permission module. Permissions are read from the database, so this step needs no restart.
Restart:
pm2 restart ns-apipm2 restart ns-docs
Create the cashier role (section 3).
Roll out the POS installers (section 4).
Turbo and DATABASE_URL.pnpm db:migrate runs turbo -F @nano-store/db db:migrate, and turbo.json declares no env passthrough. A DATABASE_URL or DIRECT_DATABASE_URL exported in your shell may therefore not reach drizzle-kit, which then reads apps/api/.env instead. This matters when you point a replay at another database. Bypass turbo with the filtered command:
Set real store values before real sales; the defaults are placeholders. Leave a key out rather than filling it with a placeholder (<district id> fails validation and the API refuses to boot).
Key
Requirement
RESEND_API_KEY, RESEND_DEFAULT_FROM
Receipt email needs both. Sales succeed without them; receipts are silently not sent
API_RUNTIME_PROFILE
Keep full. fast disables the scheduler: the outbox tick and the hourly draft sweep
API_BIND_HOST, INTERNAL_CLIENT_IP_TOKEN
Confirm both are present. The API refuses to boot in production without them (env.validation.ts:823-850)
PORT
Set it explicitly. The defaults disagree: schema 3003, main.ts5000, VPS 5002. Keep nginx proxy_pass equal to it
The existing section 13.1 ns-api block already meets every POS requirement. Do not "improve" these away:
Forward Host, X-Real-IP, X-Forwarded-For and X-Forwarded-Proto.
Keep blanking X-Internal-Client-Ip and X-Internal-Client-Ip-Token.
Serve /health/live and /health/ready unprefixed, with no auth, rate limit or redirect. The POS pings /health/live every 15 s.
No redirects on the API host. POS requests use redirect: "error". The port-80 to 443 redirect is fine.
No websocket support is needed for POS.
POS body limits are 256 KB per request and 5 MB per response, with a 15 s timeout (nano-store-pos/src/shared/constants.ts: MAX_REQUEST_BODY_BYTES, MAX_RESPONSE_BODY_BYTES, API_TIMEOUT_MS). The existing client_max_body_size 25M and proxy_read_timeout 300s are well above them.
Server. The packaged app defaults to https://api.nanostore.com.np (PRODUCTION_API_URL, nano-store-pos/src/shared/constants.ts:6). For another domain, change the constant and rebuild, or launch with --api-url=https://…, which logs the user out because the stored session belongs to the old server.
CORS and CSP. HTTP calls come from the Electron main process. No CORS applies and no CORS_ORIGINS entry is needed. Do not add the API to the CSP.
Unsigned installers. There is no auto-update; reinstall each till for a new version.
Windows: SmartScreen, "More info", then "Run anyway".
macOS: System Settings, Privacy & Security, "Open Anyway", or:
xattr -dr com.apple.quarantine "/Applications/Nano Store POS.app"
Build commands (run in nano-store-pos):
OS
Command
Where it runs
Linux
pnpm package:linux
Linux
Windows
pnpm package:win
Windows, or Linux with Wine
macOS
pnpm package:mac
A Mac only
Build from a short path. NSIS makensis crashed from a path of about 190 characters.
The POS serial-numbers feature adds 0073_order_item_serial_release. Deploy order: the migration, then the backend, then the POS app. The migration takes ACCESS EXCLUSIVE locks on order_item_serial with lock_timeout = 5s; run it in a quiet window and re-run it if it times out (it is all-or-nothing). Its down file refuses once any serial has been released. Details: /docs/developer/pos/serials.
migrate-down.ts refuses production-looking URLs, so a production reversal is by hand with a backup taken first. The down files are in packages/db/src/migrations/down/.
Down file
Behaviour
0072_pos_counter_walk_in_customer.down.sql
Refuses while any pos_sale or order references the walk-in customer; otherwise deletes the row
0071_pos_counter_returns.down.sql
Refuses while pos_counter_returns holds any row; otherwise drops the table
0070_order_refund_method_counter.down.sql
A no-op (SELECT 1;). PostgreSQL has no DROP VALUE, so card_reversal and qr_reversal stay on the enum
0073_order_item_serial_release.down.sql
Refuses once any serial has been released or a serial has duplicate history
After the first POS sale or counter return the guards in 0071 and 0072 fire, and 0073 refuses once any serial is released or duplicate history exists, so the schema is forward-fix only after first use.
Code-only rollback after first use: leave the schema in place. pos_counter_returns stays, and returns already recorded lose their UI.