1.3.2 • Published 2 years ago
seam-pgm v1.3.2
seam-pgm (Seam node-pg-migrate)
Seam uses node-pg-migrate to run database migrations.
node-pg-migrate requires some custom commands/setup to be compatible with the typical seam configuration. Namely...
- Use Typescript
- Put migrations in
src/db/migrations - "Standard Shorthands" for uuids and
created_attimestamps - Code to automatically run migrations in tests
- Automatic zapatos/kysely type generation
- Reset database and migrate scripts
- Automatic
src/db/zapatoswhich dumps the database structure - Automatic
src/db/structurewhich dumps the database structure
This module encapsulates all that functionality into one, easy-to-use module.
Usage
Scripts
Note:
seam-node-pg-migrateis abbreviated toseam-pgm, either is valid as an executable
seam-pgm init- Set up a project to useseam-pgmseam-pgm create-migration- create new migrationseam-pgm reset- drop database and recreate, then migrateseam-pgm migrate- migrate databaseseam-pgm generate- migrate database and generate new types and structure
Config
By running seam-pgm init you'll automatically get a config generated, here's
what you can customize:
module.exports = {
defaultDatabase: "mydb",
schemas: ["main"],
// Directory to store migrations, structure and database utility files
dbDir: "./src/db", // optional
}