Error on multiple migrations in a single file
- 主要語言
- Go
- 星號
- 7.4k
- 分支
- 380
- 平均合併
- 1 天 16 小時
- 30 天內合併 PR
- 2
描述
**Description**
Using multiple migrations in a single file using additional migrate:up and migrate:down sections, I get the error:
Error: pq: duplicate key value violates unique constraint "schema_migrations_pkey" (23505)
Moreover, the file containing multiple migrations is reported as applied in `dbmate status`. In reality, only the first migration (`-- migrate:up` block) is applied.
- Version: 2.34.1
- Database: PostgreSQL
- Operating System: Debian
**Steps To Reproduce**
1. Use this migration file:
```sql
-- migrate:up
CREATE TABLE t1 (
col_a text
);
-- migrate:down
DROP TABLE t1;
-- migrate:up
CREATE TABLE t2 (
col_b text
);
-- migrate:down
DROP TABLE t2;
```
2. Run `dbmate migrate`
**Expected Behavior**
Successful migration
貢獻指南
這個儲存庫沒有索引到貢獻指南
研究方向
Use the SQL migration in the reproduction steps as the starting fixture; first run `dbmate migrate` and inspect the migration parsing and application path used by the `dbmate` entry point. Done means both tables are applied from one file without the duplicate-key error, and `dbmate status` reports the file accurately.
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- go, postgresql
- 領域
- cli, databases
- Issue 類型
- 缺陷
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 活躍
- 描述清晰度
- 描述清楚
- 新手友好度
- 68/100