3
3
namespace Reliese \Meta \Postgres ;
4
4
5
5
use Illuminate \Support \Arr ;
6
+ use Illuminate \Support \Facades \Config ;
6
7
use Reliese \Meta \Blueprint ;
7
8
use Illuminate \Support \Fluent ;
8
9
use Illuminate \Database \Connection ;
@@ -33,6 +34,11 @@ class Schema implements \Reliese\Meta\Schema
33
34
*/
34
35
protected $ tables = [];
35
36
37
+ /**
38
+ * @var mixed|null
39
+ */
40
+ protected $ schema_database = null ;
41
+
36
42
/**
37
43
* Mapper constructor.
38
44
*
@@ -41,6 +47,10 @@ class Schema implements \Reliese\Meta\Schema
41
47
*/
42
48
public function __construct ($ schema , $ connection )
43
49
{
50
+ $ this ->schema_database = Config::get ("database.connections.pgsql.schema " );
51
+ if (!$ this ->schema_database ){
52
+ $ this ->schema_database = 'public ' ;
53
+ }
44
54
$ this ->schema = $ schema ;
45
55
$ this ->connection = $ connection ;
46
56
@@ -82,7 +92,7 @@ protected function load()
82
92
protected function fetchTables ()
83
93
{
84
94
$ rows = $ this ->arraify ($ this ->connection ->select (
85
- ' SELECT * FROM pg_tables where schemaname= \' public \''
95
+ " SELECT * FROM pg_tables where schemaname=' $ this -> schema_database ' "
86
96
));
87
97
$ names = array_column ($ rows , 'tablename ' );
88
98
@@ -96,7 +106,7 @@ protected function fillColumns(Blueprint $blueprint)
96
106
{
97
107
$ rows = $ this ->arraify ($ this ->connection ->select (
98
108
'SELECT * FROM information_schema.columns ' .
99
- ' WHERE table_schema= \' public \'' .
109
+ " WHERE table_schema=' $ this -> schema_database ' " .
100
110
'AND table_name= ' .$ this ->wrap ($ blueprint ->table ())
101
111
));
102
112
foreach ($ rows as $ column ) {
0 commit comments