Introduction

Laravel DB Analyzer is a developer tool to help you safely inspect, visualize, and understand your Laravel application's migrations and database structure.

It allows developers to simulate migration rollbacks, view changes before they're applied, and analyze existing schema — all without ever modifying the actual database. This makes it ideal for staging environments, code reviews, team collaboration, and debugging migration issues.

It performs read-only operations, never writing or changing the database content. Think of it as a database historian and previewer that keeps your data intact.

Getting Started

Before using this package, make sure your Laravel app is set up and your database connection is configured correctly in your .env file.

This tool works best when your migrations follow Laravel's conventions and are located in the default database/migrations directory.

Laravel DB Analyzer will scan both the migration files and the current schema to detect changes, dependencies, and actions.

Installation

Install the package via Composer:

composer require rhamadsani/migrationrollbackvisualizer

Once installed, Laravel will automatically register the service provider. No manual config is required.

Usage

The package offers Artisan commands to help inspect migration behavior:

  • php artisan visualize:rollback – Simulates a rollback and outputs what tables, columns, or indexes would be affected.
  • php artisan visualize:migrations – Shows a full list of your migration history, what has been applied, and what is pending.

Each command supports additional flags and options. For example:

php artisan visualize:rollback --mode=latest --format=json

This outputs the rollback analysis in JSON format for the latest migration batch.

Database Analyze

Beyond just migration previews, this package helps you deeply analyze your database schema in its current state. This includes:

  • Detecting which migrations introduced which schema changes
  • Highlighting unused tables or orphaned columns
  • Mapping relationships between migrations
  • Checking for mismatches between migration definitions and actual database structure

Use this to ensure your migrations match the real structure and maintain database consistency.