Skip to content

Conversation

@CodingAnarchy
Copy link
Owner

Testing CI - will be submitted upstream after validation

Add template database cloning optimization to avoid running migrations for
every test. When multiple tests use the same migrations, a template database
is created once and cloned for each test, significantly speeding up test runs.

Implementation details:
- Add migrations_hash() to compute SHA256 of migration checksums
- Add template_db_name() to generate template database names
- Extend TestContext with from_template field to track cloning
- Modify setup_test_db() to skip migrations when cloned from template
- MySQL: Use mysqldump/mysql for fast cloning with in-process fallback
- Add _sqlx_test_templates tracking table with GET_LOCK synchronization
- Add SQLX_TEST_NO_TEMPLATE env var to opt out of template cloning
- Add comprehensive tests for template functionality
- Add template tests to MySQL and MariaDB CI jobs

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@CodingAnarchy CodingAnarchy force-pushed the 12-19-feat_testing_implement_template_database_cloning_for_mysql branch from c474591 to 24a8b38 Compare December 19, 2025 20:31
CodingAnarchy and others added 2 commits December 19, 2025 15:45
Use CREATE DATABASE IF NOT EXISTS for idempotent template creation.
Check if migrations already exist before running them, allowing reuse
of template databases that exist but weren't registered in the tracking
table (e.g., from a previous CI run or interrupted process).
Use INSERT IGNORE when registering templates to handle race conditions.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…chema

Query _sqlx_migrations table directly to check if migrations exist.
This handles the case where the table exists with entries from a
previous run more reliably than checking information_schema.tables.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@CodingAnarchy CodingAnarchy force-pushed the 12-19-feat_testing_implement_template_database_cloning_for_mysql branch from 6e05988 to 4f7651d Compare December 19, 2025 21:06
CodingAnarchy and others added 3 commits December 19, 2025 16:16
- Check GET_LOCK returns 1 (success) before proceeding
- Add debug output to show migration count or error during template check
- This should help diagnose the race condition in CI

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
MariaDB returns NULL when GET_LOCK is called with -1 timeout.
Use 300 second timeout instead for cross-database compatibility.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
GitHub has deprecated the macOS-13 runner. Remove it from the
sqlx-cli workflow matrices.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants