Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions generator/default.properties
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ propel.sql.mapper.to = *.sql
propel.migration.editor =
propel.migration.table = propel_migration
propel.migration.caseInsensitive = true
propel.migration.abortOnError = false

# -------------------------------------------------------------------
#
Expand Down
10 changes: 10 additions & 0 deletions generator/lib/task/BasePropelMigrationTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@ public function getOutputDirectory()
return $this->outputDirectory;
}

/**
* Decides whether to abort the migration on error or not
*
* @return bool
*/
protected function abortMigrationOnError()
{
return (bool) $this->getGeneratorConfig()->getBuildProperty('migrationAbortOnError');
}

/**
* Gets the GeneratorConfig object for this task or creates it on-demand.
*
Expand Down
7 changes: 6 additions & 1 deletion generator/lib/task/PropelMigrationTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@ public function main()
$stmt->execute();
$res++;
} catch (PDOException $e) {
$this->log(sprintf('Failed to execute SQL "%s"', $statement), Project::MSG_ERR);
if (true === $this->abortMigrationOnError()) {
$this->log(sprintf('Failed to execute SQL "%s". Aborting migration.', $statement), Project::MSG_ERR);
return false;
} else {
$this->log(sprintf('Failed to execute SQL "%s"', $statement), Project::MSG_ERR);
}
// continue
}
}
Expand Down