dev-master
9999999-dev https://github.com/Olegator8800/ReyMigrationBitrix migration based on Doctrine migration component
MIT
The Requires
- php >=5.3.0
- doctrine/migrations 1.0.*@dev
by Nikita Krasnoyartsev
by Oleg Filimoshin
migration bitrix
Bitrix migration based on Doctrine migration component
ΠΠΈΡΡΠΈΠΊΡ ΠΌΠΈΠ³ΡΠ°ΡΠΈΠΈ Π½Π° ΠΎΡΠ½ΠΎΠ²Π΅ ΠΊΠΎΠΌΠΏΠΎΠ½Π΅Π½ΡΠ° Doctrine Migration, (*1)
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 Π΄Π»Ρ ΡΡΠΊΠΎΡΠ΅Π½ΠΈΡ ΡΠ°Π±ΠΎΡΡ ΠΌΠΎΠΆΠ½ΠΎ Π²ΠΎΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡΡΡ "ΡΠΏΡΠΎΡΠ΅Π½Π½ΡΠΌ" Π΄ΡΠ°ΠΉΠ²Π΅ΡΠΎΠΌ. ΠΠ°ΠΌΠ΅Π½ΠΈΡΡ ΠΏΠ°ΡΠ°ΠΌΠ΅ΡΡ driver Π½Π° driverClass., (*15)
$config->setConnectionParameters( array( ... 'driverClass' => new \Rey\BitrixMigrations\Driver\PDOMySql\LiteDriver(), ) );
Bitrix migration based on Doctrine migration component
MIT
migration bitrix