コード例 #1
0
ファイル: Schema.php プロジェクト: joseki/migration
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $schema = $this->schemaGenerator->createSchema($this->entities);
     if (file_exists($this->logFile)) {
         $fromSchema = unserialize(file_get_contents($this->logFile));
         $sqlStatements = $schema->getMigrateFromSql($fromSchema, $this->platform);
     } else {
         $sqlStatements = $schema->toSql($this->platform);
     }
     if (count($sqlStatements) > 0) {
         $output->writeln('Creating database schema...');
         $output->writeln(count($sqlStatements) . ' queries');
         if ($input->getOption('print')) {
             foreach ($sqlStatements as $query) {
                 $output->writeln($query . ';');
                 $output->writeln('');
             }
         } else {
             file_put_contents($this->logFile, serialize($schema));
             $output->writeln($this->logFile . ' updated');
             $name = $input->getArgument('name');
             $migration = $this->manager->createFromLeanMapper($sqlStatements, $name);
             $output->writeln($migration . ' created');
         }
     } else {
         $output->writeln('Nothing to change...');
     }
 }
コード例 #2
0
ファイル: Create.php プロジェクト: joseki/migration
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $name = $input->getArgument('name');
     // run the migrations
     $start = microtime(true);
     $this->manager->create($name);
     $end = microtime(true);
     $output->writeln('');
     $output->writeln('<comment>New migration created. Total time: ' . sprintf('%.4fs', $end - $start) . '</comment>');
 }
コード例 #3
0
ファイル: Migrate.php プロジェクト: joseki/migration
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $date = $input->getOption('date');
     // run the migrations
     $start = microtime(true);
     try {
         if (null !== $date) {
             $this->manager->migrateToDateTime(new \DateTime($date));
         } else {
             $this->manager->migrate();
         }
     } catch (\Exception $e) {
         $output->writeln('<comment>Migration has been cancelled due to the following error:</comment>');
         $output->writeln('<comment>' . $e->getMessage() . '</comment>');
         return;
     }
     $end = microtime(true);
     $output->writeln('');
     $output->writeln('<comment>Migration completed. Total time: ' . sprintf('%.4fs', $end - $start) . '</comment>');
 }