Skip to content

Commit

Permalink
feat: add onlyOne option to migrate and rollback helpers (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
imsitnikov committed May 22, 2024
1 parent b7aa6f5 commit b0cbb09
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions lib/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,26 @@ export function initDB({
await db.ready();
await db.primary.migrate.rollback({}, true);
},
rollbackDatabase: async function () {
rollbackDatabase: async function (args?: {onlyOne: boolean}) {
await db.ready();
await db.primary.migrate.rollback({});

const onlyOne = args ? args.onlyOne : false;

if (onlyOne) {
await db.primary.migrate.down();
} else {
await db.primary.migrate.rollback({});
}
},
migrateDatabase: async function () {
migrateDatabase: async function (args?: {onlyOne: boolean}) {
await db.ready();
await db.primary.migrate.latest();

const onlyOne = args ? args.onlyOne : false;
if (onlyOne) {
await db.primary.migrate.up();
} else {
await db.primary.migrate.latest();
}
},
prepareDatabase: async function () {
await db.primary.migrate.latest();
Expand Down

0 comments on commit b0cbb09

Please sign in to comment.