amacneil / amacneil/dbmate

Support for project-local migration templates

Offen
#711 0 Kommentare 6 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
feature request
Vorherrschende Sprache
Go
Sterne
7.4k
Forks
380
Ø Merge
1 T. 16 Std.
Gemergte PRs (30 T.)
2

Beschreibung

When running migrations on production databases with active traffic, it's important to include safety settings like `SET lock_timeout = '5s';` to prevent migrations from blocking writes indefinitely while waiting for locks.

Currently, teams must remember to manually add this to every migration - which is error-prone. A simple template feature would allow enforcing safe defaults automatically.

**Proposed solution:**

If a template file exists in the project (e.g., `db/.dbmate/template.sql` or configured via `--template-file`), `dbmate new` would use it instead of the default empty template:

```sql
-- migrate:up
SET lock_timeout = '5s';

-- migrate:down
```

**Why this differs from PR #530:**

The closed PR stored templates in `~/.config`, which goes against dbmate's KISS philosophy. This proposal keeps templates **in the project repo**, making them:
- Version controlled with the project
- Shared across the team automatically
- Consistent with dbmate's simple, portable approach

This is a small change that would help teams enforce safe migration practices without external tooling.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.