Skip to content

Commit

Permalink
refactor: impacts #17, #21, and #6, making Category many-to-many
Browse files Browse the repository at this point in the history
  • Loading branch information
erictheise committed Mar 24, 2020
1 parent c3b4a30 commit b2524d7
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
24 changes: 24 additions & 0 deletions mdi/migrations/0038_auto_20200324_0329.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 3.0.3 on 2020-03-24 03:29

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('mdi', '0037_auto_20200323_0409'),
]

operations = [
migrations.AddField(
model_name='organization',
name='categories',
field=models.ManyToManyField(blank=True, null=True, to='mdi.Category'),
),
migrations.AlterField(
model_name='organization',
name='category',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='category_orig', to='mdi.Category'),
),
]
21 changes: 21 additions & 0 deletions mdi/migrations/0039_auto_20200324_0331.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 3.0.3 on 2020-03-24 03:31

from django.db import models, migrations


def forward(apps, schema_editor):
Organization = apps.get_model("mdi", "Organization")
for organization in Organization.objects.all():
if organization.category is not None:
organization.categories.add(organization.category)


class Migration(migrations.Migration):

dependencies = [
('mdi', '0038_auto_20200324_0329'),
]

operations = [
migrations.RunPython(forward)
]
17 changes: 17 additions & 0 deletions mdi/migrations/0040_remove_organization_category.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 3.0.3 on 2020-03-24 03:51

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('mdi', '0039_auto_20200324_0331'),
]

operations = [
migrations.RemoveField(
model_name='organization',
name='category',
),
]

0 comments on commit b2524d7

Please sign in to comment.