Generate schema from database
Laravel | GenerateSchema |
---|---|
6.x | 3.x |
7.x | 4.x |
8.x | 5.x |
9.x | 6.x |
10.x | 7.x |
- add packeage
composer require --dev snowcookie/generate-schema
- add conditionally loading service provider to app/Providers/AppServiceProvider.php
public function register()
{
...
if (class_exists('Snowcookie\GenerateSchema\GenerateSchemaServiceProvider')) {
$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
- Mysql (MysqlManager)
- Postgres (PostgresManager)
<?php
use Snowcookie\GenerateSchema\Contracts\GeneratorDatabaseManager;
class CustomGeneratorDatabaseManager implements GeneratorDatabaseManager
{
...
}
- 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)
<?php
use Snowcookie\GenerateSchema\Contracts\GeneratorRenderer;
class CustomGeneratorRenderer implements GeneratorRenderer
{
...
}