From 2a81fedcfb396f057c7dcc35fd526277ccfbade3 Mon Sep 17 00:00:00 2001 From: adela Date: Tue, 21 Apr 2026 16:50:04 +0200 Subject: [PATCH 1/2] update tx mode gitops --- docs/change-database/transaction-mode.mdx | 22 +++++++++++++++++++ .../migration-based-workflow/develop.mdx | 10 +++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/docs/change-database/transaction-mode.mdx b/docs/change-database/transaction-mode.mdx index dea979e8..80d2f6b5 100644 --- a/docs/change-database/transaction-mode.mdx +++ b/docs/change-database/transaction-mode.mdx @@ -30,6 +30,28 @@ 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 + ## 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 From fdd6f96a7a606a898c874cc6c1249e5514216eb9 Mon Sep 17 00:00:00 2001 From: adela Date: Tue, 21 Apr 2026 17:07:09 +0200 Subject: [PATCH 2/2] update --- docs/change-database/transaction-mode.mdx | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/change-database/transaction-mode.mdx b/docs/change-database/transaction-mode.mdx index 80d2f6b5..9f2dd316 100644 --- a/docs/change-database/transaction-mode.mdx +++ b/docs/change-database/transaction-mode.mdx @@ -51,6 +51,7 @@ 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