--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a52ae01a-1a7d-43ce-a94f-fb00c4e1b7d1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
you can remove the field and don't run migrations until you are ready to actually remove the column, or you may run migrations fake and leave the column there forever
On Wed, Jul 5, 2017 at 6:39 AM, <tay...@cedar.com> wrote:
I am having some trouble figuring out the best way to remove model fields in Django. If I remove a field from a model and then run makemigrations, it creates a RemoveField operation in a migration. That is great, but if I decide to run the migration before releasing the new code, the existing code will break (for a short time between running the migration and releasing the new code) because the old code is still querying for the removed column (Django queries for all columns by default). I could run the migration after the release, but that won't work if I also have an AddField operation because the new code needs the new column, so it needs to be run before. I am wondering if anyone has solved this issue?My best solution (I don't think Django supports this) would be to have a special type of field called a DeprecatedField. It would delete the field from Django's perspective, but keep the column in the DB. Django would no longer query for the column, but the column would still be in the DB. On the next release, I could remove the column completely (with a RemoveField operation) and the existing code would not error because it has no knowledge of the column.I noticed Django has an idea of a private field, which is on a model but not in the DB. Is there a way to create a field that is in the DB, but Django model doesn't query for it or allow it to be used in creates and updates? Very similar to the managed=False on the Model, but on the Field level. If anyone has other approaches to the problem, I would be very excited to find alternative methods.Thanks,Taylor
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
Hi,
Sounds like your all developers do use same database if you have such a problems.
It's usually good practice to have per developer development
database. That will allow individual developers to do changes to
database and migrate others as they please. Also it doesn't
"matter" if one developer breaks their database for example by
accidentally running migrations that are not in the repo yet.
Of course, it requires that you have either database creation
script, or like we do, we clone our staging database for
development basis.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e1f61e62-a6cc-44a4-ba35-7fa8b28c5549%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
-- Jani Tiainen
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e1f61e62-a6cc-44a4-ba35-7fa8b28c5549%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
-- Jani Tiainen
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d4ba64c5-0dac-bcb4-520f-78835d049ad4%40gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e1f61e62-a6cc-44a4-ba35-7fa8b28c5549%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
-- Jani Tiainen
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
It seems to me more a organization/project
management isssue that something that should be handled by Django
itself. Well, if I got the problem correctly, that is.
It seems you can't remove the field from the Model class because that would remove the column from the underline table itself as soon as the migration is executed.
If your developers are doing development on their own computers (like they should), it would be a matter to leave them working on a different branch of the SCM where you're not applying that. Later is just a matter to provide comunication that they should update their own local repositories after you finished the merge process.
In the case you need to keep the column around for a while, you
might want to add some abstraction, like a view with a harcoded
value for that column.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f8891294-3be5-41d0-a6a7-9740d7b8b3bb%40googlegroups.com.
Hi,
Well, seems that your deployment process needs fixing.
Simplest option is to stop serving site (put it to maintenance mode to show for example static maintenance page), update codebase and run migrations. Restart servers and put django serving back.
If you're looking zero downtime migrations you have to plan model
modifications very carefully.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a4d711f4-7996-47ea-b903-c73698bdac29%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
-- Jani Tiainen
On Tuesday 04 July 2017 20:39:37 tay...@cedar.com wrote:
> I am having some trouble figuring out the best way to remove model
> fields in Django. If I remove a field from a model and then run
> makemigrations, it creates a RemoveField operation in a migration.
> That is great, but if I decide to run the migration before releasing
> the new code, the existing code will break (for a short time between
> running the migration and releasing the new code) because the old
> code is still querying for the removed column (Django queries for all
> columns by default). I could run the migration after the release, but
> that won't work if I also have an AddField operation because the new
> code needs the new column, so it needs to be run before. I am
> wondering if anyone has solved this issue?
You're fixing this in the wrong place. This is for the project manager and technical lead to fix. If you have dependencies between releases that break the product if either one of them is not applied, then you need to move components of those releases so that it doesn't happen.
Also, migrations exist to have a consistent code versus database.
A developer's task to "remove field A", isn't simply to remove the field from the model and makemigrations. Her task isn't done till all querysets that reference that field by name are refactored.
--
Melvyn Sopacua