old migration typing.

This commit is contained in:
mike12345567 2024-12-03 16:28:04 +00:00
parent 82088544f1
commit b1dc997390
3 changed files with 23 additions and 4 deletions

View File

@ -1,24 +1,33 @@
import { context } from "@budibase/backend-core"
import { migrate as migrationImpl, MIGRATIONS } from "../../migrations"
import { Ctx } from "@budibase/types"
import {
Ctx,
FetchOldMigrationResponse,
GetOldMigrationStatus,
RunOldMigrationRequest,
} from "@budibase/types"
import {
getAppMigrationVersion,
getLatestEnabledMigrationId,
} from "../../appMigrations"
export async function migrate(ctx: Ctx) {
export async function migrate(ctx: Ctx<RunOldMigrationRequest, void>) {
const options = ctx.request.body
// don't await as can take a while, just return
migrationImpl(options)
ctx.status = 200
}
export async function fetchDefinitions(ctx: Ctx) {
export async function fetchDefinitions(
ctx: Ctx<void, FetchOldMigrationResponse>
) {
ctx.body = MIGRATIONS
ctx.status = 200
}
export async function getMigrationStatus(ctx: Ctx) {
export async function getMigrationStatus(
ctx: Ctx<void, GetOldMigrationStatus>
) {
const appId = context.getAppId()
if (!appId) {

View File

@ -4,3 +4,4 @@ export * from "./events"
export * from "./configs"
export * from "./scim"
export * from "./license"
export * from "./oldMigration"

View File

@ -0,0 +1,9 @@
import { Migration, MigrationOptions } from "../../../sdk"
export interface RunOldMigrationRequest extends MigrationOptions {}
export type FetchOldMigrationResponse = Migration[]
export interface GetOldMigrationStatus {
migrated: boolean
}