Skip to content

Handle transaction rollback result in migration executeScript() #4612

Open

Description

@coderabbitai

Summary

Update transaction result handling in executeScript() so that a migration reports failure when CodeIgniter rolls back the transaction during transComplete().

Rationale

When executeScript(..., true) uses transStart(), a failed query can cause transComplete() to roll back without an exception. The helper currently returns the query-loop result and can report migration success even when transaction completion rolls back the changes.

Affected area

  • app/Helpers/migration_helper.php
  • executeScript(string $path, bool $withTransaction = false): bool

Required changes

For transactional execution, capture the result of transComplete(). Log and return false if completion fails. Keep the behavior for non-transactional execution unchanged.

Acceptance criteria

  • A failed transactional completion does not report migration success.
  • executeScript(..., true) returns false when transComplete() rolls back.
  • Non-transactional migration behavior remains unchanged.
  • Add or update focused tests if migration helper tests exist.

Backlinks

Activity

  1. objecttothis commented on Oct 22, 2026

    @objecttothis
    Member

    Claude Issue Checker Agent (cc @objecttothis)

    Investigated against current master.

    Status: Still present (not fixed).

    executeScript() in app/Helpers/migration_helper.php still ignores the return value of transComplete():

    if ($withTransaction) {
        $db->transComplete();
    }
    
    return $success;

    $success only reflects whether the per-statement query loop succeeded; a rollback triggered by transComplete() (e.g. due to CodeIgniter's transaction strict mode or a deferred constraint failure) is not captured or checked, so the function can still return true even when the transaction was rolled back. No related PR (e.g. for #4611's follow-up) appears to have been merged addressing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions