Non-transactional migrations, callbacks, and superseded repeatables#2
Merged
Conversation
…bles Closes #1. Add three Flyway behaviors, each with unit and integration tests: 1. Per-script non-transactional execution. A script whose first comment lines carry a "-- goway:noTransaction" directive runs outside the per-migration transaction on a dedicated connection, enabling statements such as PostgreSQL's CREATE INDEX CONCURRENTLY and SQLite's VACUUM. A new sessionSearchPathSQL dialect method sets the schema for such runs. 2. Lifecycle callbacks. SQL callback scripts (beforeMigrate, afterMigrate, beforeEachMigrate, afterEachMigrate) are discovered in the configured locations, and callbacks can also be registered programmatically through the Callback interface and the CallbackFunc adapter. 3. Superseded state for repeatable migrations. Info now keeps every applied run of a repeatable migration; the newest by installed rank is current and the older runs are reported as Superseded, which is never a validation error. Update the README and design documentation accordingly.
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.
Closes #1.
Implements the three missing Flyway behaviors, each developed with TDD (unit tests first) and verified with integration tests against real PostgreSQL (testcontainers) and SQLite.
1. Per-script non-transactional execution
A script whose first comment lines carry
-- goway:noTransaction(the-- flyway:executeInTransaction=falseform is also accepted) runs outside the per-migration transaction, on a dedicated connection.CREATE INDEX CONCURRENTLY(PostgreSQL) andVACUUM(SQLite).sessionSearchPathSQLdialect method sets the schema for the session.Repaircan clear.2. Callbacks
beforeMigrate.sql,afterMigrate.sql,beforeEachMigrate.sql,afterEachMigrate__desc.sql.Configure().Callbacks(...), theCallbackinterface, and theCallbackFuncadapter.3. Superseded state for repeatables
Infokeeps every applied run of a repeatable migration.installed_rankis current (Success/Outdated); older runs areStateSuperseded.Supersededis never a validation error.Tests
script_test.go,callback_test.go,info_superseded_test.go(+ existing suite) — all green.integration/parity_test.goadds 6 tests (PostgreSQL concurrent index + control, SQLite vacuum, SQL callbacks, programmatic callbacks, repeatable supersede). Full suite: 21 pass, 0 fail.Docs
README "Status and roadmap" updated; new Callbacks and Non-transactional sections in README and
docs/design.md.