|
@@ -534,6 +534,42 @@ class MigrationsBase extends AbstractMigration implements ContainerAwareInterfac
|
|
|
$this->connection->commit();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Verifica si la migracion ya se incorporo.
|
|
|
+ * @param string $obj Contiene el objeto this.
|
|
|
+ * @return bool Retorna TRUE si ya se realizo la migracion.
|
|
|
+ */
|
|
|
+ protected function verifyMigrationsVersion($obj)
|
|
|
+ {
|
|
|
+ $existe = false;
|
|
|
+ try {
|
|
|
+ $arr = explode("\\", get_class($obj));
|
|
|
+ $nroVersion = str_ireplace("version", "", $arr[count($arr) - 1]);
|
|
|
+ $base = $this->getDataBaseName();
|
|
|
+ $sql =
|
|
|
+ "SELECT ifnull(version, '') as nombre " .
|
|
|
+ "FROM migration_versions " .
|
|
|
+ "WHERE " .
|
|
|
+ $base . ".migration_versions.version = '" . $nroVersion . "';";
|
|
|
+ $stmt = $this->connection->prepare($sql);
|
|
|
+ $stmt->execute();
|
|
|
+ $resp = $stmt->fetchAll();
|
|
|
+ foreach ($resp as $key => $value) {
|
|
|
+ if (strtolower($value["nombre"]) === strtolower($nroVersion)) {
|
|
|
+ $existe = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $existe;
|
|
|
+ $stmt = $this->connection->prepare("DELETE FROM migration_versions WHERE migration_versions.version = '" .
|
|
|
+ str_ireplace("version", "", $arr[count($arr) - 1]) . "'");
|
|
|
+ $stmt->execute();
|
|
|
+ $this->connection->commit();
|
|
|
+ } catch (\Throwable $e) {
|
|
|
+ return $existe;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* Funcion que muestra por pantalla el resultado de la ejecucion y de los errores.
|
|
@@ -644,7 +680,6 @@ class MigrationsBase extends AbstractMigration implements ContainerAwareInterfac
|
|
|
" TABLE_NAME = '" . $table . "' " .
|
|
|
"LIMIT 1;";
|
|
|
$stmt = $this->connection->prepare($sql);
|
|
|
- var_dump($sql);
|
|
|
$stmt->execute();
|
|
|
$resp = $stmt->fetchAll();
|
|
|
foreach ($resp as $key => $value) {
|