Skip to content

Stop app on unapplied migrations ? #4700

Closed Answered by shrynx
shrynx asked this question in Help
Discussion options

You must be logged in to vote

added the following as a provider and it works well

import app from "@adonisjs/core/services/app";
import type { ApplicationService } from "@adonisjs/core/types";
import { MigrationRunner } from "@adonisjs/lucid/migration";
import db from "@adonisjs/lucid/services/db";

export default class MigrationCheckProvider {
  constructor(protected app: ApplicationService) {}

  async start() {
    if (this.app.getEnvironment() === "web") {
      const migrator = new MigrationRunner(db, app, {
        direction: "up",
        dryRun: true,
      });
      const migrations = await migrator.getList();
      const incompleteMigrations = migrations.filter(
        (m) => m.status !== "migrated",
      );

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by shrynx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
1 participant