Pluma uses Prisma Migrate to
manage PostgreSQL schema changes. Migration files live in
packages/db/prisma/migrations/ and are included in every Docker release. When
the API container starts, pending migrations are applied automatically via
prisma migrate deploy.
Self-hosted operators do not need to run migrations manually — pulling and starting a new API image is sufficient.
| Change type | Examples | Docker bump | Backward compatible |
|---|---|---|---|
| Additive | New table, new nullable column, new index | Minor | Yes |
| Destructive | Drop column/table, rename with data loss, change column type | Major | No |
| Data migration | Backfill values, transform existing rows | Depends on context | Must be idempotent |
Additional rules:
- Never edit a migration after it is merged to
main. Prisma tracks migrations by name and checksum; editing a deployed migration will causeprisma migrate deployto fail. - Data migrations must be idempotent — safe to run more than once without side effects.
- Every destructive migration must include rollback guidance in the release notes.
Follow these steps when upgrading to a new Docker release:
-
Back up your database.
pg_dump -U pluma -d pluma > pluma_backup_$(date +%Y%m%d).sql
-
Pull the new Docker images.
docker pull ghcr.io/403-html/pluma-api:<version> docker pull ghcr.io/403-html/pluma-app:<version>
-
Restart the containers. Migrations run automatically when the API container starts. If using Docker Compose:
docker compose up -d
-
Verify the migration succeeded. Check the API container logs for Prisma migration output:
docker compose logs api
-
If a migration fails:
- Stop the containers.
- Restore the database from backup:
psql -U pluma -d pluma < pluma_backup_YYYYMMDD.sql - Report the issue on the Pluma issue tracker.
This matrix will be populated as versions are released.
| API image version | Minimum DB schema | Notes |
|---|---|---|
0.1.0 |
0.1.0 (initial) |
Baseline schema |
When a major Docker version includes destructive migrations, the release must provide:
- Explicit rollback SQL or step-by-step instructions to reverse the migration.
- Minimum backup recommendation — operators should retain a database backup from before the upgrade for at least 7 days.
- Tested upgrade path — the upgrade must be validated from the immediately preceding major version.
Check the GitHub Releases page for details on every major version.
SDK versions are forward-compatible within the same major API version:
- An SDK client built for API
v1.xwill continue to work with anyv1.yAPI release (wherey ≥ x). - Upgrading the API within a major version will not break existing SDK clients.
- A new major API version may change the SDK snapshot format (
/sdk/v1/*), requiring an SDK upgrade.
When upgrading across major API versions, upgrade the SDK to a version that supports the new major API version first, then upgrade the API.
Use the Prisma CLI through the workspace script:
pnpm --filter @pluma-flags/db db:migrateThis runs prisma migrate dev, which will:
- Detect schema changes in
packages/db/prisma/schema.prisma. - Generate a new migration SQL file in
packages/db/prisma/migrations/. - Apply the migration to your local database.
- Regenerate the Prisma Client.
- Always use
pnpm --filter @pluma-flags/db db:migrate(or the shorthandpnpm db:migratefrom thepackages/dbdirectory) to create migrations. - Never edit an existing migration file after it has been committed.
- Use
pnpm --filter @pluma-flags/db db:pushfor rapid prototyping only — it modifies the database schema without creating a migration file and must not be used in place of a real migration. - Use
pnpm --filter @pluma-flags/db db:studioto inspect data during development. - Test migrations locally against a fresh database before opening a PR:
docker compose down -v # remove existing volume docker compose up postgres -d # start fresh PostgreSQL pnpm --filter @pluma-flags/db db:migrate