Exemplo n.º 1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln('Create a migration file');
     try {
         $helper = $this->getHelper('question');
         $question = new Question('Please enter migration key : ', '');
         $key = $helper->ask($input, $output, $question);
         if ($key == "") {
             throw new \Exception("you must specify migration key");
         }
         $question = new Question('Please enter a description : ', '');
         $description = $helper->ask($input, $output, $question);
         if ($description == "") {
             throw new \Exception("you must specify an description");
         }
         // test if key exist
         $migrator = new Migrator();
         if ($migrator->testExist($key)) {
             throw new \Exception("Key was already created");
         }
         $ret = $migrator->create($key, $description);
         $keyslug = "";
         if ($ret) {
             $keyslug = $migrator->getSlugKeyName($key);
         }
         $message = $ret == true ? "Migration {$keyslug} created" : "Error during creating";
         $output->writeln($message);
     } catch (\Exception $e) {
         $output->writeln('Error : ' . $e->getMessage());
     }
     $output->writeln('finished');
 }
Exemplo n.º 2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln('Execute all migration files');
     try {
         $migrator = new Migrator();
         $migrator->migrateAll();
     } catch (\Exception $e) {
         $output->writeln('Error : ' . $e->getMessage());
     }
     $output->writeln('finished');
 }
Exemplo n.º 3
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln('Rollback migration');
     try {
         $key = $input->getArgument('migration_key');
         if ($key == "") {
             throw new \Exception("You must specify a key");
         }
         $migrator = new Migrator();
         $migrator->rollback($key);
     } catch (\Exception $e) {
         $output->writeln('Error : ' . $e->getMessage());
     }
     $output->writeln('finished');
 }
Exemplo n.º 4
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln('Give list of all migrations');
     try {
         $migrator = new Migrator();
         $keys = $migrator->MigrationList();
         foreach ($keys as $key) {
             $date = Carbon::createFromFormat("YmdHis", $key->getCreationDate())->format("d/m/Y H:i:s");
             $texte = $key->getUniqueTag() . " : " . $key->getDescription() . " -> " . $date;
             $output->writeln($texte);
         }
     } catch (\Exception $e) {
         $output->writeln('Error : ' . $e->getMessage());
     }
     $output->writeln('finished');
 }