amacneil / amacneil/dbmate

Support for project-local migration templates

Aberta
#711 0 comentários 6 reações 0 responsáveis Ver no GitHub
feature request
Linguagem predominante
Go
Estrelas
7.4k
Forks
380
Merge médio
1d 16h
PRs com merge (30d)
2

Descrição

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.

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.