In 2026, SQL developers use Atlas to add regression tests for bug fixes by first writing a failing pgTAP test, proving the bug, then applying the fix, and finally confirming the test passes, ensuring the fix is locked in with a verifiable test suite using real SQL toolchain commands.
How does Atlas add a regression test for a SQL bug fix?
Atlas streamlines the process of adding a regression test for a SQL bug fix in 2026 by adhering to the red-first, then green discipline. It uses the `bash` tool to run `pgTAP` tests, ensuring the bug is reproducible before any code changes are applied.
Atlas facilitates the red-green testing workflow for SQL bug fixes. First, Atlas helps you reproduce the bug using its `bash` tool to execute a `pgTAP` test command, capturing the exact failing output. This step is crucial for SQL, as it confirms the `pgTAP` test correctly identifies the issue in the database state or query logic. Next, Atlas uses its `write` tool to create a new `pgTAP` test file, asserting on the observed wrong behavior. After confirming this new test fails, Atlas applies the necessary SQL fix using its `edit` tool, which can modify existing `Flyway migrations` or other SQL files. Finally, Atlas re-runs the same `bash` command to confirm the test now passes. The `bash` output, with its real exit code, provides unambiguous pass/fail states, which is vital for verifying SQL changes where subtle data interactions can be hard to track. Atlas's ability to read `git` branches and status also helps manage the testing context throughout this process.
What SQL commands and files does Atlas use for regression testing?
Atlas interacts directly with your SQL toolchain, using `pgTAP` for testing and `Flyway migrations` for schema management, to add regression tests. In 2026, it leverages actual commands like `pg_prove` or `psql -f test.sql` to execute tests and confirm bug reproduction.
Atlas integrates direct with your existing SQL development environment. For testing, Atlas uses its `write` tool to create `pgTAP` test files, typically named like `tests/my_bug_test.sql` or `V1_1__bug_fix_test.sql` if integrated with `Flyway migrations`. To execute these tests, Atlas employs its `bash` tool to run commands such as `pg_prove tests/my_bug_test.sql` or `psql -d my_database -f tests/my_bug_test.sql`. The output and exit code from these commands are captured and analyzed by Atlas to determine test status. When applying fixes, SQL changes are often made within `Flyway migrations` files, for example, `V1_2__bug_fix.sql`. Atlas uses its `edit` tool to precisely modify existing SQL files or its `write` tool to create new migration scripts. After any modifications, Atlas can be instructed to run `sqlfluff format` via the `bash` tool, ensuring all SQL code adheres to your team's formatting standards. Atlas also reads `git` branches and diffs to understand the current state of the SQL codebase, providing context for its operations.
How does Atlas ensure safety and review for SQL bug fixes?
Atlas prioritizes safety and review for SQL bug fixes by presenting a unified diff for every file edit before writing, ensuring developers approve all changes. In 2026, this includes modifications to `Flyway migrations` or `pgTAP` test files, preventing unintended alterations.
Atlas incorporates several robust safety mechanisms to protect your SQL codebase. When Atlas proposes a change, such as modifying a `Flyway migrations` script or a `pgTAP` test file, it computes and surfaces a unified diff for every file edit. This allows developers to review and explicitly approve all proposed changes before they are written to disk, preventing unintended alterations to critical SQL logic or schema definitions. The `edit` tool, used for applying SQL fixes, requires an exact-enough `oldString` and refuses ambiguous multi-match replacements, ensuring precise and targeted modifications. Furthermore, every Atlas tool call is permission-gated against allow, ask, and deny rules, providing granular control over what actions Atlas can perform within your SQL repository. Atlas also drafts a plan in a read-only plan agent and asks for approval before switching to a build agent, offering a clear audit trail for all SQL changes. Its deep integration with `git` means Atlas reads branches, status, and diffs, and can stage and create commits on your behalf, streamlining the version control process. Atlas also snapshots file changes as `git` patches, so edits can be easily diffed and rolled back if necessary.
Step by step
- 01Reproduce the SQL bug: Use `atlas bash "pg_prove tests/failing_query.sql"` to run a `pgTAP` test that demonstrates the bug, capturing the exact failing command and output.
- 02Write the `pgTAP` regression test: Instruct Atlas to `atlas write tests/new_bug_regression.sql` to create a new `pgTAP` test file, asserting on the observed wrong behavior in your SQL database.
- 03Confirm the test fails: Execute `atlas bash "pg_prove tests/new_bug_regression.sql"` to run the newly written `pgTAP` test and confirm it fails, verifying it accurately reproduces the SQL bug.
- 04Apply the SQL fix: Use `atlas edit "ALTER TABLE users ADD COLUMN email VARCHAR(255);" "ALTER TABLE users ADD COLUMN email VARCHAR(255) NOT NULL;"` to apply the necessary SQL fix, potentially within a `Flyway migrations` file like `V1_3__add_email_not_null.sql`.
- 05Re-run and confirm pass: Re-execute `atlas bash "pg_prove tests/new_bug_regression.sql"` to confirm the `pgTAP` test now passes, then run `atlas bash "pg_prove tests/"` to check the wider `pgTAP` suite for collateral damage.
- 06Format SQL files: Ensure code consistency by running `atlas bash "sqlfluff format V1_3__add_email_not_null.sql"` on any modified SQL files.
- 07Review and commit changes: Review the unified diff presented by Atlas for all SQL and `pgTAP` file changes, then allow Atlas to stage and commit the fix and test.
Frequently asked questions
- How does Atlas run `pgTAP` tests for SQL?
- Atlas uses its `bash` tool to execute `pgTAP` commands directly, such as `pg_prove tests/my_test.sql` or `psql -d my_database -f tests/my_test.sql`, capturing the output and exit code to determine pass or fail states for your SQL tests.
- Can Atlas modify `Flyway migrations` files?
- Yes, Atlas can modify existing `Flyway migrations` files or create new ones using its `edit` or `write` tools. It always presents a unified diff for your review and approval before applying any changes to your SQL schema.
- How does Atlas ensure my SQL changes are safe?
- Atlas ensures safety by drafting plans in a read-only agent, requiring explicit permission for tool calls, and presenting a unified diff for every SQL file edit, including `pgTAP` tests and `Flyway migrations`, for developer approval before writing.
- Does Atlas support `sqlfluff format` for SQL code?
- Yes, Atlas can integrate `sqlfluff format` into its workflow. You can instruct Atlas to run `atlas bash "sqlfluff format my_migration.sql"` to automatically format SQL files after edits, maintaining consistent code style across your project.
- How does Atlas handle the red-green testing cycle for SQL?
- Atlas implements the red-green cycle for SQL by first writing a `pgTAP` test that fails, running it with `bash` to confirm the bug, then applying the fix with `edit`, and finally re-running the same `bash` command to confirm the test passes.
- What kind of SQL files can Atlas work with?
- Atlas can work with any `.sql` files, including `pgTAP` test scripts, `Flyway migrations` scripts, and general SQL query files. It indexes code by AST declarations using tree-sitter, understanding the structure and context of your SQL code.
- Can Atlas help me commit my SQL bug fix and test?
- Yes, Atlas reads `git` branches, status, and diffs. After you approve the changes, Atlas can stage the modified SQL and `pgTAP` test files and create a commit on your behalf, streamlining the version control process for your bug fixes.
Try Atlas in your terminal
The terminal-native AI coding agent. Free core, single binary.
Install AtlasRelated guides
Add a Regression Test for a Bug Fix with Atlas in 2026
How to add a regression test with Atlas in 2026: red first, then green. bash records the exit code, write creates the failing test, and edit applies the fix.
Atlas for SQL in 2026
Atlas is a terminal-native AI coding agent for SQL in 2026. Run it in a repo with your migrations or .sql files, optimize a query, and review the diff before applying.
Migrate a Deprecated API Across Every Callsite in SQL with Atlas in 2026
In 2026, Atlas helps SQL developers migrate deprecated functions or modules across an entire codebase, ensuring no callsite is missed and changes are validated with pgTAP and Flyway migrations.
Locate Where a Behavior is Implemented in SQL with Atlas in 2026
In 2026, Atlas helps SQL developers quickly locate the exact file and symbol responsible for a behavior across Flyway migrations and .sql files, using semantic search and LSP.
Review a Pull Request in SQL with Atlas in 2026
In 2026, SQL developers use Atlas to review pull requests, catching subtle bugs beyond line-by-line diffs. Atlas integrates with pgTAP and Flyway migrations for comprehensive SQL code review.
Rename a SQL Symbol Across Your Repo with Atlas in 2026
In 2026, Atlas helps SQL developers rename functions, classes, or constants across their entire codebase, integrating with pgTAP, Flyway, and sqlfluff for verified refactoring.
Onboard to an Unfamiliar SQL Codebase with Atlas in 2026
Rapidly build a mental model of any SQL repository in 2026 using Atlas. Leverage semantic search, explore Flyway migrations, and understand pgTAP tests without reading every file.
Run Atlas Headless in CI for SQL in 2026
Automate SQL development workflows in CI with Atlas. Learn how to run Atlas headless, integrate with pgTAP and Flyway migrations, and get machine-readable output for your SQL pipelines.