From 989168b511ed277d8658c8392b8cb584ea796d5c Mon Sep 17 00:00:00 2001 From: ShibuyaKosuke Date: Sun, 5 Sep 2021 21:55:28 +0900 Subject: [PATCH] mod --- src/Exports/DdlExport.php | 3 ++- src/Models/Contracts/TableInterface.php | 3 +++ src/Models/Repositories/MysqlManageView.php | 3 ++- src/sql/mysql_create_view.sql | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Exports/DdlExport.php b/src/Exports/DdlExport.php index cf9922d..862238f 100644 --- a/src/Exports/DdlExport.php +++ b/src/Exports/DdlExport.php @@ -2,6 +2,7 @@ namespace ShibuyaKosuke\LaravelDdlExport\Exports; +use Illuminate\Console\OutputStyle; use Illuminate\Support\Collection; use Maatwebsite\Excel\Concerns\Exportable; use Maatwebsite\Excel\Concerns\WithEvents; @@ -33,7 +34,7 @@ class DdlExport implements WithMultipleSheets, WithEvents * @param mixed $output * @param Collection|TableInterface[] $tables */ - public function __construct($output, $tables) + public function __construct(OutputStyle $output, Collection $tables) { $this->output = $output; $this->tables = $tables; diff --git a/src/Models/Contracts/TableInterface.php b/src/Models/Contracts/TableInterface.php index 667f4bf..93dc8ab 100644 --- a/src/Models/Contracts/TableInterface.php +++ b/src/Models/Contracts/TableInterface.php @@ -13,6 +13,9 @@ * @property-read string name * @property-read string comment * @property-read Collection|ColumnInterface[] columns + * @property-read Collection|ColumnInterface[] indexes + * @property-read Collection|ColumnInterface[] referencing + * @property-read Collection|ColumnInterface[] referenced * */ interface TableInterface diff --git a/src/Models/Repositories/MysqlManageView.php b/src/Models/Repositories/MysqlManageView.php index d1a96eb..90e1c56 100644 --- a/src/Models/Repositories/MysqlManageView.php +++ b/src/Models/Repositories/MysqlManageView.php @@ -23,7 +23,8 @@ class MysqlManageView implements ManageViewInterface */ public function __construct() { - $this->sql = File::get(__DIR__ . '/../../sql/mysql_create_view.sql'); + $sql = File::get(__DIR__ . '/../../sql/mysql_create_view.sql'); + $this->sql = str_replace(':DATABASE_NAME', DB::getDatabaseName(), $sql); } /** diff --git a/src/sql/mysql_create_view.sql b/src/sql/mysql_create_view.sql index 582d4f4..b53d7fe 100644 --- a/src/sql/mysql_create_view.sql +++ b/src/sql/mysql_create_view.sql @@ -11,4 +11,4 @@ FROM information_schema.key_column_usage usg ON usg.table_schema = cst.table_schema AND usg.constraint_name = cst.constraint_name WHERE cst.constraint_type = 'FOREIGN KEY' - and usg.table_schema = 'bizocean_portal' \ No newline at end of file + and usg.table_schema = ':DATABASE_NAME' \ No newline at end of file