SQLiteBuilder.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace Illuminate\Database\Schema;
  3. class SQLiteBuilder extends Builder
  4. {
  5. /**
  6. * Drop all tables from the database.
  7. *
  8. * @return void
  9. */
  10. public function dropAllTables()
  11. {
  12. if ($this->connection->getDatabaseName() !== ':memory:') {
  13. return $this->refreshDatabaseFile();
  14. }
  15. $this->connection->select($this->grammar->compileEnableWriteableSchema());
  16. $this->connection->select($this->grammar->compileDropAllTables());
  17. $this->connection->select($this->grammar->compileDisableWriteableSchema());
  18. $this->connection->select($this->grammar->compileRebuild());
  19. }
  20. /**
  21. * Drop all views from the database.
  22. *
  23. * @return void
  24. */
  25. public function dropAllViews()
  26. {
  27. $this->connection->select($this->grammar->compileEnableWriteableSchema());
  28. $this->connection->select($this->grammar->compileDropAllViews());
  29. $this->connection->select($this->grammar->compileDisableWriteableSchema());
  30. $this->connection->select($this->grammar->compileRebuild());
  31. }
  32. /**
  33. * Empty the database file.
  34. *
  35. * @return void
  36. */
  37. public function refreshDatabaseFile()
  38. {
  39. file_put_contents($this->connection->getDatabaseName(), '');
  40. }
  41. }