-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Guillaume Chau
committed
Aug 23, 2019
1 parent
0208c32
commit 4b76719
Showing
8 changed files
with
110 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"name": "@nodepack/db-migrator", | ||
"version": "0.4.4", | ||
"description": "Database Migration system for Nodepack", | ||
"author": "Guillaume Chau <[email protected]>", | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/Akryum/nodepack.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/Akryum/nodepack/issues" | ||
}, | ||
"homepage": "https://github.com/Akryum/nodepack#readme", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"main": "src/index.js", | ||
"typings": "types/index.d.ts", | ||
"scripts": { | ||
"test": "yarn test:lint", | ||
"test:lint": "eslint src" | ||
}, | ||
"dependencies": { | ||
"@nodepack/env-migrator": "^0.4.4" | ||
}, | ||
"devDependencies": { | ||
"@nodepack/service": "^0.4.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
exports.Migrator = require('./lib/Migrator') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* @typedef FileMigrationRecord | ||
* @prop {string} file | ||
* @prop {string} date | ||
*/ | ||
|
||
const { Migrator: EnvMigrator } = require('@nodepack/env-migrator') | ||
|
||
module.exports = class Migrator extends EnvMigrator { | ||
/** | ||
* @private | ||
*/ | ||
async setup () { | ||
await this.readMigrationRecords() | ||
} | ||
|
||
/** | ||
* @private | ||
*/ | ||
async readMigrationRecords () { | ||
if (!this.context.readDbMigrationRecords) { | ||
throw new Error(`No 'readDbMigrationRecords' method provided by context`) | ||
} | ||
const data = await this.context.readDbMigrationRecords() | ||
this.fileMigrationRecords = data.files | ||
} | ||
|
||
/** | ||
* @private | ||
*/ | ||
async writeMigrationRecords () { | ||
if (!this.context.writeDbMigrationRecords) { | ||
throw new Error(`No 'writeDbMigrationRecords' method provided by context`) | ||
} | ||
await this.context.writeDbMigrationRecords({ | ||
files: this.fileMigrationRecords, | ||
plugins: [], | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as Migrator } from '../src/lib/Migrator' |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters