feat(testing): implement template database cloning for MySQL#1
Draft
CodingAnarchy wants to merge 6 commits intomainfrom
Draft
feat(testing): implement template database cloning for MySQL#1CodingAnarchy wants to merge 6 commits intomainfrom
CodingAnarchy wants to merge 6 commits intomainfrom
Conversation
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>
c474591 to
24a8b38
Compare
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>
6e05988 to
4f7651d
Compare
- 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Testing CI - will be submitted upstream after validation