public function testLoadedVersions() { $this->preMigrationEvent->setLoadedVersion('testBundle', 'v1_0'); $this->assertEquals(['testBundle' => 'v1_0'], $this->preMigrationEvent->getLoadedVersions()); $this->assertEquals('v1_0', $this->preMigrationEvent->getLoadedVersion('testBundle')); $this->assertNull($this->preMigrationEvent->getLoadedVersion('nonLoggedBundle')); }
/** * @param PreMigrationEvent $event */ public function onPreUp(PreMigrationEvent $event) { if ($event->isTableExist(CreateMigrationTableMigration::MIGRATION_TABLE)) { $data = $event->getData(sprintf('select * from %s where id in (select max(id) from %s group by bundle)', CreateMigrationTableMigration::MIGRATION_TABLE, CreateMigrationTableMigration::MIGRATION_TABLE)); foreach ($data as $val) { $event->setLoadedVersion($val['bundle'], $val['version']); } } else { $event->addMigration(new CreateMigrationTableMigration()); // load MigrationTable initial data for BAP and OroCRM bundles installed before migrations is introduced // @todo: this transient solution can be removed in a future // when we ensure RC1 and RC2 are updated for all clients if ($event->isTableExist('oro_installer_bundle_version')) { $oroTableDataConfig = $this->kernel->locateResource('@OroMigrationBundle/EventListener/MigrationTableData/Oro.yml'); $bundleVersions = Yaml::parse(realpath($oroTableDataConfig)); $oroCrmTableDataConfig = $this->kernel->locateResource('@OroMigrationBundle/EventListener/MigrationTableData/OroCRM.yml'); if ($event->isTableExist('orocrm_account')) { $bundleVersions = array_merge($bundleVersions, Yaml::parse(realpath($oroCrmTableDataConfig))); } foreach ($bundleVersions as $bundleName => $version) { $event->setLoadedVersion($bundleName, $version); } $event->addMigration(new UpdateBundleVersionMigration($bundleVersions)); $event->addMigration(new UpdateEntityConfigMigration()); } } }
/** * @param PreMigrationEvent $event */ public function onPreUp(PreMigrationEvent $event) { if ($event->isTableExist(CreateMigrationTableMigration::MIGRATION_TABLE)) { $data = $event->getData(sprintf('select * from %s where id in (select max(id) from %s group by bundle)', CreateMigrationTableMigration::MIGRATION_TABLE, CreateMigrationTableMigration::MIGRATION_TABLE)); foreach ($data as $val) { $event->setLoadedVersion($val['bundle'], $val['version']); } } else { $event->addMigration(new CreateMigrationTableMigration()); } }