-
-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a CI job that makes sure umzug works as a package. Do that by: - adding a "vanilla" usage example which has no dependencies whatsoever - in a job, build then use `npm pack` to create a .tgz - in another job (i.e. without node_modules) download and install that tgz in the vanilla example folder - run some basic commands to make sure it works --------- Co-authored-by: Misha Kaletsky <[email protected]>
- Loading branch information
Showing
9 changed files
with
271 additions
and
191 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
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 @@ | ||
[] |
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,14 @@ | ||
const { Umzug, JSONStorage } = require('umzug'); | ||
|
||
exports.migrator = new Umzug({ | ||
migrations: { | ||
glob: 'migrations/*.js', | ||
}, | ||
context: { directory: __dirname + '/ignoreme' }, | ||
storage: new JSONStorage({ path: 'ignoreme/uzmug.json' }), | ||
logger: console, | ||
}); | ||
|
||
if (require.main === module) { | ||
exports.migrator.runAsCLI(); | ||
} |
12 changes: 12 additions & 0 deletions
12
examples/0.vanilla/migrations/2023.11.03T16.52.04.users-table.js
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,12 @@ | ||
const { promises: fs } = require('fs'); | ||
|
||
/** @type {typeof import('../migrate').migrator['_types']['migration']} */ | ||
exports.up = async ({ context }) => { | ||
await fs.mkdir(context.directory, { recursive: true }); | ||
await fs.writeFile(context.directory + '/users.json', JSON.stringify([], null, 2)); | ||
}; | ||
|
||
/** @type {typeof import('../migrate').migrator['_types']['migration']} */ | ||
exports.down = async ({ context }) => { | ||
await fs.unlink(context.directory + '/users.json'); | ||
}; |
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,16 @@ | ||
This example shows the simplest possible, node-only setup for Umzug. No typescript, no database, no dependencies. | ||
|
||
Note: | ||
- The `context` for the migrations just contains a (gitignored) directory. | ||
- The example migration just writes an empty file to the directory | ||
|
||
```bash | ||
node migrate --help # show CLI help | ||
|
||
node migrate up # apply migrations | ||
node migrate down # revert the last migration | ||
node migrate create --name new-migration.js # create a new migration file | ||
|
||
node migrate up # apply migrations again | ||
node migrate down --to 0 # revert all migrations | ||
``` |
Oops, something went wrong.