forked from ProklUng/bitrix-migrations
-
Notifications
You must be signed in to change notification settings - Fork 0
/
migrator
53 lines (46 loc) · 1.86 KB
/
migrator
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
#!/usr/bin/env php
<?php
use Arrilot\BitrixMigrations\Commands\ArchiveCommand;
use Arrilot\BitrixMigrations\Commands\MakeCommand;
use Arrilot\BitrixMigrations\Commands\InstallCommand;
use Arrilot\BitrixMigrations\Commands\MigrateCommand;
use Arrilot\BitrixMigrations\Commands\RollbackCommand;
use Arrilot\BitrixMigrations\Commands\TemplatesCommand;
use Arrilot\BitrixMigrations\Commands\StatusCommand;
use Arrilot\BitrixMigrations\Constructors\IBlock;
use Arrilot\BitrixMigrations\Migrator;
use Arrilot\BitrixMigrations\Storages\BitrixDatabaseStorage;
use Arrilot\BitrixMigrations\TemplatesCollection;
use Symfony\Component\Console\Application;
define("NOT_CHECK_PERMISSIONS", true);
$_SERVER["DOCUMENT_ROOT"] = __DIR__;
$DOCUMENT_ROOT = $_SERVER["DOCUMENT_ROOT"];
require $_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php";
CModule::IncludeModule("iblock");
$config = [
'table' => 'migrations',
'dir' => './migrations',
// 'dir_archive' => 'archive', // not required. default = "archive"
'use_transaction' => true, // not required. default = false
'default_fields' => [
IBlock::class => [
'INDEX_ELEMENT' => 'N',
'INDEX_SECTION' => 'N',
'VERSION' => 2,
'SITE_ID' => 's1',
]
]
];
$database = new BitrixDatabaseStorage($config['table']);
$templates = new TemplatesCollection();
$templates->registerBasicTemplates();
$migrator = new Migrator($config, $templates, $database);
$app = new Application('Migrator');
$app->add(new MakeCommand($migrator));
$app->add(new InstallCommand($config['table'], $database));
$app->add(new MigrateCommand($migrator));
$app->add(new RollbackCommand($migrator));
$app->add(new TemplatesCommand($templates));
$app->add(new StatusCommand($migrator));
$app->add(new ArchiveCommand($migrator));
$app->run();