abkrim/db-schema

A fork of thedevsaddam/laravel-schema of Saddam H thedevsaddam@gmail.com with some improvements and maintained

dev-master 2019-09-25 12:14 UTC

This package is auto-updated.

Last update: 2024-04-26 00:30:26 UTC


README

Latest Version on Packagist pipeline status coverage report Total Downloads

This package will help to display database dbSchema information from terminal or save in file

Installation

You can install the package via composer:

composer require --dev abkrim/db-schema

Publish config

php artisan vendor:publish 

Or use tag for install

php artisan vendor:publish --tag=config-db-schema

Usage

View or save a connections with version and information of each table

New command for see or show schema and indexes for any connections fo our Laravel project, using Doctrine instead use several wrappers. Only tested with MySQL (not testing phpunit, testing in production) but is possible that work fine with Postgresql, sqlite,...

On this version options for this command are in Laravel mode instead Symfony Model. Check with --help

php artisan db-schema:doctrine-list

Schema and indexes information in tabular form

See --help for more info

Show Schema information in tabular form

 php artisan db-schema:show

Example output: Schema information in tabular form

Schema information in tabular form

If you want to see a specific table then pass table name or Namespace\\Model

 php artisan db-schema:show --t=tableName or --t=Namespace\\Model

database info commandline

Note: Same condition will be applied for tables list view

Show Schema information in List

 php artisan db-schema:list

Example output: Schema information in list

database info commandline

Avaliable Options in show and list:

  • --t=tableName or -t tableName to provide table name or Namespace\Model
  • --c=connectionName or -c connectionName to provide connections name

Show Table names and total rows

 php artisan db-schema:simple

Example output: Tables name with rows count

Tables name with rows count

Note: You may pass --c=connectionName or -c connectionName to display a specific connections dbSchema info

Show table definition

 php artisan db-schema:table --t=tableName or --t=Namespace\\Model

Example output: Table definition with default page and limit

Table definition with default page and limit

Avaliable Options in table:

  • --t=tableName or -t tableName to provide table name or Namespace\\Model (e.g: --t=App\\User or --t=users).
  • --p=pageNumber or -p PageNumber to provide current page which you want to see
  • --o=orderBy or -o orderBy to provide orderBy clause against a column (e.g: --o=id:desc or --o=id:asc [default asc]).
  • --l=rowsLimitPerPage or -l rowsLimitPerPage to provide number of rows you want to display (e.g: --l=20).
  • --c=connectionName or -c connectionName to provide connections name
  • --w=widthOfTableCell or -w widthOfTableCell to provide character length of cell to show in tables (numeric [default=10]).
  • --s=columnName to provide the column to display, you can provide comma (,) separated names to display (e.g: --s=name or --s=id,name).
php artisan db-schema:table --t=countries --p=4 --o=id:desc --l=25

Perform raw sql query

 php artisan db-schema:query --r="your sql query"

Example output: Query result will be dumped in console

Query result will be dumped in console

Avaliable Options in query:

  • --r=yourRawQuery or -r yourRawQuery to provide your raw sql query (e.g: --r="select * from someTable limit 20").
  • --c=connectionName or -c connectionName to provide connections name (e.g: --c=mysql or -c sqlite)

Monitor database server

 php artisan db-schema:monitor

Example output: Showing the database status

Schema information in tabular form

You can pass --i=integerNumber as refresh time interval and --c=ConnectionName as well

 php artisan db-schema:monitor --i=3 --c=secondaryDatabase

Testing

composer test

Laravel versions

This package is only tested in Laravel 6.0 (not test at now, but are coming soon). For older versión try use original package

For older versions that do not have auto discover providers you may need to add service provider.

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email abdelkarim.mateos@castris.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Laravel Package Boilerplate

This package was generated using the Laravel Package Boilerplate.