Skip to content

Schema: schema caching and rebuilding across tests #125

Open

Description

@temp

Part of #102. Line numbers refer to branch chore/php-8.4-dependabot (#98). Verified = reproduced, suspected = from reading the code.

  • The static $executedStatements cache is keyed by SQL string and is append-only. If class B defines user with one more column than class A, the run fails with table user already exists (SqliteFileBasedSchemaStrategy.php:107-113, MysqlBasedSchemaStrategy.php:44-50, MysqlDamaBasedSchemaStrategy.php:47-53). Verified (SQLite file), suspected for MySQL.
  • The SQLite file DAMA strategy runs CREATE TABLE unconditionally (SqliteFileDamaBasedSchemaStrategy.php:44-46). If the file already has tables, every test fails with table already exists. This happens e.g. after a test with #[SkipDatabaseRollback] switched to the non-DAMA strategy, or after a run with DAMA disabled. Verified (emulated).
  • The SQLite file strategy unlinks the database file under an already open connection, so CREATE runs on the deleted inode (SqliteFileBasedSchemaStrategy.php:66-70). Verified.
  • SQLite memory runs CREATE TABLE unconditionally, so a second fixture on the same connection fails (SqliteMemoryBasedSchemaStrategy.php:22-27). Verified.
  • Nested database directories are not created, because mkdir() isn't recursive (SqliteFile*SchemaStrategy). Verified.

Possible approach: a schema-aware rebuild via DBAL's Comparator instead of the SQL-string cache, and a schema cache that survives between runs, keyed by a schema hash.

Activity

  1. added this to the 7.x milestone on Nov 3, 2026
  2. added
    bugSomething isn't working
    on Nov 3, 2026
  3. added a commit that references this issue on Nov 5, 2026
    cbcc680
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions