Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into rm-import-eq
Browse files Browse the repository at this point in the history
  • Loading branch information
mmkal committed Nov 4, 2023
2 parents 10f2b47 + db53e34 commit 8a8ba89
Show file tree
Hide file tree
Showing 9 changed files with 272 additions and 192 deletions.
41 changes: 40 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: CI
on: [push, pull_request]

jobs:
build:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -29,3 +29,42 @@ jobs:
with:
node-version: 12.x
- run: npm test --ignore-scripts
create_tgz:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup node 20
uses: actions/setup-node@v2
with:
node-version: 20.x
- run: npm install
- run: npm run build
- run: npm pack
- run: mv $(ls | grep .tgz) umzug.tgz
- uses: actions/upload-artifact@v3
with:
name: tarball
path: umzug.tgz
test_tgz:
runs-on: ubuntu-latest
needs: [create_tgz]
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: tarball
- run: ls
- name: install tarball in examples directory
working-directory: examples/0.vanilla
run: |
rm -rf ../node_modules
npm init -y
npm install ../../umzug.tgz
- name: run example
run: |
cd examples/0.vanilla
node migrate up
node migrate down
node migrate create --name new-migration.js
node migrate up
- run: ls -R
1 change: 1 addition & 0 deletions examples/0.vanilla/ignoreme/uzmug.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
14 changes: 14 additions & 0 deletions examples/0.vanilla/migrate.js
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 examples/0.vanilla/migrations/2023.11.03T16.52.04.users-table.js
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');
};
16 changes: 16 additions & 0 deletions examples/0.vanilla/readme.md
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
```
Loading

0 comments on commit 8a8ba89

Please sign in to comment.