-
Notifications
You must be signed in to change notification settings - Fork 0
/
migrate
executable file
·60 lines (51 loc) · 2.77 KB
/
migrate
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
#!/usr/bin/env php
<?php
require_once __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . '/support/bootstrap.php';
use Doctrine\DBAL\DriverManager;
use Doctrine\Migrations\Configuration\Configuration;
use Doctrine\Migrations\Configuration\Connection\ExistingConnection;
use Doctrine\Migrations\Configuration\Migration\ExistingConfiguration;
use Doctrine\Migrations\DependencyFactory;
use Doctrine\Migrations\Metadata\Storage\TableMetadataStorageConfiguration;
use Doctrine\Migrations\Tools\Console\Command;
use Symfony\Component\Console\Application;
$config = config('plugin.wen-gg.webman-migrations.app');
$dbParams = $config['migrations_db'];
$connection = DriverManager::getConnection($dbParams);
$configuration = new Configuration($connection);
foreach ($config['migrations']['migrations_paths'] as $key => $value) {
$configuration->addMigrationsDirectory($key, $value);
}
$configuration->setAllOrNothing($config['migrations']['all_or_nothing']);
$configuration->setTransactional($config['migrations']['transactional']);
$configuration->setCheckDatabasePlatform($config['migrations']['check_database_platform']);
$configuration->setMigrationOrganization($config['migrations']['organize_migrations']);
$configuration->setConnectionName($config['migrations']['connection']);
$configuration->setEntityManagerName($config['migrations']['em']);
$storageConfiguration = new TableMetadataStorageConfiguration();
$storageConfiguration->setTableName($config['migrations']['table_storage']['table_name']);
$storageConfiguration->setVersionColumnName($config['migrations']['table_storage']['version_column_name']);
$storageConfiguration->setVersionColumnLength($config['migrations']['table_storage']['version_column_length']);
$storageConfiguration->setExecutedAtColumnName($config['migrations']['table_storage']['executed_at_column_name']);
$storageConfiguration->setExecutionTimeColumnName($config['migrations']['table_storage']['execution_time_column_name']);
$configuration->setMetadataStorageConfiguration($storageConfiguration);
$dependencyFactory = DependencyFactory::fromConnection(
new ExistingConfiguration($configuration),
new ExistingConnection($connection)
);
$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),
));
$cli->run();