Registry / database / sequelize-typescript-mysql-migration

sequelize-typescript-mysql-migration

JSON →
library1.0.0jsnpmunverified

Auto-generates migration scripts from sequelize-typescript models by scanning decorators to detect changes and produce migration code with up/down functions, similar to Django's makemigration. Version 1.0.0 targets sequelize v6 and sequelize-typescript v2. Fixes several unresolved issues from predecessor (kimjbstar/sequelize-typescript-migration) including @Index support and PostgreSQL 'relation sequalizemeta does not exist'. Adds snapshot file storage, prettier formatting, and enhanced index handling with underscore option.

npm install sequelize-typescript-mysql-migration
INSTALL
IMPORT
SIG · SEQUELIZE-TYPESCRI
S
sequelize-typescript-mysql-migration
databasejavascriptv1.0.0
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-migration';
const generateMigration = require('sequelize-typescript-model-migration');
ESM import; the library is TypeScript-native and provides types.
GenerateMigrationOptions
import type { GenerateMigrationOptions } from 'sequelize-typescript-model-migration';
import { GenerateMigrationOptions } from 'sequelize-typescript-model-migration';
Use type import for Options interface when not needed at runtime.
Model
import { Model } from 'sequelize-typescript';
import { Model } from 'sequelize-typescript-model-migration';
Model is from sequelize-typescript, not from this migration package.

Demonstrates creating a Sequelize instance with models, then generating a migration file using the package's generateMigration function.

import { Sequelize } from 'sequelize-typescript'; import { generateMigration } from 'sequelize-typescript-model-migration'; const sequelize = new Sequelize({ database: process.env.DB_NAME ?? '', username: process.env.DB_USER ?? '', password: process.env.DB_PASS ?? '', host: process.env.DB_HOST ?? 'localhost', dialect: 'mysql', models: [__dirname + '/models'], // path to your model files }); async function migrate() { await generateMigration(sequelize, { outDir: './migrations', snapshotDir: './snapshots', migrationName: 'initial', prettierOptions: { singleQuote: true }, }); } migrate().catch(console.error);
Debug
Known issues
deprecatedThe sequelize-typescript-model-migration package is a fork with limited maintenance.
fix
Consider using sequelize-migrate or umzug for more robust migration handling.
affects: >=1.0.0
gotchaSnapshot files are stored locally and must be committed to version control for consistent migration generation across environments.
fix
Ensure snapshotDir is included in your repository and not in .gitignore.
affects: >=1.0.0
gotchaThe library only supports MySQL as per its description (though may work with other dialects).
fix
If using PostgreSQL or other dialects, test thoroughly or consider alternatives.
affects: >=1.0.0
gotchaModels must be loaded into Sequelize via the `models` option; the library does not auto-discover model files.
fix
Pass the correct path to your model files in the Sequelize constructor.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'sequelize-typescript-model-migration'
Package not installed or not installed locally.
fix
Run 'npm install --save-dev sequelize-typescript-model-migration'
TypeError: sequelize.define is not a function
Sequelize instance not configured correctly; likely missing models or incorrect dialect.
fix
Ensure Sequelize is instantiated with 'models' option pointing to valid TypeScript model files.
Migration file not generated: No changes detected
Snapshot matches current model state; no differences found.
fix
If expecting changes, delete existing snapshot file and rerun generateMigration.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies
sequelize-typescriptrequiredPeer dependency; package scans model decorators from this library.
sequelizerequiredRequired for migration execution; used by underlying Sequelize migration mechanism.
Agent activity
7 hits · last 30 days
node
6
Meta
1
Resources
sequelize-typescript-mysql-migration — npm install sequelize-typescript-mysql-migration · libregistry