Skip to content

Commit

Permalink
fix: Fix phpcs errors
Browse files Browse the repository at this point in the history
  • Loading branch information
owenconti committed May 2, 2020
1 parent 0594216 commit 6bd7864
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions src/Schemas/PostgresSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace OhSeeSoftware\LaravelSchemaList\Schemas;

use Illuminate\Database\ConnectionInterface;
use Illuminate\Support\Facades\DB;

class PostgresSchema implements SchemaContract
{
Expand All @@ -22,13 +21,31 @@ public function getTables(ConnectionInterface $connection): array
public function getColumns(ConnectionInterface $connection, string $table): array
{
$output = $connection->table('information_schema.columns', 'c')
->select(['c.column_name as Field', 'c.data_type as Type', 'c.is_nullable as Nullable', 'tc.constraint_type as Key', 'c.column_default as "Default Value"', 'c.ordinal_position'])
->join('information_schema.key_column_usage AS kcu', 'kcu.column_name', '=', 'c.column_name', 'full')
->leftJoin('information_schema.table_constraints AS tc', 'tc.constraint_name', '=', 'kcu.constraint_name')
->where('c.table_name', $table)
->orderBy('c.ordinal_position', 'asc')
->distinct()
->get();
->select([
'c.column_name as Field',
'c.data_type as Type',
'c.is_nullable as Nullable',
'tc.constraint_type as Key',
'c.column_default as "Default Value"',
'c.ordinal_position'
])
->join(
'information_schema.key_column_usage AS kcu',
'kcu.column_name',
'=',
'c.column_name',
'full'
)
->leftJoin(
'information_schema.table_constraints AS tc',
'tc.constraint_name',
'=',
'kcu.constraint_name'
)
->where('c.table_name', $table)
->orderBy('c.ordinal_position', 'asc')
->distinct()
->get();

return collect($output)->map(function ($value) {
unset($value->ordinal_position);
Expand Down

0 comments on commit 6bd7864

Please sign in to comment.