Hey Bibhas,

thank you for the report. I can verify that behavior and would classify it 
as a release blocker since it leads to potential data loss. Can you open a 
ticket on https://code.djangoproject.com/ please.

In general a migration is a collection of operations. The migration will 
only be unapplied if all operations are reversible. There is no direct way 
to prevent a migration (file) to be unapplied. I'm not sure if it's worth 
to add a property / attribute to the migration class to centralize that 
check. You could open a ticket as well.

As a workaround you can add "migrations.RunPython(lambda apps, 
schema_editor: None)" as first operation in the operations list for that 
migration. It is a noop in forwards migrations and not reversible. But in 
adding a RunPython operation you will lose the ability to squash migrations.

/Markus

On Sunday, December 21, 2014 1:32:29 PM UTC+1, Bibhas wrote:
>
> Hi,
>
> I need to make a migration irreversible. And strangely I don't see any way 
> to do it in the migration doc. I see that the Operation class has a 
> property called `reversible`, but don't see any way to set it to False.
>
> I had a legacy model that was generated with inspectdb, hence it had 
> managed=False. But now when I Need to make changes to it I removed the 
> managed flag and the migration is trying to delete the table and create it 
> again. I removed the droptable operation and faked the migration to avoid 
> the error. But if I revert the migration, that table is going to be dropped 
> anyway, right? Because it's the revert operation of CreateTable. How do I 
> stop the backward migration for this particular migration? There is nothing 
> much important before it, so it's not a trouble if it's irreversible.
>
> Am I missing something really obvious?
>
> Thanks,
> Bibhas
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6cbcca9e-d60d-419d-874c-e5d234e7c6a2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to