Skip to content

Instantly share code, notes, and snippets.

@janedbal
Last active January 24, 2025 09:38
Show Gist options
  • Select an option

  • Save janedbal/f4dea14a76e54ef6ea930234b1357d02 to your computer and use it in GitHub Desktop.

Select an option

Save janedbal/f4dea14a76e54ef6ea930234b1357d02 to your computer and use it in GitHub Desktop.

Revisions

  1. janedbal renamed this gist Jan 24, 2025. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions migrate.php → doctrine-two-phase-migrations-migrate.php
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,7 @@
    <?php

    // see https://github.com/shipmonk-rnd/doctrine-two-phase-migrations/issues/97

    // composer require nette/utils

    require __DIR__ . '/../vendor/autoload.php';
  2. janedbal created this gist Aug 12, 2024.
    27 changes: 27 additions & 0 deletions migrate.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    <?php

    // composer require nette/utils

    require __DIR__ . '/../vendor/autoload.php';

    /** @var SplFileInfo $file */
    foreach (\Nette\Utils\Finder::findFiles('*.php')->in(__DIR__ . '/../migrations') as $file) {
    $contents = \Nette\Utils\FileSystem::read($file->getPathname());
    $newContents = str_replace([
    'use Doctrine\Migrations\AbstractMigration;',
    'extends AbstractMigration',
    'public function up(Schema $schema): void',
    'public function down(Schema $schema): void',
    '$this->addSql',
    ], [
    'use ShipMonk\Doctrine\Migration\Migration;',
    'implements Migration',
    'public function before(\Doctrine\DBAL\Connection $connection): void',
    'public function after(\Doctrine\DBAL\Connection $connection): void',
    '$connection->executeQuery',
    ],
    $contents
    );

    \Nette\Utils\FileSystem::write($file->getPathname(), $newContents);
    }