Registry / database / gs-migrations

gs-migrations

JSON →
library1.0.146jsnpmunverified

Database migration and seeding package for GoSafe applications (v1.0.146). Provides CLI and programmatic API for running migrations, rollbacks, seeding, and resetting databases. Designed specifically for the GoSafe ecosystem with a shared database connection via Sequelize. Ships TypeScript types. Active development with frequent releases (146+ versions). Key differentiators: tightly integrated with GoSafe apps, simple CLI, and shared connection management.

npm install gs-migrations
INSTALL
IMPORT
SIG · GS-MIGRATIONS
G
gs-migrations
databasejavascriptv1.0.146
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

runMigrations
import { runMigrations } from 'gs-migrations'
const { runMigrations } = require('gs-migrations')
Package is ESM-only; CommonJS require is not supported.
runRollback
import { runRollback } from 'gs-migrations'
import runRollback from 'gs-migrations'
runRollback is a named export, not default.
runSeed
import { runSeed } from 'gs-migrations'

Shows how to programmatically run migrations and seeds using the package's main exports with a Sequelize connection.

import { runMigrations, runRollback, runSeed, resetDatabase } from 'gs-migrations'; import { Sequelize } from 'sequelize'; async function main() { const sequelize = new Sequelize( process.env.DB_NAME ?? 'test', process.env.DB_USER ?? 'root', process.env.DB_PASS ?? '', { host: 'localhost', dialect: 'mysql' } ); await runMigrations(sequelize); console.log('Migrations complete.'); await runSeed(sequelize); console.log('Seeding complete.'); } main().catch(console.error);
Debug
Known issues
gotchaThe package exports are ESM-only; do not use CommonJS require() as it will throw an error.
fix
Use ES module imports (import { ... } from 'gs-migrations') or set 'type':'module' in package.json if using Node.js < 16.
affects: >=1.0.0
gotchaThe shared database connection via getSequelize() is only available after calling initializeDatabase(). Attempting to getSequelize() before initialization returns undefined.
fix
Always call initializeDatabase() first and await its completion before using getSequelize().
affects: >=1.0.0
breakingIn v1.0.50, the signature of runMigrations changed from (path: string) to (sequelize: Sequelize, options?: MigrationOptions). Old code passing a path string will break.
fix
Pass a Sequelize instance as first argument and optionally an options object as second.
affects: >=1.0.50
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module /node_modules/gs-migrations/src/index.ts from /app/index.js not supported.
Trying to require() an ES module with CommonJS require().
fix
Use import statement or set type: 'module' in your package.json and rename .js to .mjs if needed.
TypeError: getSequelize is not a function
getSequelize is not exported from the package (it may be internal).
fix
Use the sequelize instance you pass to runMigrations, or import initializeDatabase and getSequelize if they exist.
SequelizeConnectionError: Access denied for user 'user'@'host' (using password: NO)
Missing or incorrect database credentials in environment variables.
fix
Set DB_USER, DB_PASS, DB_NAME, DB_HOST, DB_PORT environment variables correctly.
Upgrade
Version history
1.0.146latest on npm
Audit
Dependencies
sequelizerequiredCore ORM for database connection and operations
Agent activity
6 hits · last 30 days
node
6
Resources
gs-migrations — npm install gs-migrations · libregistry