snowcookie/generate-schema

Generate schema from database

v5.0.0 2020-09-28 01:45 UTC

This package is auto-updated.

Last update: 2021-10-21 16:41:41 UTC


README

Build Status

Generate schema from database

Requirement

Laravel GenerateSchema
6.x 3.x
7.x 4.x
8.x 5.x

Usage

  • add packeage
composer require --dev snowcookie/generate-schema
  • add conditionally loading service provider to app/Providers/AppServiceProvider.php
public function register()
{
    ...

    if ($this->app->environment('local')) {
        $this->app->register('Snowcookie\GenerateSchema\GenerateSchemaServiceProvider');
    }
    ...
}
  • publish config file
php artisan vendor:publish --tag=generate-schema
  • generate scheam with command
php artisan tools:generate_schema --storage_disk=local

Support Database

  • Mysql 8 (MysqlManager)
  • Postgres 11 (PostgresManager)

Extend Database Manager

<?php

use Snowcookie\GenerateSchema\Contracts\GeneratorDatabaseManager;

class CustomGeneratorDatabaseManager implements GeneratorDatabaseManager
{
    ...
}

Support Renderer

  • Plain text (TxtRenderer, per table one file)

example: migrations.txt

+-----------+------------------+-----+----------+---------+-----------------+------------+------------+
| name      | type             | key | nullable | default | constraint_name | index_name | referenced |
+-----------+------------------+-----+----------+---------+-----------------+------------+------------+
| id        | int(10) unsigned | PRI | NO       |         |                 | PRIMARY    |            |
| migration | varchar(255)     |     | NO       |         |                 |            |            |
| batch     | int(11)          |     | NO       |         |                 |            |            |
+-----------+------------------+-----+----------+---------+-----------------+------------+------------+
  • Csv (CsvRenderer, per table one file, delimiter ,)
  • Xlsx (XlsxRenderer, one file, per table one sheet)

Extend Renderer

<?php

use Snowcookie\GenerateSchema\Contracts\GeneratorRenderer;

class CustomGeneratorRenderer implements GeneratorRenderer
{
    ...
}