Browse Source

Se agrego el numero de version en la muestra de la ejecucion

gabriel 8 years ago
parent
commit
d718baa949
2 changed files with 28 additions and 11 deletions
  1. 22 11
      Migrations/MigrationsBase.php
  2. 6 0
      README.md

+ 22 - 11
Migrations/MigrationsBase.php

@@ -455,21 +455,32 @@ class MigrationsBase extends AbstractMigration implements ContainerAwareInterfac
 	 */
 	protected function executeYaml($dir, $file)
 	{
-		$this->connection->beginTransaction();
 		try {
-			$this->interpretYaml($dir, $file);
-			if (count($this->getErrorLineExecution()) > 0
-			) {
-				//se produjeron errores
-				$this->connection->rollBack();
-				echo "\nSe produjeron errores de sql.\n";
+			$tmp = explode("\\", get_class($this));
+			if ($tmp != null && count($tmp) > 0) {
+				$version = $tmp[count($tmp) - 1];
 			} else {
-				$this->connection->commit();
-				echo "\nMigracion correcta.\n";
+				$version = "";
+			}
+			echo "\n\tInicio del procesamiento de la migracion: " . $version;
+			$this->connection->beginTransaction();
+			try {
+				$this->interpretYaml($dir, $file);
+				if (count($this->getErrorLineExecution()) > 0
+				) {
+					//se produjeron errores
+					$this->connection->rollBack();
+					echo "\n\t\tSe produjeron errores de sql.\n";
+				} else {
+					$this->connection->commit();
+					echo "\n\t\tMigracion correcta.\n";
+				}
+			} catch (\Throwable $ex) {
+				$this->connection->rollBack();
+				echo "\n\t\tSe produjeron errores por una excepcion. " . $ex->getMessage() . "\n";
 			}
 		} catch (\Throwable $e) {
-			$this->connection->rollBack();
-			echo "\nSe produjeron errores por una excepcion. " . $e->getMessage() . "\n";
+			echo "\n\t\tSe produjeron errores genericos. " . $e->getMessage() . "\n";
 		}
 	}
 

+ 6 - 0
README.md

@@ -60,9 +60,15 @@ Ademas se pueden utilizar las siguientes funciones:
             Se toma como base el directorio app/DoctrineMigrations/ 
 ```
 
+**Ejecucion**
+Una version
 ```bash
 $ bin/console doctrine:migrations:execute <numberOfMigrations>
 ```
+Todas las versiones
+```bash
+$ bin/console doctrine:migrations:migrate
+```
 
 ## Ejemplo YAML
 **Palabras claves de importacion**: son palabras que importan los datos desde otros archivos que pueden estar en otros directorios. Siempre se toma como base `app/DoctrineMigrations`.