Просмотр файла app/Migrations/Migration.php

Размер файла: 785B
  1. <?php
  2.  
  3. declare(strict_types=1);
  4.  
  5. namespace App\Migrations;
  6.  
  7. use Illuminate\Database\Capsule\Manager as DB;
  8. use Illuminate\Database\Schema\Builder;
  9. use PDO;
  10. use Phinx\Migration\AbstractMigration;
  11.  
  12. class Migration extends AbstractMigration
  13. {
  14. /** @var DB $db */
  15. public $db;
  16.  
  17. /** @var Builder $capsule */
  18. public $schema;
  19.  
  20. public function init(): void
  21. {
  22. $this->db = new DB();
  23. $this->db->addConnection(array_merge(
  24. config('database.connections.' . config('database.default')),
  25. [
  26. 'options' => [
  27. PDO::ATTR_PERSISTENT => true
  28. ],
  29. ]
  30. ));
  31.  
  32. $this->db->setAsGlobal();
  33. $this->db->bootEloquent();
  34. $this->schema = $this->db::schema();
  35. }
  36. }