amacneil / amacneil/dbmate

Error on multiple migrations in a single file

Aperta
#820 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
bug
Lingua principale
Go
Stelle
7.4k
Fork
379
Merge medio
6m
PR unite (30g)
1

Descrizione

**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

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.