Migrations and templates
@exo/kit/migrate#
Exports: syncKitMigrations, checkKitMigrations, migrationVersion, migrateUpHalf. It also installs the command exo-kit-migrations.
Some kit modules need tables. The sign-in module needs account_sessions and the users.exo_sub column. The kit ships that SQL, and you copy it into your own migrations folder so that your migration tool (dbmate, or Prisma) can apply it with your own.
exo-kit-migrations sync --dir apps/api/migrations/kit --signin
exo-kit-migrations check --dir apps/api/migrations/kit --signin
import { signinMigrations } from '@exo/kit/signin';
import { checkKitMigrations, syncKitMigrations } from '@exo/kit/migrate';
const options = { files: signinMigrations(), dir: 'apps/api/migrations/kit' };
syncKitMigrations(options); // after a version bump; commit what it writes
checkKitMigrations(options); // in the build; { ok: false } should fail it
synccopies the files byte for byte. It never deletes a leftover file, because a file that was applied to a live database is not garbage.checkcompares your copies with the installed package and reportsmissing,changedandextra. It exits with 1 on any difference and writes nothing. Run it in your image build so a stale copy cannot ship.- Kit file names start with
20200101. That is an ordering floor, so the kit's tables exist before your own migrations that build on them. - Each file has a
-- migrate:upand a-- migrate:downblock. The down block raises an error: kit migrations do not roll back. - For accounts in a schema other than
public, add--no-auth --schema <name>to both commands.
Templates#
The package includes files that you copy, not code you import. A later version of the kit does not change a copy you already made.
| File | What it is |
|---|---|
templates/migrate.sh | A wrapper around dbmate for running migrations. |
templates/docker/<form>/Dockerfile | Seven Dockerfile archetypes. |
templates/docker/compose-service.yml | A compose service block. |
| Form | Directory | For |
|---|---|---|
| F1 | static-nginx | A static build behind an unprivileged nginx. |
| F2 | next-standalone | Next.js with standalone output. |
| F3 | node-api | A Node HTTP service in a pnpm monorepo, bundled with esbuild. |
| F4 | node-prisma | Next.js or Node with Prisma. |
| F5 | node-worker | A background Node process. |
| F6 | python-uv | A Python service on uv. |
| F7 | python-wrapper | A thin HTTP wrapper around a third-party Python tool. |
The comments in these files explain why each non-obvious line exists. Keep them when you copy.