-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathm
77 lines (62 loc) · 2.47 KB
/
m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env php
<?php declare(strict_types=1);
require_once __DIR__ . '/vendor/autoload.php';
use App\Console\Kernel as ConsoleKernel;
use App\Infrastructure\Database\DatabaseServiceInterface;
use Doctrine\DBAL\DriverManager;
use Doctrine\Migrations\Configuration\EntityManager\ExistingEntityManager;
use Doctrine\Migrations\DependencyFactory;
use Doctrine\Migrations\Configuration\Migration\PhpFile;
use Doctrine\Migrations\Tools\Console\Command;
use Doctrine\ORM\EntityManagerInterface;
use Illuminate\Contracts\Container\BindingResolutionException;
use Symfony\Component\Console\Application;
use Illuminate\Contracts\Foundation\Application as LaravelApplication;
require_once 'vendor/autoload.php';
/** @var $app LaravelApplication */
$app = require_once __DIR__ . DIRECTORY_SEPARATOR . 'bootstrap/app.php';
try {
/** @var $kernel ConsoleKernel */
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
$kernel->bootstrap();
/** @var $databaseService DatabaseServiceInterface */
$databaseService = $app->make(DatabaseServiceInterface::class);
/** @var $em EntityManagerInterface */
$em = $app->make(EntityManagerInterface::class);
} catch (BindingResolutionException $exception) {
echo $exception->getMessage();
exit;
}
try {
$connection = DriverManager::getConnection($databaseService->getConnectionParameters());
} catch (\Doctrine\DBAL\Exception $exception) {
echo $exception->getMessage() . PHP_EOL;
exit(1);
}
// Or use one of the Doctrine\Migrations\Configuration\Configuration\* loaders
$config = new PhpFile('migrations-config.php');
$dependencyFactory = DependencyFactory::fromEntityManager(
$config,
new ExistingEntityManager($em)
);
$cli = new Application('Doctrine Migrations');
$cli->setCatchExceptions(true);
$cli->addCommands(array(
new Command\DumpSchemaCommand($dependencyFactory),
new Command\ExecuteCommand($dependencyFactory),
new Command\GenerateCommand($dependencyFactory),
new Command\LatestCommand($dependencyFactory),
new Command\ListCommand($dependencyFactory),
new Command\MigrateCommand($dependencyFactory),
new Command\RollupCommand($dependencyFactory),
new Command\StatusCommand($dependencyFactory),
new Command\SyncMetadataCommand($dependencyFactory),
new Command\VersionCommand($dependencyFactory),
new Command\DiffCommand($dependencyFactory)
));
try {
$cli->run();
} catch (Exception $exception) {
echo $exception->getMessage() . PHP_EOL;
exit(1);
}