Inheritance: extends Migration, implements LazyRecord\Migration\Migratable
 public function testRemoveColumn()
 {
     $schema = new AuthorSchema();
     $schema->column('cellphone')->varchar(30);
     $this->buildSchemaTables([$schema], true);
     AutomaticMigration::options($options = new OptionCollection());
     $migrate = new AutomaticMigration($this->conn, $this->queryDriver, $this->logger, OptionResult::create($options, []));
     $migrate->upgrade([$schema]);
 }
 public function options($opts)
 {
     parent::options($opts);
     AutomaticMigration::options($opts);
 }
Esempio n. 3
0
 public function runUpgradeAutomatically(OptionResult $options = NULL)
 {
     foreach ($this->dataSourceIds as $dsId) {
         $driver = $this->connectionManager->getQueryDriver($dsId);
         $connection = $this->connectionManager->getConnection($dsId);
         $this->logger->info("Performing automatic upgrade over data source: {$dsId}");
         $script = new AutomaticMigration($driver, $connection, $options);
         try {
             $this->logger->info('Begining transaction...');
             $connection->beginTransaction();
             $script->upgrade();
             $this->logger->info('Committing...');
             $connection->commit();
         } catch (Exception $e) {
             $this->logger->error('Exception was thrown: ' . $e->getMessage());
             $this->logger->warn('Rolling back ...');
             $connection->rollback();
             $this->logger->warn('Recovered, escaping...');
             break;
         }
     }
 }
Esempio n. 4
0
 public function runUpgradeAutomatically(Connection $conn, BaseDriver $driver, array $schemas, OptionResult $options = null)
 {
     $script = new AutomaticMigration($conn, $driver, $this->logger, $options);
     try {
         $this->logger->info('Begining transaction...');
         $conn->beginTransaction();
         // where to find the schema?
         $script->upgrade($schemas);
         $this->logger->info('Committing...');
         $conn->commit();
     } catch (Exception $e) {
         $this->logger->error('Exception was thrown: ' . $e->getMessage());
         $this->logger->warn('Rolling back ...');
         $conn->rollback();
         $this->logger->warn('Recovered, escaping...');
         throw $e;
     }
 }