revert target-version does not behave as expected

Aperta
#4,231 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 4 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
postgresql, rust, sql
Ambito
cli, databases

Direzione di ricerca

Start from sqlx-cli migrate revert versus migrate run and how --target-version is interpreted (the dry-run logs show revert skipping the named version while still reverting later ones). Trace the CLI option into the migration planner and compare the run path, which already applies the target and skips the rest. Done when revert --target-version N dry-run (and a real revert) stops at N the same way run does, with tests covering that ordering.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug
I have found these related issues/pull requests

None

Description

If I use sqlx-cli (version 0.7.4) with command sqlx migrate revert --target-version <version>, my intended target is skipped and other migrations are reverted instead.

I posted this in discussions (#4218), but no replies in 4 days. After thinking about the logic for a few days, I think this may be an unintentional bug (seems unlikely because --target-version is a standard option for run or revert) or, at best, a poor user experience -- counterintuitive.

Reproduction steps

Opposite of what I expected:

steve@pop-os:~/Coding/rust_projects/webdev/bookmarks-rs$ sqlx migrate revert --dry-run --target-version 20240330153006 -D $DATABASE_URL/bookmarks
Can apply 20250905212818/revert test (0ns)
Can apply 20250428203929/revert mirror pinboard (0ns)
Skipped 20240330153006/revert use tag arrays (0ns) 

It skips the target script, but reverts the others?

When I use the run command it behaves as I expected:

steve@pop-os:~/Coding/rust_projects/webdev/bookmarks-rs$ sqlx migrate run --dry-run --target-version 20240330153006 -D $DATABASE_URL/bookmarks
Can apply 20240330153006/migrate use tag arrays (0ns)
Skipped 20250428203929/migrate mirror pinboard (0ns)
Skipped 20250905212818/migrate test (0ns) 

It runs the target and skips the others. I am showing my dry-run but the executed commands behaved the same.

Am I missing something? This revert behavior seems counterintuitive.

SQLx version

0.8.6

Enabled SQLx features

"runtime-tokio", "postgres", "tls-rustls", "chrono"

Database server and version

Postgres 18.3

Operating system

Pop_OS 22.04

Rust version

1.87.0

Lingua principale
Rust
Stelle
17.5k
Fork
1.7k
Merge medio
1g 17h
PR unite (30g)
7

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di transact-rs/sqlx

Tutte le issue di transact-rs/sqlx

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.