Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eiskalteschatten/sequelize-migration-wrapper
A wrapper for migrating databases using Sequelize and Umzug.
https://github.com/eiskalteschatten/sequelize-migration-wrapper
database migration mysql nodejs postgresql sequelize sql sqlite umzug
Last synced: about 1 month ago
JSON representation
A wrapper for migrating databases using Sequelize and Umzug.
- Host: GitHub
- URL: https://github.com/eiskalteschatten/sequelize-migration-wrapper
- Owner: eiskalteschatten
- Created: 2019-04-08T12:57:49.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-06-12T21:14:16.000Z (over 1 year ago)
- Last Synced: 2024-09-26T20:57:39.727Z (about 2 months ago)
- Topics: database, migration, mysql, nodejs, postgresql, sequelize, sql, sqlite, umzug
- Language: TypeScript
- Homepage: https://www.alexseifert.com
- Size: 72.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# sequelize-migration-wrapper
> A wrapper for migrating databases using Sequelize and Umzug.
## Table of Contents
- Requirements
- Install
- Usage
- API
- Release Notes
- Maintainer## Requirements
This module is tested with Node.js 14. It might work with Node.js >= 12, but is not tested.
## Install
```
npm install --save sequelize-migration-wrapper
```## Usage
### Initialization
```js
import { setupMigration } from 'sequelize-migration-wrapper'; // TypeScript
const { setupMigration } = require('sequelize-migration-wrapper'); // CommonJSconst sequelize = new Sequelize({...});
setupMigration({
sequelize,
path: 'path/to/migration/scripts',
filePattern: /\.js$/
});
```#### Options
- sequelize (no default, must be a Sequelize instance; required),
- path (no default; required),
- filePattern (default: `/\.js$/`)## API
### migrate()
Runs through all migration scripts in the configured folder. Umzug automatically saves which migration scripts have already been run, so it will not re-run those.
```js
await migrateDb.migrate();
```### getStatus()
Get the current status of the migration
```js
const status = await migrateDb.getStatus();
```### migrateNext()
Iteratively run through migration scripts.
```js
for (const i in numberOfScriptsOrSomething) {
await migrateDb.migrateNext();
}
```### reset()
Undo the last migration using Umzug's `down` function. This will only work if your migration scripts provide a `down` function. See [Umzug's documentation](https://github.com/sequelize/umzug#migrations) for more details.
```js
await migrateDb.reset();
```### resetPrev()
Iteratively undo a migration. This will only work if your migration scripts provide a `down` function. See [Umzug's documentation](https://github.com/sequelize/umzug#migrations) for more details.
```js
for (const i in numberOfScriptsOrSomething) {
await migrateDb.resetPrev();
}
```## Release Notes
### 1.0.1
- Security updates
### 1.0.0
- Complete rewrite in TypeScript
- Support for Sequelize 6### 0.1.1
- Update dependencies to fix security vulnerabilities
### 0.1.0
- Initial release
## Maintainer
This modules is maintained by Alex Seifert ([Website](https://www.alexseifert.com), [Github](https://github.com/eiskalteschatten)).