Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions docs/change-database/transaction-mode.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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

Comment thread
adela-bytebase marked this conversation as resolved.
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
Expand Down
10 changes: 8 additions & 2 deletions docs/gitops/migration-based-workflow/develop.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
```

<Card title="Online Schema Migration" icon="bolt" href="/change-database/online-schema-migration-for-mysql">
Learn more about gh-ost
Expand Down
Loading