diff --git a/docs/change-database/transaction-mode.mdx b/docs/change-database/transaction-mode.mdx index dea979e8..9f2dd316 100644 --- a/docs/change-database/transaction-mode.mdx +++ b/docs/change-database/transaction-mode.mdx @@ -30,6 +30,29 @@ For MySQL databases, Bytebase offers additional control over transaction isolati - **REPEATABLE READ**: Default MySQL isolation, prevents dirty and non-repeatable reads - **SERIALIZABLE**: Highest isolation, prevents all phenomena but may impact performance +## GitOps + +In the GitOps workflow there is no UI toggle, so transaction mode and isolation level are controlled via comment directives at the top of the migration file: + +```sql +-- txn-mode = off +-- txn-isolation = READ COMMITTED + +ALTER TABLE users ADD COLUMN email VARCHAR(255); +``` + +Supported directives: + +- `-- txn-mode = on|off` — wrap the script in a transaction, or run statements directly without transaction wrapping +- `-- txn-isolation = READ UNCOMMITTED | READ COMMITTED | REPEATABLE READ | SERIALIZABLE` — MySQL only + +Rules: + +- Directives must appear at the top of the file, before any non-comment SQL +- Empty lines between directives are allowed; scanning stops at the first non-comment line +- The order of the two directives does not matter +- Whitespace around `=` is optional — `-- txn-mode = off` and `-- txn-mode=off` are both accepted; the spaced form shown above is the canonical style + ## Best Practices - Keep transactions enabled for DDL and DML operations that modify data diff --git a/docs/gitops/migration-based-workflow/develop.mdx b/docs/gitops/migration-based-workflow/develop.mdx index 4a19589f..fe07a075 100644 --- a/docs/gitops/migration-based-workflow/develop.mdx +++ b/docs/gitops/migration-based-workflow/develop.mdx @@ -81,12 +81,18 @@ Choose a versioning strategy that fits your team: For zero-downtime MySQL schema changes, add this comment at the top of your file: ```sql --- migration-type: ghost +-- gh-ost = {} ALTER TABLE users ADD COLUMN email VARCHAR(255); ``` -This uses [gh-ost](https://github.com/github/gh-ost) to apply changes without blocking your database. +This uses [gh-ost](https://github.com/github/gh-ost) to apply changes without blocking your database. Use `{}` to run with default flags, or pass gh-ost flags as a JSON object: + +```sql +-- gh-ost = {"max-lag-millis":"1500","cut-over-lock-timeout-seconds":"10"} + +ALTER TABLE users ADD COLUMN email VARCHAR(255); +``` Learn more about gh-ost