davedevelopment / phpmig

Simple migrations system for php
Other
569 stars 92 forks source link

Running migrations via API #62

Closed clphillips closed 9 years ago

clphillips commented 9 years ago

Wondering if this is the proper way to invoke migrations via the API as opposed to the CLI? Also, would this run all migrations up to the latest version, or does Migrator::up() have to be invoked once per version?

<?php
$container = include "path/to/phpmig.php";

use Phpmig\Migration;
use Symfony\Component\Console\Output;

$latest_version = "20141027000000";
$migration = new Migration($latest_version);
$output = new BufferedOutput();
$container['phpmig.migrator'] = new Migrator($container['phpmig.adapter'], $container, $output);
$container['phpmig.migrator']->up($migration);

var_dump($output->fetch());
davedevelopment commented 9 years ago

To be honest, I have no idea! It's a long time since I looked at the inner workings and the code is quite tightly coupled to the command line application.

clphillips commented 9 years ago

No worries. I'll give it a go and figure it out.

clphillips commented 9 years ago

Now in 3d729d0.