import {Unit, Singleton, MigrateDirective} from '@extollo/lib'

/**
 * Apply migrations when the application starts up.
 * This is way more convenient than `./ex migrate` for Kubernetes deployments.
 */
@Singleton()
export class MigrateUnit extends Unit {
    async up() {
        const directive = this.make<MigrateDirective>(MigrateDirective)
        await directive.invoke([])
    }
}
