Registry / database / sequelize-typescript-model-repository-migration

sequelize-typescript-model-repository-migration

JSON →
library1.0.13jsnpmunverified

Auto-generate Sequelize migration scripts from sequelize-typescript model decorators, similar to Django's makemigration. Current stable version 1.0.13. Scans models for changes and generates up/down functions, resolving issues with @Index decorators, missing sequelizemeta table, and underscore table options. Uses snapshot files instead of SequelizeMetaMigration table. Supports prettier formatting. Release cadence is irregular. Alternative to umzug with manual migration writing.

npm install sequelize-typescript-model-repository-migration
INSTALL
IMPORT
SIG · SEQUELIZE-TYPESCRI
S
sequelize-typescript-model-repository-migration
databasejavascriptv1.0.13
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.

generateMigration
import { generateMigration } from 'sequelize-typescript-model-repository-migration'
const generateMigration = require('sequelize-typescript-model-repository-migration').generateMigration
Package is ESM and exports named function. CJS require may still work depending on bundler.

Shows how to generate a migration by scanning sequelize-typescript models.

import { Sequelize } from 'sequelize-typescript'; import { generateMigration } from 'sequelize-typescript-model-repository-migration'; import path from 'path'; const sequelize = new Sequelize({ database: process.env.DB_NAME ?? 'test', username: process.env.DB_USER ?? 'root', password: process.env.DB_PASS ?? '', dialect: 'postgres', host: process.env.DB_HOST ?? 'localhost', models: [path.join(__dirname, '/models')] }); await generateMigration(sequelize, { outDir: path.join(__dirname, '../migrations'), snapshotDir: path.join(__dirname, '../snapshots'), migrationName: 'my-migration', prettierOptions: { semi: true, singleQuote: true } });
Debug
Known issues
breakingSnapshot files are used to track model state instead of SequelizeMetaMigration table. Existing migration workflows may break if relying on that table.
fix
Remove old SequelizeMetaMigration table and ensure snapshotDir is provided and consistent across runs.
affects: >=1.0.0
gotchagenerateMigration expects a Sequelize instance with models already loaded. Forgetting to set `models` option will cause 'no matching model' error.
fix
Pass models array or path to Sequelize constructor before calling generateMigration.
affects: >=1.0.0
gotchaThe package name in npm is sequelize-typescript-model-repository-migration, but the README and import use sequelize-typescript-model-migration. Using wrong package name leads to installation errors.
fix
Install with npm i -D sequelize-typescript-model-repository-migration, then import from 'sequelize-typescript-model-migration'.
affects: >=1.0.0
deprecatedThe original sequelize-typescript-migration (by kimjbstar) is unmaintained. This fork addresses bugs but is itself not actively maintained.
fix
Consider using umzug with manual migrations or other tools if reliability is critical.
affects: all
Errors
Common errors & fixes
ERROR: No matching model found for 'ModelName'
Models not loaded into Sequelize instance before calling generateMigration.
fix
Ensure Sequelize constructor includes models option (array or path) that contains the target model.
Error: Cannot find module 'sequelize-typescript-model-repository-migration'
Package installed with wrong name or import mismatch.
fix
Install the correct package: npm i -D sequelize-typescript-model-repository-migration
Must use import to load ES Module: ...
Using require() on an ESM-only package.
fix
Use import { generateMigration } from 'sequelize-typescript-model-migration' instead of require.
Upgrade
Version history
1.0.13latest on npm
Audit
Dependencies
sequelizerequiredpeer dependency for Sequelize instance
sequelize-typescriptrequiredpeer dependency for model decorators (v2+)
prettieroptionaloptional dependency for formatting generated migration files
Agent activity
15 hits · last 30 days
node
12
Meta
1
Resources
sequelize-typescript-model-repository-migration — npm install sequelize-typescript-model-repository-migration · libregistry