PHPackages                             cleaniquecoders/db-schema-auditor - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. cleaniquecoders/db-schema-auditor

ActiveLibrary[Database &amp; ORM](/categories/database)

cleaniquecoders/db-schema-auditor
=================================

Audit Database Schema Design

1.1.0(1mo ago)1173[4 PRs](https://github.com/cleaniquecoders/db-schema-auditor/pulls)MITPHPPHP ^8.4CI passing

Since Oct 7Pushed 1mo agoCompare

[ Source](https://github.com/cleaniquecoders/db-schema-auditor)[ Packagist](https://packagist.org/packages/cleaniquecoders/db-schema-auditor)[ Docs](https://github.com/cleaniquecoders/db-schema-auditor)[ GitHub Sponsors]()[ RSS](/packages/cleaniquecoders-db-schema-auditor/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (28)Versions (7)Used By (0)

Audit Database Schema Design
============================

[](#audit-database-schema-design)

[![Latest Version on Packagist](https://camo.githubusercontent.com/7c379309fe6dd09ce39ee72aaefe025075cf71fc6ffb8a4d9cf5ea0c0874ccec/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636c65616e69717565636f646572732f64622d736368656d612d61756469746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/cleaniquecoders/db-schema-auditor)[![GitHub Tests Action Status](https://camo.githubusercontent.com/c8be840c6f6f1e0fd16ab90eea907bc1d651d331ee6ad100d7ac933a2b0ad804/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f636c65616e69717565636f646572732f64622d736368656d612d61756469746f722f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/cleaniquecoders/db-schema-auditor/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/a1c804f7f844397706555cab0cb43a509a40d03216042a14c6984fd7083fc314/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f636c65616e69717565636f646572732f64622d736368656d612d61756469746f722f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/cleaniquecoders/db-schema-auditor/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/6dffdced0f24c4293c4e8fbc8b5f7426fe01936e708f582322b49c77014d2f1f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636c65616e69717565636f646572732f64622d736368656d612d61756469746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/cleaniquecoders/db-schema-auditor)

Audit Database Schema Design.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require cleaniquecoders/db-schema-auditor --dev
```

You can publish and run the migrations with:

```
php artisan vendor:publish --tag="db-schema-auditor-migrations"
php artisan migrate
```

You can publish the config file with:

```
php artisan vendor:publish --tag="db-schema-auditor-config"
```

Usage
-----

[](#usage)

```
# Basic audit - displays summary in console
php artisan db:audit

# Audit with model relationship analysis
php artisan db:audit --models

# Output as JSON to default path (/database/audit/)
php artisan db:audit --format=json

# Output as JSON to specified directory
php artisan db:audit --format=json --path=/storage/audit

# Output as Markdown
php artisan db:audit --format=markdown

# Output as CSV
php artisan db:audit --format=csv

# Output as HTML report
php artisan db:audit --format=html

# Generate fix migrations automatically
php artisan db:audit --generate-fixes

# Save results to database for tracking
php artisan db:audit --save-database

# Audit specific database connection
php artisan db:audit --connection=secondary

# Full audit with all options
php artisan db:audit --models --generate-fixes --save-database --format=markdown
```

### Supported Database Types

[](#supported-database-types)

This package supports all major database types:

- **MySQL** / **MariaDB** - Full support for indexes, foreign keys, and constraints
- **PostgreSQL** - Complete support including partial indexes and advanced features
- **Microsoft SQL Server** - Full support for SQL Server specific features
- **Oracle** - Support for Oracle-specific indexes and constraints
- **SQLite** - Basic support for SQLite databases

### Output Formats

[](#output-formats)

- **console** (default) - Colored terminal output with recommendations
- **json** - Machine-readable JSON format for integration
- **markdown** - GitHub-flavored markdown for documentation
- **csv** - Spreadsheet-compatible format for analysis
- **html** - Styled HTML report for sharing

### What Gets Audited

[](#what-gets-audited)

**Database Structure:**

- Missing indexes on foreign key columns
- Missing indexes on commonly queried columns
- Missing unique constraints
- Missing foreign key constraints
- Orphaned records in relationships
- Suspicious column patterns

**Model Relationships (with --models flag):**

- Missing inverse relationships
- Relationship naming inconsistencies
- Missing model relationships for database foreign keys
- Relationship method issues

### Generated Outputs

[](#generated-outputs)

**Migration Files (with --generate-fixes):**

- Index creation migrations
- Unique constraint migrations
- Foreign key suggestion migrations (commented for review)
- Orphaned record cleanup scripts

**Database Storage (with --save-database):**

- Complete audit history
- Issue tracking and resolution status
- Model analysis results
- Performance trending over time

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Nasrul Hazim Bin Mohamad](https://github.com/nasrulhazim)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

45

—

FairBetter than 92% of packages

Maintenance91

Actively maintained with recent releases

Popularity13

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 86.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~174 days

Total

2

Last Release

43d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b57069d0f4b634f65eccc6e5d5848990e25968d45ec2cf46d626c6a4658f944b?d=identicon)[nasrulhazim.m](/maintainers/nasrulhazim.m)

---

Top Contributors

[![nasrulhazim](https://avatars.githubusercontent.com/u/10341422?v=4)](https://github.com/nasrulhazim "nasrulhazim (13 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")

---

Tags

laravelCleanique Codersdb-schema-auditor

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/cleaniquecoders-db-schema-auditor/health.svg)

```
[![Health](https://phpackages.com/badges/cleaniquecoders-db-schema-auditor/health.svg)](https://phpackages.com/packages/cleaniquecoders-db-schema-auditor)
```

###  Alternatives

[dyrynda/laravel-model-uuid

This package allows you to easily work with UUIDs in your Laravel models.

4802.8M8](/packages/dyrynda-laravel-model-uuid)[spatie/laravel-model-flags

Add flags to Eloquent models

4301.1M1](/packages/spatie-laravel-model-flags)[clickbar/laravel-magellan

This package provides functionality for working with the postgis extension in Laravel.

423715.4k1](/packages/clickbar-laravel-magellan)[spatie/laravel-sql-commenter

Add comments to SQL queries made by Laravel

1931.4M1](/packages/spatie-laravel-sql-commenter)[spatie/laravel-deleted-models

Automatically copy deleted records to a separate table

409109.8k4](/packages/spatie-laravel-deleted-models)[wnx/laravel-backup-restore

A package to restore database backups made with spatie/laravel-backup.

203330.1k2](/packages/wnx-laravel-backup-restore)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
