Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Illuminate/Database/Schema/Grammars/PostgresGrammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function compileTables()
{
return 'select c.relname as name, n.nspname as schema, pg_total_relation_size(c.oid) as size, '
."obj_description(c.oid, 'pg_class') as comment from pg_class c, pg_namespace n "
."where c.relkind = 'r' and n.oid = c.relnamespace "
."where c.relkind in ('r', 'p') and n.oid = c.relnamespace and n.nspname not in ('pg_catalog', 'information_schema')"
.'order by c.relname';
}

Expand All @@ -98,7 +98,7 @@ public function compileTables()
*/
public function compileViews()
{
return 'select viewname as name, schemaname as schema, definition from pg_views order by viewname';
return "select viewname as name, schemaname as schema, definition from pg_views where schemaname not in ('pg_catalog', 'information_schema') order by viewname";
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Schema/SQLiteBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function dropDatabaseIfExists($name)
*/
public function getTables()
{
$withSize = $this->connection->scalar($this->grammar->compileDbstatExists());
$withSize = rescue(fn () => $this->connection->scalar($this->grammar->compileDbstatExists()), false, false);

return $this->connection->getPostProcessor()->processTables(
$this->connection->selectFromWriteConnection($this->grammar->compileTables($withSize))
Expand Down
23 changes: 23 additions & 0 deletions tests/Integration/Database/Postgres/PostgresSchemaBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,29 @@ public function testGetViews()
}));
}

public function testDropPartitionedTables()
{
DB::statement('create table groups (id bigserial, tenant_id bigint, name varchar, primary key (id, tenant_id)) partition by hash (tenant_id)');
DB::statement('create table groups_1 partition of groups for values with (modulus 2, remainder 0)');
DB::statement('create table groups_2 partition of groups for values with (modulus 2, remainder 1)');

$tables = array_column(Schema::getTables(), 'name');

$this->assertContains('groups', $tables);
$this->assertContains('groups_1', $tables);
$this->assertContains('groups_2', $tables);

Schema::dropAllTables();

$this->artisan('migrate:install');

$tables = array_column(Schema::getTables(), 'name');

$this->assertNotContains('groups', $tables);
$this->assertNotContains('groups_1', $tables);
$this->assertNotContains('groups_2', $tables);
}

protected function hasView($schema, $table)
{
return DB::table('information_schema.views')
Expand Down