Skip to content

Commit 2772fa8

Browse files
authored
Merge pull request #19645 from themsaid/handleSqliteMemory
[5.5] Handle sqlite :memory: while deleting all tables
2 parents 0ca97fa + c3d3464 commit 2772fa8

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/Illuminate/Database/Schema/SQLiteBuilder.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,24 @@ class SQLiteBuilder extends Builder
1010
* @return void
1111
*/
1212
public function dropAllTables()
13+
{
14+
if ($this->connection->getDatabaseName() != ':memory:') {
15+
return $this->refreshDatabaseFile();
16+
}
17+
18+
$this->connection->select($this->grammar->compileEnableWriteableSchema());
19+
20+
$this->connection->select($this->grammar->compileDropAllTables());
21+
22+
$this->connection->select($this->grammar->compileDisableWriteableSchema());
23+
}
24+
25+
/**
26+
* Delete the database file & re-create it.
27+
*
28+
* @return void
29+
*/
30+
public function refreshDatabaseFile()
1331
{
1432
unlink($this->connection->getDatabaseName());
1533

0 commit comments

Comments
 (0)