In a code review, I spotted someone doing $this->connection->executeStatement() in an up() method. They claim "it works".
My suspicion is that this is just by coincidence, because of the acutal changes made in this particular case, but not generally safe.
I would assume that addSql batches the statements for execution, for dumping to a file or skipping it in a --dry-run – and that would not be possible with direct executeStatement().
The documentation does not address this and I would like to clarify it.
- May I use direct
executeStatement() or executeQuery() in up(), down(), postUp() or postDown()?
- May/shall I use
addSql() in postUp() or postDown()?
- Are
postUp() / postDown() only called when the migrations has actually been executed, i. e. not in a dry-run?
- What should I be aware of when mixing
addSql and other statements?
In a code review, I spotted someone doing
$this->connection->executeStatement()in anup()method. They claim "it works".My suspicion is that this is just by coincidence, because of the acutal changes made in this particular case, but not generally safe.
I would assume that
addSqlbatches the statements for execution, for dumping to a file or skipping it in a--dry-run– and that would not be possible with directexecuteStatement().The documentation does not address this and I would like to clarify it.
executeStatement()orexecuteQuery()inup(),down(),postUp()orpostDown()?addSql()inpostUp()orpostDown()?postUp()/postDown()only called when the migrations has actually been executed, i. e. not in a dry-run?addSqland other statements?