add utils to migrations up and down

This commit is contained in:
Matt Hill
2023-05-05 10:45:21 -06:00
parent e32b768e5c
commit 8f69f3df9e
8 changed files with 54 additions and 51 deletions

View File

@@ -1,12 +1,13 @@
import { ManifestVersion } from "../../manifest/ManifestTypes"
import { Effects } from "../../types"
import { Utils } from "../../util"
export class Migration<Version extends ManifestVersion> {
export class Migration<Version extends ManifestVersion, WD> {
constructor(
readonly options: {
version: Version
up: (opts: { effects: Effects }) => Promise<void>
down: (opts: { effects: Effects }) => Promise<void>
up: (opts: { effects: Effects; utils: Utils<WD> }) => Promise<void>
down: (opts: { effects: Effects; utils: Utils<WD> }) => Promise<void>
},
) {}
static of<Version extends ManifestVersion>(options: {
@@ -17,11 +18,11 @@ export class Migration<Version extends ManifestVersion> {
return new Migration(options)
}
async up(opts: { effects: Effects }) {
async up(opts: { effects: Effects; utils: Utils<WD> }) {
this.up(opts)
}
async down(opts: { effects: Effects }) {
async down(opts: { effects: Effects; utils: Utils<WD> }) {
this.down(opts)
}
}