Support "rename model" in automatic migration generator

Aperta
#208 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
rust
Ambito
database

Direzione di ricerca

Start in cot-cli/src/migration_generator.rs at generate_operarations, then read cot/src/db/migrations.rs around OperationInner and Operation::backwards. The issue proposes interactive rename detection and a new operation that stores the old model name. Done means the generator can distinguish a rename from delete-and-create with developer input, and the operation can be reversed.

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

Descrizione

enhancement

We should support renaming models in the automatic migration generator.

This is more complicated than most of the other operations. This is because we can't reliably detect renaming models (we only see that a model has been removed and then created). For starters, we could detect if a model was renamed by keeping all of the fields intact. Then, we could add some heuristics (like for instance, we see that a model was removed but then recreated with 80% of its original fields). This, however, needs to be interactive—we need to ask the developer if they actually renamed the model (and then create either a rename, or delete+create operations depending on their reply).

The entry point is probably somewhere in the generate_operarations function: https://github.com/cot-rs/cot/blob/2bbb09699bf7b74c41bb323338a02c528de1acff/cot-cli/src/migration_generator.rs#L271

This will require adding a new OperationInner variant: https://github.com/cot-rs/cot/blob/2bbb09699bf7b74c41bb323338a02c528de1acff/cot/src/db/migrations.rs#L460

Note that the "rename model" operation will need to store the old name of the model, so that an implementation of Operation::backwards can be created.

Lingua principale
Rust
Stelle
1.1k
Fork
57
Merge medio
17h 39m
PR unite (30g)
12

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 cot-rs/cot

Tutte le issue di cot-rs/cot

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.