2017 © Pedro PelΓ‘ez
 

library migration

Bitrix migration based on Doctrine migration component

image

rey/migration

Bitrix migration based on Doctrine migration component

  • Monday, October 10, 2016
  • by olegator8800
  • Repository
  • 4 Watchers
  • 2 Stars
  • 18 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

ReyMigration

Битрикс ΠΌΠΈΠ³Ρ€Π°Ρ†ΠΈΠΈ Π½Π° основС ΠΊΠΎΠΌΠΏΠΎΠ½Π΅Π½Ρ‚Π° Doctrine Migration, (*1)

Scrutinizer Code Quality Join the chat at https://gitter.im/Olegator8800/ReyMigration, (*2)

Установка

Composer:, (*3)

$ php composer.phar require rey/migration dev-master

ИспользованиС

Π‘ΠΎΠ·Π΄Π°Ρ‚ΡŒ Ρ„Π°ΠΉΠ» Π½.ΠΏ bin/console, (*4)

    #!/usr/bin/env php
    <?php

    use Symfony\Component\Console\Application;
    use Doctrine\Common\Annotations\AnnotationRegistry;
    use Rey\BitrixMigrations\Configuration;
    use Rey\BitrixMigrations\MigrationManager;

    //ΡƒΠΊΠ°Π·Π°Ρ‚ΡŒ ΠΏΡƒΡ‚ΡŒ Π΄ΠΎ ΠΏΡ€ΠΎΠ΅ΠΊΡ‚Π°
    $_SERVER['DOCUMENT_ROOT'] = __DIR__.'/../htdocs/';

    $loader = require __DIR__.'/../vendor/autoload.php';
    AnnotationRegistry::registerLoader(array($loader, 'loadClass'));

    $console = new Application('console');
    $config = new Configuration();

    $config->setConnectionParameters(
                            array(
                                'dbname' => 'mydatabase',
                                'user' =>  'root',
                                'password' => '',
                                'host' => '127.0.0.1',
                                'driver' => 'pdo_mysql',
                            )
                        );

    $config->setMigrationsParameters(
                            array(
                                'migrations_directory' => __DIR__.'/../migration',
                            )
                        );

    $bitrixMigrationManager = new MigrationManager($console, $config);
    $bitrixMigrationManager->init();

    $console->run();

И Π·Π°ΠΏΡƒΡΡ‚ΠΈΡ‚ΡŒ ΠΈΠ· консоли, (*5)

$ php bin/console

Для Π³Π΅Π½Π΅Ρ€Π°Ρ†ΠΈΠΈ Π½ΠΎΠ²ΠΎΠΉ ΠΌΠΈΠ³Ρ€Π°Ρ†ΠΈΠΈ Π²Ρ‹ΠΏΠΎΠ»Π½ΠΈΡ‚ΡŒ ΠΊΠΎΠΌΠ°Π½Π΄Ρƒ:, (*6)

$ php bin/console bitrix:migrations:generate

Π‘ΡƒΠ΄Π΅Ρ‚ сгСнСрированная пустая миграция Π² Π΄ΠΈΡ€ΠΈΠΊΡ‚ΠΎΡ€ΠΈΠΈ %migrations_directory, (*7)

Класс ΠΌΠΈΠ³Ρ€Π°Ρ†ΠΈΠΈ ΠΏΠΎ ΡƒΠΌΠΎΠ»Ρ‡Π°Π½ΠΈΡŽ унаслСдован ΠΎΡ‚ Rey\BitrixMigrations\AbstractMigration (ΠΌΠΎΠΆΠ½ΠΎ ΠΏΠ΅Ρ€Π΅ΠΎΠΏΡ€Π΅Π΄Π΅Π»ΠΈΡ‚ΡŒ ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€ΠΎΠΌ %abstract_class Π² MigrationsParameters), (*8)

Для использования api битрикса достаточно Π²Ρ‹Π·Π²Π°Ρ‚ΡŒ ΠΌΠ΅Ρ‚ΠΎΠ΄ $this->enableBitrixAPI();, (*9)

    public function up(Schema $schema)
    {
        $this->enableBitrixAPI();
        ...

Для выполнСния ΠΎΠ΄ΠΈΠ½ΠΎΡ‡Π½ΠΎΠΉ ΠΌΠΈΠ³Ρ€Π°Ρ†ΠΈΠΈ Π²Ρ‹ΠΏΠΎΠ»Π½ΠΈΡ‚ΡŒ:, (*10)

$ php bin/console bitrix:migrations:execute %Π½ΠΎΠΌΠ΅Ρ€_ΠΌΠΈΠ³Ρ€Π°Ρ†ΠΈΠΈ% --up

Для ΠΎΡ‚ΠΊΠ°Ρ‚Π° Π²Ρ‹ΠΏΠΎΠ»Π½ΠΈΡ‚ΡŒ ΠΊΠΎΠΌΠ°Π½Ρƒ с ΠΊΠ»ΡŽΡ‡Π΅ΠΌ --down, (*11)

$ php bin/console bitrix:migrations:execute %Π½ΠΎΠΌΠ΅Ρ€_ΠΌΠΈΠ³Ρ€Π°Ρ†ΠΈΠΈ% --down

Для выполнСния всСх Π½Π΅Π½Π°ΠΊΠ°Ρ‡Π΅Π½Π½Ρ‹Ρ… ΠΌΠΈΠ³Ρ€Π°Ρ†ΠΉΠΈ Π²Ρ‹ΠΏΠΎΠ»Π½ΠΈΡ‚ΡŒ:, (*12)

$ php bin/console bitrix:migrations:migrate

Для просмотра статуса ΠΌΠΈΠ³Ρ€Π°Ρ†ΠΈΠΉ:, (*13)

$ php bin/console bitrix:migrations:status

Для Π΄Π΅Ρ‚Π°Π»ΡŒΠ½ΠΎΠΉ ΠΈΠ½Ρ„ΠΎΡ€ΠΌΠ°Ρ†ΠΈΠΈ ΠΏΠΎ ΠΊΠ°ΠΆΠ΄ΠΎΠΉ ΠΌΠΈΠ³Ρ€Π°Ρ†ΠΈΠΈ Π²Ρ‹ΠΏΠΎΠ»Π½ΠΈΡ‚ΡŒ с ΠΊΠ»ΡŽΡ‡ΠΎΠΌ --show-versions, (*14)

$ php bin/console bitrix:migrations:status --show-versions

MySql Lite Driver

ΠŸΡ€ΠΈ использованиС MySql для ускорСния Ρ€Π°Π±ΠΎΡ‚Ρ‹ ΠΌΠΎΠΆΠ½ΠΎ Π²ΠΎΡΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚ΡŒΡΡ "ΡƒΠΏΡ€ΠΎΡ‰Π΅Π½Π½Ρ‹ΠΌ" Π΄Ρ€Π°ΠΉΠ²Π΅Ρ€ΠΎΠΌ. Π—Π°ΠΌΠ΅Π½ΠΈΡ‚ΡŒ ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€ driver Π½Π° driverClass., (*15)

    $config->setConnectionParameters(
                            array(
                                ...
                                'driverClass' => new \Rey\BitrixMigrations\Driver\PDOMySql\LiteDriver(),
                            )
                        );

The Versions

10/10 2016

dev-master

9999999-dev https://github.com/Olegator8800/ReyMigration

Bitrix migration based on Doctrine migration component

  Sources   Download

MIT

The Requires

 

by Nikita Krasnoyartsev
by Oleg Filimoshin

migration bitrix