diff --git a/src/Illuminate/Database/Query/Processors/PostgresProcessor.php b/src/Illuminate/Database/Query/Processors/PostgresProcessor.php index d35ee2dc2c6c..ddfbfe722da2 100755 --- a/src/Illuminate/Database/Query/Processors/PostgresProcessor.php +++ b/src/Illuminate/Database/Query/Processors/PostgresProcessor.php @@ -45,54 +45,6 @@ public function processColumnListing($results) }, $results); } - /** - * Process the results of a types query. - * - * @param array $results - * @return array - */ - public function processTypes($results) - { - return array_map(function ($result) { - $result = (object) $result; - - return [ - 'name' => $result->name, - 'schema' => $result->schema, - 'implicit' => (bool) $result->implicit, - 'type' => match (strtolower($result->type)) { - 'b' => 'base', - 'c' => 'composite', - 'd' => 'domain', - 'e' => 'enum', - 'p' => 'pseudo', - 'r' => 'range', - 'm' => 'multirange', - default => null, - }, - 'category' => match (strtolower($result->category)) { - 'a' => 'array', - 'b' => 'boolean', - 'c' => 'composite', - 'd' => 'date_time', - 'e' => 'enum', - 'g' => 'geometric', - 'i' => 'network_address', - 'n' => 'numeric', - 'p' => 'pseudo', - 'r' => 'range', - 's' => 'string', - 't' => 'timespan', - 'u' => 'user_defined', - 'v' => 'bit_string', - 'x' => 'unknown', - 'z' => 'internal_use', - default => null, - }, - ]; - }, $results); - } - /** * Process the results of a columns query. * diff --git a/src/Illuminate/Database/Query/Processors/Processor.php b/src/Illuminate/Database/Query/Processors/Processor.php index 97a994ebc221..87a15c6d7a1d 100755 --- a/src/Illuminate/Database/Query/Processors/Processor.php +++ b/src/Illuminate/Database/Query/Processors/Processor.php @@ -77,17 +77,6 @@ public function processViews($results) }, $results); } - /** - * Process the results of a types query. - * - * @param array $results - * @return array - */ - public function processTypes($results) - { - return $results; - } - /** * Process the results of a columns query. * diff --git a/src/Illuminate/Database/Schema/Builder.php b/src/Illuminate/Database/Schema/Builder.php index c4b3da940265..efcad17fced3 100755 --- a/src/Illuminate/Database/Schema/Builder.php +++ b/src/Illuminate/Database/Schema/Builder.php @@ -211,16 +211,6 @@ public function getViews() ); } - /** - * Get the user-defined types that belong to the database. - * - * @return array - */ - public function getTypes() - { - throw new LogicException('This database driver does not support user-defined types.'); - } - /** * Get all of the table names for the database. * diff --git a/src/Illuminate/Database/Schema/Grammars/PostgresGrammar.php b/src/Illuminate/Database/Schema/Grammars/PostgresGrammar.php index 4d5fb7ba1312..094d49605d19 100755 --- a/src/Illuminate/Database/Schema/Grammars/PostgresGrammar.php +++ b/src/Illuminate/Database/Schema/Grammars/PostgresGrammar.php @@ -101,23 +101,6 @@ public function compileViews() return "select viewname as name, schemaname as schema, definition from pg_views where schemaname not in ('pg_catalog', 'information_schema') order by viewname"; } - /** - * Compile the query to determine the user-defined types. - * - * @return string - */ - public function compileTypes() - { - return 'select t.typname as name, n.nspname as schema, t.typtype as type, t.typcategory as category, ' - ."((t.typinput = 'array_in'::regproc and t.typoutput = 'array_out'::regproc) or t.typtype = 'm') as implicit " - .'from pg_type t join pg_namespace n on n.oid = t.typnamespace ' - .'left join pg_class c on c.oid = t.typrelid ' - .'left join pg_type el on el.oid = t.typelem ' - .'left join pg_class ce on ce.oid = el.typrelid ' - ."where ((t.typrelid = 0 and (ce.relkind = 'c' or ce.relkind is null)) or c.relkind = 'c') " - ."and n.nspname not in ('pg_catalog', 'information_schema')"; - } - /** * Compile the SQL needed to retrieve all table names. * @@ -520,22 +503,9 @@ public function compileDropAllTypes($types) return 'drop type '.implode(',', $this->escapeNames($types)).' cascade'; } - /** - * Compile the SQL needed to drop all domains. - * - * @param array $domains - * @return string - */ - public function compileDropAllDomains($domains) - { - return 'drop domain '.implode(',', $this->escapeNames($domains)).' cascade'; - } - /** * Compile the SQL needed to retrieve all type names. * - * @deprecated Will be removed in a future Laravel version. - * * @return string */ public function compileGetAllTypes() diff --git a/src/Illuminate/Database/Schema/PostgresBuilder.php b/src/Illuminate/Database/Schema/PostgresBuilder.php index 5b62187b45f0..4990cb445d98 100755 --- a/src/Illuminate/Database/Schema/PostgresBuilder.php +++ b/src/Illuminate/Database/Schema/PostgresBuilder.php @@ -53,18 +53,6 @@ public function hasTable($table) )) > 0; } - /** - * Get the user-defined types that belong to the database. - * - * @return array - */ - public function getTypes() - { - return $this->connection->getPostProcessor()->processTypes( - $this->connection->selectFromWriteConnection($this->grammar->compileTypes()) - ); - } - /** * Get all of the table names for the database. * @@ -163,8 +151,6 @@ public function dropAllViews() /** * Get all of the type names for the database. * - * @deprecated Will be removed in a future Laravel version. - * * @return array */ public function getAllTypes() @@ -182,27 +168,20 @@ public function getAllTypes() public function dropAllTypes() { $types = []; - $domains = []; - $schemas = $this->grammar->escapeNames($this->getSchemas()); + foreach ($this->getAllTypes() as $row) { + $row = (array) $row; - foreach ($this->getTypes() as $type) { - if (! $type['implicit'] && in_array($this->grammar->escapeNames([$type['schema']])[0], $schemas)) { - if ($type['type'] === 'domain') { - $domains[] = $type['schema'].'.'.$type['name']; - } else { - $types[] = $type['schema'].'.'.$type['name']; - } - } + $types[] = reset($row); } - if (! empty($types)) { - $this->connection->statement($this->grammar->compileDropAllTypes($types)); + if (empty($types)) { + return; } - if (! empty($domains)) { - $this->connection->statement($this->grammar->compileDropAllDomains($domains)); - } + $this->connection->statement( + $this->grammar->compileDropAllTypes($types) + ); } /** diff --git a/src/Illuminate/Support/Facades/Schema.php b/src/Illuminate/Support/Facades/Schema.php index 8d4d9b0c0dc8..934d27e6f508 100755 --- a/src/Illuminate/Support/Facades/Schema.php +++ b/src/Illuminate/Support/Facades/Schema.php @@ -14,7 +14,6 @@ * @method static bool hasView(string $view) * @method static array getTables() * @method static array getViews() - * @method static array getTypes() * @method static bool hasColumn(string $table, string $column) * @method static bool hasColumns(string $table, array $columns) * @method static void whenTableHasColumn(string $table, string $column, \Closure $callback) diff --git a/tests/Integration/Database/SchemaBuilderTest.php b/tests/Integration/Database/SchemaBuilderTest.php index 5d38e0e2a8a2..ea9a6d905031 100644 --- a/tests/Integration/Database/SchemaBuilderTest.php +++ b/tests/Integration/Database/SchemaBuilderTest.php @@ -182,33 +182,6 @@ public function testGetViews() $this->assertEmpty(array_diff(['foo', 'bar', 'baz'], array_column($views, 'name'))); } - public function testGetAndDropTypes() - { - if ($this->driver !== 'pgsql') { - $this->markTestSkipped('Test requires a PostgreSQL connection.'); - } - - DB::statement('create type pseudo_foo'); - DB::statement('create type comp_foo as (f1 int, f2 text)'); - DB::statement("create type enum_foo as enum ('new', 'open', 'closed')"); - DB::statement('create type range_foo as range (subtype = float8)'); - DB::statement('create domain domain_foo as text'); - - $types = Schema::getTypes(); - - $this->assertCount(11, $types); - $this->assertTrue(collect($types)->contains(fn ($type) => $type['name'] === 'pseudo_foo' && $type['type'] === 'pseudo' && ! $type['implicit'])); - $this->assertTrue(collect($types)->contains(fn ($type) => $type['name'] === 'comp_foo' && $type['type'] === 'composite' && ! $type['implicit'])); - $this->assertTrue(collect($types)->contains(fn ($type) => $type['name'] === 'enum_foo' && $type['type'] === 'enum' && ! $type['implicit'])); - $this->assertTrue(collect($types)->contains(fn ($type) => $type['name'] === 'range_foo' && $type['type'] === 'range' && ! $type['implicit'])); - $this->assertTrue(collect($types)->contains(fn ($type) => $type['name'] === 'domain_foo' && $type['type'] === 'domain' && ! $type['implicit'])); - - Schema::dropAllTypes(); - $types = Schema::getTypes(); - - $this->assertEmpty($types); - } - public function testGetIndexes() { Schema::create('foo', function (Blueprint $table) {