PSA/docs/migrations/local-ee-migrations.md
Hermes 284313f908
Some checks are pending
Bidi Control Character Guard / bidi-control-guard (push) Waiting to run
Circular Dependency Check / Check for new circular dependencies (push) Waiting to run
Citus Migration Smoke / Combined migrations on single-node Citus (push) Waiting to run
E2E Fresh Install Tests / fresh-install-e2e (push) Waiting to run
ext-v2 guardrails / Run ext-v2 guard and ESLint (push) Waiting to run
Integration Tests / Check for relevant changes (push) Waiting to run
Integration Tests / ${{ (github.event_name == 'schedule' || github.event.inputs.suite == 'full') && 'Full integration suite' || 'Tier-1 integration subset' }} (push) Blocked by required conditions
Mobile checks / Mobile lint + typecheck (push) Waiting to run
Mobile checks / Mobile unit tests (push) Waiting to run
Mobile checks / Mobile dependency audit (report) (push) Waiting to run
Mobile checks / Mobile reproducibility checks (push) Waiting to run
Secrets guard (env backups) / Ensure no tracked env backup files (push) Waiting to run
Temporal Readiness / fast-readiness (push) Waiting to run
Temporal Readiness / docker-parity (push) Waiting to run
TypeScript Type Check / Nx affected typecheck (push) Waiting to run
Unit Tests / Skipped-test budget (push) Waiting to run
Unit Tests / Nx affected unit tests (push) Waiting to run
Unit Tests / Server unit coverage (informational) (push) Waiting to run
Validate Tenant Management Schema / Check for relevant changes (push) Waiting to run
Validate Tenant Management Schema / Validate Tenant Management Schema (push) Blocked by required conditions
EE Workflows Build Guard / ee-workflows-build-guard (push) Waiting to run
Initial import of AlgaPSA codebase from PSA server
Excluded: .git, node_modules, secrets/, compose.env, assemblyscript tgz

Source: /opt/alga-psa on psa.joliet.tech
2026-06-22 16:12:17 -05:00

57 lines
2.6 KiB
Markdown

# Running EE Migrations Locally (Without Copying Into Repo)
Goal: run Community Edition (CE) and Enterprise Edition (EE) migrations together on a developer workstation without physically copying or committing merged files into the repository.
Summary
- CE migrations live in `server/migrations/`
- EE migrations live in `ee/server/migrations/`
- Locally, use a temp-dir overlay: copy CE first, then overlay EE, run Knex pointing at the temp dir
- Nothing is written inside the repo, avoiding accidental commits or duplication
How it works
- `server/knexfile.cjs` now honors `MIGRATIONS_DIR` (defaults to `./migrations`)
- New helper: `server/scripts/run-ee-migrations.js`
- Creates a temp directory under your OS tmp
- Copies `server/migrations` into it
- Overlays `ee/server/migrations` on top (EE overwrites on filename conflicts)
- Runs `npx knex migrate:latest --env migration` with `MIGRATIONS_DIR` pointing to that temp dir
Prerequisites
- Local DB reachable based on `server/.env`
- Node 20+, repo dependencies installed
Commands
- From repo root: `npm -w server run migrate:ee`
- Or from `server/`: `npm run migrate:ee`
What the script does
- Uses the `migration` environment from `server/knexfile.cjs` so migrations run with admin credentials
- Leaves the temp directory in place for inspection; the script prints its path
Rollback or targeted steps (optional)
- Today, the helper runs only `migrate:latest`
- If you need down/targeted steps, two options:
1) Re-run the script to produce a fresh merged temp dir, then run Knex manually against it:
- `NODE_ENV=migration MIGRATIONS_DIR=/path/to/temp/migrations npx knex migrate:down --knexfile server/knexfile.cjs --env migration`
- Or specify a particular file with `migrate:up <file>`/`migrate:down <file>`
2) Ask to add `migrate:ee:down`/`migrate:ee:up <file>` wrappers; we can extend the helper to support those flows
Do not commit merged migrations
- Never copy the merged/overlay results into `server/migrations/`
- All merging happens in a temporary folder under the OS tmp
CI/CD vs local
- CI/CD images still combine/overlay migrations during build/entrypoint as before
- Locally, use the temp-dir approach to avoid churn in version control
Troubleshooting
- Ensure `server/.env` contains correct DB host/user/password for the `migration` env
- If you need to inspect what ran, open the printed temp path
- If `npx knex` fails, run the command it prints with `--debug` for more detail
Files involved
- `server/knexfile.cjs` (supports `MIGRATIONS_DIR`)
- `server/scripts/run-ee-migrations.js` (temp overlay + invoker)
- `server/package.json` → script `migrate:ee`