You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.1 KiB

  1. <?php
  2. /*
  3. * SPDX-FileCopyrightText: 2010 Jaussoin Timothée
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. namespace Movim;
  7. use Illuminate\Database\Capsule\Manager as Capsule;
  8. use Phinx\Migration\AbstractMigration;
  9. use Movim\Bootstrap;
  10. class Migration extends AbstractMigration
  11. {
  12. public $capsule;
  13. public $schema;
  14. public function init()
  15. {
  16. if (!defined('DOCUMENT_ROOT')) {
  17. $bootstrap = new Bootstrap;
  18. $bootstrap->boot(true);
  19. }
  20. $this->schema = Capsule::schema();
  21. }
  22. public function enableForeignKeyCheck()
  23. {
  24. switch ($this->schema->getConnection()->getDriverName()) {
  25. case 'mysql':
  26. $this->schema->getConnection()->unprepared('SET foreign_key_checks = 1');
  27. break;
  28. }
  29. }
  30. public function disableForeignKeyCheck()
  31. {
  32. switch ($this->schema->getConnection()->getDriverName()) {
  33. case 'mysql':
  34. $this->schema->getConnection()->unprepared('SET foreign_key_checks = 0');
  35. break;
  36. }
  37. }
  38. }