Fields deleted on migration
See original GitHub issueHello
I just tried an upgrade to django 1.8 form django 1.7.7 and from django-simple-history 1.5.4 to django-simple-history 1.6.1 and run into some problems when running new migrations.
I have several models with ForeignKey fields. After upgrading and running
./manege makemigrations
All the ForeignKey fields got removed and added again, causing data lost.
For instance one migrations does this (tables and fields in spanish):
...
migrations.RemoveField(
model_name='historicalitemordendecompra',
name='item_id',
),
...
migrations.AddField(
model_name='historicalitemordendecompra',
name='item',
field=models.ForeignKey(null=True, db_constraint=False, blank=True, related_name='+', on_delete=django.db.models.deletion.DO_NOTHING, to='almacen.Item'),
),
...
I’ve been playing with the idea of manually changing migrations to AlterField and RenameField but that sounds like a lengthy and not sure how safe process.
Help is appreciated.
Issue Analytics
- State:
- Created 8 years ago
- Comments:10 (4 by maintainers)
Top Results From Across the Web
How to drop columns using Rails migration - Stack Overflow
Generate a migration to remove a column such that if it is migrated ( rake db:migrate ), it should drop the column. And...
Read more >Solved: Can't remove "Migrated On ..." field description
Follow a migration from JIRA Server to JIRA Cloud, there is an annoying field description which states that the field was migrated and...
Read more >Removing fields with a Rails migration - Tosbourn
Ruby on Rails gives you powerful tools to make removing old fields easy, lets walk through how we can do this.
Read more >Deleting a model and fields that relate to it results in ValueError
This seems to happen because a single migration is created which both deletes the model and the fields that reference it - but...
Read more >Deleting/Editing fields with Migration Tool
Can I delete and edit custom fields using the ANT Migration Tool. In the documentation I only found how to delete the entire...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hello, I did almsot the same as you, but didn’t need to re-run “makemigrations”, I renamed and then altered the fields. I guess the result is the same:
Cheers.
Don’t think this issue is relevant anymore.