Support "rename field" in automatic migration generator

Abierto
#209 2 comentarios 0 reacciones 1 asignado Ver en GitHub

Los mantenedores suelen responder en 1 día

@Soroushsrd ya está trabajando en esto.

Desde el 15/4/2025.

Evaluación

Este issue todavía no se ha evaluado.

Descripción

enhancement

We should support renaming fields in the automatic migration generator.

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

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

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 field" operation will need to store the old name of the field, so that an implementation of Operation::backwards can be created.

Lenguaje dominante
Rust
Estrellas
1.1k
Forks
57
Merge medio
17 h 39 min
PR fusionados (30 d)
12

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de cot-rs/cot

Todos los issues de cot-rs/cot

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.