Friday, May 31, 2019

Re: state_operations while adding 2 fields

> Am 31.05.2019 um 13:15 schrieb Axel Rau <Axel.Rau@chaos1.de>:
>
> is it posible to bundle 2 AddField migrations with one RunPython?
> How should I arrange the state_operations in this case?
>
> The following migration does not work.

It seems, the variant below does the job.
However there is no state operation for undoing the migration.

Axel

- - -
class Migration(migrations.Migration):

dependencies = [
('erdb', '0007_add_customer_group'),
]

operations = [
migrations.RunPython(forwards_func, reverse_code=reverse_func),
migrations.SeparateDatabaseAndState(
database_operations=[],
state_operations=[
migrations.AddField(
model_name='account',
name='is_account_admin',
field=models.BooleanField(
db_column='is_account_admin',
default=False),
),
migrations.AddField(
model_name='account',
name='self_admin_only',
field=models.BooleanField(
db_column='self_admin_only',
default=False),
),
],
)
]
- - -
---
PGP-Key:29E99DD6 ☀ computing @ chaos claudius

--
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-users@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/8FA10E29-8B1E-4A60-A483-DB8104C36FDD%40Chaos1.DE.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment