Registry / database / sequelize-typescript-migration-updated

sequelize-typescript-migration-updated

JSON →
library2.0.3jsnpmunverified

A migration tool for Sequelize and TypeScript users, providing a streamlined way to generate and run database migrations from annotated Sequelize models. Version 2.0.3 targets Node.js >=12 and ships TypeScript types. Compared to alternatives like sequelize-cli or umzug, this package focuses on seamless TypeScript integration and automatic migration creation from model definitions, reducing boilerplate. It is a community fork of the original sequelize-typescript-migration with continued updates.

npm install sequelize-typescript-migration-updated
INSTALL
IMPORT
SIG · SEQUELIZE-TYPESCRI
S
sequelize-typescript-migration-updated
databasejavascriptv2.0.3
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-migration-updated'
const generateMigration = require('sequelize-typescript-migration-updated')
ESM module; CommonJS require not supported (use import or dynamic import). Also, ensure TypeScript configuration includes 'esModuleInterop'.
generateMigration
const { generateMigration } = await import('sequelize-typescript-migration-updated')
const { generateMigration } = require('sequelize-typescript-migration-updated')
Dynamic import for CommonJS/Node environments; static import works only with ESM.

Generates a migration file from Sequelize model definitions in TypeScript, using SQLite as an example database.

import { Sequelize } from 'sequelize'; import { generateMigration } from 'sequelize-typescript-migration-updated'; const sequelize = new Sequelize({ dialect: 'sqlite', storage: ':memory:', }); (async () => { await generateMigration({ sequelize, queryInterface: sequelize.getQueryInterface(), modelPath: path.join(__dirname, '/models'), migrationPath: path.join(__dirname, '/migrations'), migrationName: 'create-user-table', overwrite: false, }); console.log('Migration generated successfully'); await sequelize.close(); })();
Debug
Known issues
gotchaDynamic import is required in CommonJS environments; static import fails with 'ERR_REQUIRE_ESM'.
fix
Use dynamic import or set 'type': 'module' in package.json for static import.
affects: >=2.0.0
deprecatedThe package is a fork; original package 'sequelize-typescript-migration' is no longer maintained.
fix
Switch to 'sequelize-typescript-migration-updated' for active development.
affects: *
gotchaModel path must point to a directory containing TypeScript model files; JavaScript files are not processed.
fix
Ensure modelPath points to .ts files or compile models to .js in the same directory.
affects: *
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module not supported
Using CommonJS require() to import an ESM-only package.
fix
Change to dynamic import: const { generateMigration } = await import('sequelize-typescript-migration-updated');
TypeError: sequelize.define is not a function
Sequelize instance passed incorrectly or not initialized.
fix
Verify sequelize is an instance of Sequelize (not a model or QueryInterface).
Cannot find module './models/User'
modelPath is incorrect or models are not compiled to JavaScript.
fix
Use absolute path and ensure models are TypeScript files or compile them before using.
Upgrade
Version history
2.0.3latest on npm
Audit
Dependencies
sequelizerequiredpeer dependency for model definitions
Agent activity
17 hits · last 30 days
node
14
Meta
2
Amazon
1
Resources
sequelize-typescript-migration-updated — npm install sequelize-typescript-migration-updated · libregistry