@13w/miri
v1.1.17
Published
MongoDB patch manager
Downloads
210
Readme
Migration manager
Migrations folder structure
- migrations/
- init/
- 01-create-collections.js
db.createCollection('users'); db.createCollection('goods');
- 02-create-default-users.js
db.users.insertOne({firstName: 'foo', lastName: 'zoo'}); db.users.insertOne({firstName: 'baz', lastName: 'poo'});
- 03-create-default-goods.js
db.goods.insertOne({name: 'lemon'}); db.goods.insertOne({name: 'orange'});
- 01-create-collections.js
- indexes/
- users.json
[ {name: 1} ]
- goods.json
[ [{name: 1}, { unique: true }] ]
- version-1/
- 01-02-2023-add-full-name.js
export const test = () => db.users.countDocuments({ fullName: { $exists: false } }); export const up = () => db.users.updateMany({ fullName: { $exists: false } }, [{ $set: { fullName: { $concat: ['$firstName', ' ', '$lastName'] } } }]) export const down = () => db.users.updateMany({}, {$unset: { fullName: 1 }})
- 04-05-2023-add-user-age.js
export const test = () => db.users.countDocuments({ age: { $exists: false } }); export const up => () => db.users.updateMany({ age: { $exists: false } }, {$set: { age: 135 }}) export const down = () => db.users.updateMany({}, {$unset: { age: 1 }})
- version-2/
- 05-08-2023-add-price-to-goods.js
export const test = () => db.goods.countDocuments({ price: { $exists: false } }); export const up => () => db.goods.updateMany({ price: { $exists: false } }, { $set: {price: 12.24} }) export const down = () => db.goods.updateMany({}, {$unset: { price: 1 }})
- init/